Chore: Edit button on cells should be guessed by the field's type (#1952)

* created custom hook to get Icon Component as per field type

* Fix conflicts

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Ayush Agrawal
2023-10-18 02:12:57 +05:30
committed by GitHub
parent 2c1ad1661a
commit a1a2309140
10 changed files with 40 additions and 38 deletions

View File

@ -2,10 +2,12 @@ import { useContext } from 'react';
import { FieldDisplay } from '@/ui/data/field/components/FieldDisplay';
import { FieldInput } from '@/ui/data/field/components/FieldInput';
import { FieldContext } from '@/ui/data/field/contexts/FieldContext';
import { useGetButtonIcon } from '@/ui/data/field/hooks/useGetButtonIcon';
import { FieldInputEvent } from '@/ui/data/field/types/FieldInputEvent';
import { IconArrowUpRight } from '@/ui/display/icon';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { ColumnIndexContext } from '../../contexts/ColumnIndexContext';
import { useMoveSoftFocus } from '../../hooks/useMoveSoftFocus';
import { useTableCell } from '../hooks/useTableCell';
@ -16,7 +18,9 @@ export const TableCell = ({
}: {
customHotkeyScope: HotkeyScope;
}) => {
const { fieldDefinition } = useContext(FieldContext);
const isFirstColumn = useContext(ColumnIndexContext) === 0;
const buttonIcon = useGetButtonIcon();
const { closeTableCell } = useTableCell();
@ -68,7 +72,7 @@ export const TableCell = ({
/>
}
nonEditModeContent={<FieldDisplay />}
buttonIcon={fieldDefinition.buttonIcon}
buttonIcon={isFirstColumn ? IconArrowUpRight : buttonIcon}
></TableCellContainer>
);
};