[REFACTOR][FRONT]: Remove objectMetadata and fieldMetadata sluggification (#9441)
# Introduction For motivations and context please have a look to https://github.com/twentyhq/twenty/pull/9394 whom this PR results from. In this pull-request we remove any `metadataField` and `objectMetadata` sluggification. We directly consume `objectMetadata.namePlural` and `metadataField.name`, ***it seems like that historically the consumed `metadataField.name`*** are we sure that we wanna change this behavior ? ## Notes Unless I'm mistaken by reverting the `kebabcase` url formatting we might be creating deadlinks that user could have save beforehand => Discussed with Charles said it's controlled risk. --------- Co-authored-by: Paul Rastoin <paulrastoin@Pauls-MacBook-Pro.local>
This commit is contained in:
@ -35,7 +35,7 @@ const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||
);
|
||||
|
||||
describe('useFilteredObjectMetadataItems', () => {
|
||||
it('should findActiveObjectMetadataItemBySlug', async () => {
|
||||
it('should findActiveObjectMetadataItemByNamePlural', async () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
||||
@ -49,13 +49,14 @@ describe('useFilteredObjectMetadataItems', () => {
|
||||
);
|
||||
|
||||
act(() => {
|
||||
const res = result.current.findActiveObjectMetadataItemBySlug('people');
|
||||
const res =
|
||||
result.current.findActiveObjectMetadataItemByNamePlural('people');
|
||||
expect(res).toBeDefined();
|
||||
expect(res?.namePlural).toBe('people');
|
||||
});
|
||||
});
|
||||
|
||||
it('should findObjectMetadataItemBySlug', async () => {
|
||||
it('should findObjectMetadataItemByNamePlural', async () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
||||
@ -69,7 +70,7 @@ describe('useFilteredObjectMetadataItems', () => {
|
||||
);
|
||||
|
||||
act(() => {
|
||||
const res = result.current.findObjectMetadataItemBySlug('people');
|
||||
const res = result.current.findObjectMetadataItemByNamePlural('people');
|
||||
expect(res).toBeDefined();
|
||||
expect(res?.namePlural).toBe('people');
|
||||
});
|
||||
|
||||
@ -2,8 +2,6 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
|
||||
|
||||
import { getObjectSlug } from '../utils/getObjectSlug';
|
||||
|
||||
export const useFilteredObjectMetadataItems = () => {
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
|
||||
@ -27,17 +25,6 @@ export const useFilteredObjectMetadataItems = () => {
|
||||
({ isActive, isSystem }) => !isActive && !isSystem,
|
||||
);
|
||||
|
||||
const findObjectMetadataItemBySlug = (slug: string) =>
|
||||
objectMetadataItems.find(
|
||||
(objectMetadataItem) => getObjectSlug(objectMetadataItem) === slug,
|
||||
);
|
||||
|
||||
const findActiveObjectMetadataItemBySlug = (slug: string) =>
|
||||
activeObjectMetadataItems.find(
|
||||
(activeObjectMetadataItem) =>
|
||||
getObjectSlug(activeObjectMetadataItem) === slug,
|
||||
);
|
||||
|
||||
const findActiveObjectMetadataItemByNamePlural = (namePlural: string) =>
|
||||
activeObjectMetadataItems.find(
|
||||
(activeObjectMetadataItem) =>
|
||||
@ -56,13 +43,11 @@ export const useFilteredObjectMetadataItems = () => {
|
||||
|
||||
return {
|
||||
activeObjectMetadataItems,
|
||||
findActiveObjectMetadataItemBySlug,
|
||||
findObjectMetadataItemById,
|
||||
findObjectMetadataItemByNamePlural,
|
||||
findActiveObjectMetadataItemByNamePlural,
|
||||
inactiveObjectMetadataItems,
|
||||
objectMetadataItems,
|
||||
findObjectMetadataItemBySlug,
|
||||
alphaSortedActiveObjectMetadataItems,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user