feat: disable Standard field edition in Relation field form (#2604)
* feat: disable Standard field edition in Relation field form Closes #2584 * refactor: code review
This commit is contained in:
@ -18,6 +18,7 @@ export type SettingsObjectFieldRelationFormValues = Partial<{
|
||||
}>;
|
||||
|
||||
type SettingsObjectFieldRelationFormProps = {
|
||||
disableFieldEdition?: boolean;
|
||||
disableRelationEdition?: boolean;
|
||||
onChange: (values: SettingsObjectFieldRelationFormValues) => void;
|
||||
values?: SettingsObjectFieldRelationFormValues;
|
||||
@ -46,6 +47,7 @@ const StyledInputsContainer = styled.div`
|
||||
`;
|
||||
|
||||
export const SettingsObjectFieldRelationForm = ({
|
||||
disableFieldEdition,
|
||||
disableRelationEdition,
|
||||
onChange,
|
||||
values,
|
||||
@ -96,6 +98,7 @@ export const SettingsObjectFieldRelationForm = ({
|
||||
</StyledInputsLabel>
|
||||
<StyledInputsContainer>
|
||||
<IconPicker
|
||||
disabled={disableFieldEdition}
|
||||
dropdownScopeId="field-destination-icon-picker"
|
||||
selectedIconKey={values?.field?.icon || undefined}
|
||||
onChange={(value) =>
|
||||
@ -106,6 +109,7 @@ export const SettingsObjectFieldRelationForm = ({
|
||||
variant="primary"
|
||||
/>
|
||||
<TextInput
|
||||
disabled={disableFieldEdition}
|
||||
placeholder="Field name"
|
||||
value={values?.field?.label || ''}
|
||||
onChange={(value) => {
|
||||
|
||||
@ -27,7 +27,7 @@ type SettingsObjectFieldTypeSelectSectionProps = {
|
||||
excludedFieldTypes?: FieldMetadataType[];
|
||||
fieldMetadata: Pick<Field, 'icon' | 'label'> & { id?: string };
|
||||
onChange: (values: SettingsObjectFieldTypeSelectSectionFormValues) => void;
|
||||
relationFieldMetadataId?: string;
|
||||
relationFieldMetadata?: Pick<Field, 'id' | 'isCustom'>;
|
||||
values?: SettingsObjectFieldTypeSelectSectionFormValues;
|
||||
} & Pick<SettingsObjectFieldPreviewProps, 'objectMetadataId'>;
|
||||
|
||||
@ -50,7 +50,7 @@ export const SettingsObjectFieldTypeSelectSection = ({
|
||||
fieldMetadata,
|
||||
objectMetadataId,
|
||||
onChange,
|
||||
relationFieldMetadataId,
|
||||
relationFieldMetadata,
|
||||
values,
|
||||
}: SettingsObjectFieldTypeSelectSectionProps) => {
|
||||
const relationFormConfig = values?.relation;
|
||||
@ -116,7 +116,7 @@ export const SettingsObjectFieldTypeSelectSection = ({
|
||||
label:
|
||||
relationFormConfig.field?.label || 'Field name',
|
||||
type: FieldMetadataType.Relation,
|
||||
id: relationFieldMetadataId,
|
||||
id: relationFieldMetadata?.id,
|
||||
}}
|
||||
shrink
|
||||
objectMetadataId={relationFormConfig.objectMetadataId}
|
||||
@ -129,7 +129,10 @@ export const SettingsObjectFieldTypeSelectSection = ({
|
||||
form={
|
||||
values.type === FieldMetadataType.Relation && (
|
||||
<SettingsObjectFieldRelationForm
|
||||
disableRelationEdition={!!relationFieldMetadataId}
|
||||
disableFieldEdition={
|
||||
relationFieldMetadata && !relationFieldMetadata.isCustom
|
||||
}
|
||||
disableRelationEdition={!!relationFieldMetadata}
|
||||
values={relationFormConfig}
|
||||
onChange={(nextValues) =>
|
||||
onChange({
|
||||
|
||||
Reference in New Issue
Block a user