Prevent remote object updates (#4804)

Backend: Adding a new util function that throw an error if the
objectMetadata is remote

Frontend: hiding the save button when remote

Also renaming `useObjectMetadataItemForSettings` since this hook is used
in other places than settings and is not in the settings repo. Name can
definitely be challenged!

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-04-04 15:47:08 +02:00
committed by GitHub
parent c5349291c8
commit 2e419091cc
16 changed files with 79 additions and 40 deletions

View File

@ -6,7 +6,7 @@ import pick from 'lodash.pick';
import { IconArchive, IconSettings } from 'twenty-ui';
import { z } from 'zod';
import { useObjectMetadataItemForSettings } from '@/object-metadata/hooks/useObjectMetadataItemForSettings';
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { useUpdateOneObjectMetadataItem } from '@/object-metadata/hooks/useUpdateOneObjectMetadataItem';
import { getObjectSlug } from '@/object-metadata/utils/getObjectSlug';
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
@ -44,7 +44,7 @@ export const SettingsObjectEdit = () => {
const { objectSlug = '' } = useParams();
const { findActiveObjectMetadataItemBySlug } =
useObjectMetadataItemForSettings();
useFilteredObjectMetadataItems();
const { updateOneObjectMetadataItem } = useUpdateOneObjectMetadataItem();
const activeObjectMetadataItem =