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

@ -0,0 +1,22 @@
import { useContext } from 'react';
import { IconPencil } from '@/ui/display/icon';
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
import { FieldContext } from '../contexts/FieldContext';
import { isFieldEmail } from '../types/guards/isFieldEmail';
import { isFieldPhone } from '../types/guards/isFieldPhone';
import { isFieldRelation } from '../types/guards/isFieldRelation';
import { isFieldURL } from '../types/guards/isFieldURL';
export const useGetButtonIcon = (): IconComponent | undefined => {
const { fieldDefinition } = useContext(FieldContext);
if (
isFieldURL(fieldDefinition) ||
isFieldEmail(fieldDefinition) ||
isFieldPhone(fieldDefinition) ||
isFieldRelation(fieldDefinition)
) {
return IconPencil;
}
};

View File

@ -10,7 +10,6 @@ export type FieldDefinition<T extends FieldMetadata> = {
Icon?: IconComponent;
type: FieldType;
metadata: T;
buttonIcon?: IconComponent;
basePathToShowPage?: string;
infoTooltipContent?: string;
entityChipDisplayMapper?: (dataObject: any) => {