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:
22
front/src/modules/ui/data/field/hooks/useGetButtonIcon.ts
Normal file
22
front/src/modules/ui/data/field/hooks/useGetButtonIcon.ts
Normal 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;
|
||||
}
|
||||
};
|
||||
@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user