diff --git a/front/src/AppNavbar.tsx b/front/src/AppNavbar.tsx index d49de53e57..2d8180e777 100644 --- a/front/src/AppNavbar.tsx +++ b/front/src/AppNavbar.tsx @@ -3,7 +3,7 @@ import { useLocation, useNavigate } from 'react-router-dom'; import { useCurrentUserTaskCount } from '@/activities/tasks/hooks/useCurrentUserDueTaskCount'; import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu'; import { Favorites } from '@/favorites/components/Favorites'; -import { MetadataObjectNavItems } from '@/metadata/components/MetadataObjectNavItems'; +import { ObjectMetadataNavItems } from '@/metadata/components/ObjectMetadataNavItems'; import { SettingsNavbar } from '@/settings/components/SettingsNavbar'; import { IconBell, @@ -95,7 +95,7 @@ export const AppNavbar = () => { Icon={IconTargetArrow} active={currentPath === '/opportunities'} /> - {isFlexibleBackendEnabled && } + {isFlexibleBackendEnabled && } ) : ( diff --git a/front/src/generated-metadata/gql.ts b/front/src/generated-metadata/gql.ts index fc139c467e..9fd1e0e9a0 100644 --- a/front/src/generated-metadata/gql.ts +++ b/front/src/generated-metadata/gql.ts @@ -13,13 +13,13 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - "\n mutation CreateOneMetadataObject($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.CreateOneMetadataObjectDocument, + "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.CreateOneObjectMetadataItemDocument, "\n mutation CreateOneMetadataField($input: CreateOneFieldInput!) {\n createOneField(input: $input) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.CreateOneMetadataFieldDocument, "\n mutation UpdateOneMetadataField(\n $idToUpdate: ID!\n $updatePayload: UpdateFieldInput!\n ) {\n updateOneField(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.UpdateOneMetadataFieldDocument, - "\n mutation UpdateOneMetadataObject(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.UpdateOneMetadataObjectDocument, - "\n mutation DeleteOneMetadataObject($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.DeleteOneMetadataObjectDocument, + "\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.UpdateOneObjectMetadataItemDocument, + "\n mutation DeleteOneObjectMetadataItem($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n": types.DeleteOneObjectMetadataItemDocument, "\n mutation DeleteOneMetadataField($idToDelete: ID!) {\n deleteOneField(input: { id: $idToDelete }) {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n": types.DeleteOneMetadataFieldDocument, - "\n query MetadataObjects {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n": types.MetadataObjectsDocument, + "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n": types.ObjectMetadataItemsDocument, }; /** @@ -39,7 +39,7 @@ export function graphql(source: string): unknown; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n mutation CreateOneMetadataObject($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation CreateOneMetadataObject($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; +export function graphql(source: "\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) {\n createOneObject(input: $input) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -51,11 +51,11 @@ export function graphql(source: "\n mutation UpdateOneMetadataField(\n $idTo /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n mutation UpdateOneMetadataObject(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation UpdateOneMetadataObject(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; +export function graphql(source: "\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation UpdateOneObjectMetadataItem(\n $idToUpdate: ID!\n $updatePayload: UpdateObjectInput!\n ) {\n updateOneObject(input: { id: $idToUpdate, update: $updatePayload }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n mutation DeleteOneMetadataObject($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation DeleteOneMetadataObject($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; +export function graphql(source: "\n mutation DeleteOneObjectMetadataItem($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"): (typeof documents)["\n mutation DeleteOneObjectMetadataItem($idToDelete: ID!) {\n deleteOneObject(input: { id: $idToDelete }) {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -63,7 +63,7 @@ export function graphql(source: "\n mutation DeleteOneMetadataField($idToDelete /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query MetadataObjects {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"): (typeof documents)["\n query MetadataObjects {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"]; +export function graphql(source: "\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"): (typeof documents)["\n query ObjectMetadataItems {\n objects(paging: { first: 1000 }) {\n edges {\n node {\n id\n dataSourceId\n nameSingular\n namePlural\n labelSingular\n labelPlural\n description\n icon\n isCustom\n isActive\n createdAt\n updatedAt\n fields(paging: { first: 1000 }) {\n edges {\n node {\n id\n type\n name\n label\n description\n icon\n placeholder\n isCustom\n isActive\n isNullable\n createdAt\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n totalCount\n }\n }\n"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/front/src/generated-metadata/graphql.ts b/front/src/generated-metadata/graphql.ts index c7672dcff2..f0b706457c 100644 --- a/front/src/generated-metadata/graphql.ts +++ b/front/src/generated-metadata/graphql.ts @@ -806,12 +806,12 @@ export type ObjectEdge = { node: Object; }; -export type CreateOneMetadataObjectMutationVariables = Exact<{ +export type CreateOneObjectMetadataItemMutationVariables = Exact<{ input: CreateOneObjectInput; }>; -export type CreateOneMetadataObjectMutation = { __typename?: 'Mutation', createOneObject: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any } }; +export type CreateOneObjectMetadataItemMutation = { __typename?: 'Mutation', createOneObject: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any } }; export type CreateOneMetadataFieldMutationVariables = Exact<{ input: CreateOneFieldInput; @@ -828,20 +828,20 @@ export type UpdateOneMetadataFieldMutationVariables = Exact<{ export type UpdateOneMetadataFieldMutation = { __typename?: 'Mutation', updateOneField: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }; -export type UpdateOneMetadataObjectMutationVariables = Exact<{ +export type UpdateOneObjectMetadataItemMutationVariables = Exact<{ idToUpdate: Scalars['ID']['input']; updatePayload: UpdateObjectInput; }>; -export type UpdateOneMetadataObjectMutation = { __typename?: 'Mutation', updateOneObject: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any } }; +export type UpdateOneObjectMetadataItemMutation = { __typename?: 'Mutation', updateOneObject: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any } }; -export type DeleteOneMetadataObjectMutationVariables = Exact<{ +export type DeleteOneObjectMetadataItemMutationVariables = Exact<{ idToDelete: Scalars['ID']['input']; }>; -export type DeleteOneMetadataObjectMutation = { __typename?: 'Mutation', deleteOneObject: { __typename?: 'ObjectDeleteResponse', id?: string | null, dataSourceId?: string | null, nameSingular?: string | null, namePlural?: string | null, labelSingular?: string | null, labelPlural?: string | null, description?: string | null, icon?: string | null, isCustom?: boolean | null, isActive?: boolean | null, createdAt?: any | null, updatedAt?: any | null } }; +export type DeleteOneObjectMetadataItemMutation = { __typename?: 'Mutation', deleteOneObject: { __typename?: 'ObjectDeleteResponse', id?: string | null, dataSourceId?: string | null, nameSingular?: string | null, namePlural?: string | null, labelSingular?: string | null, labelPlural?: string | null, description?: string | null, icon?: string | null, isCustom?: boolean | null, isActive?: boolean | null, createdAt?: any | null, updatedAt?: any | null } }; export type DeleteOneMetadataFieldMutationVariables = Exact<{ idToDelete: Scalars['ID']['input']; @@ -850,16 +850,16 @@ export type DeleteOneMetadataFieldMutationVariables = Exact<{ export type DeleteOneMetadataFieldMutation = { __typename?: 'Mutation', deleteOneField: { __typename?: 'FieldDeleteResponse', id?: string | null, type?: string | null, name?: string | null, label?: string | null, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom?: boolean | null, isActive?: boolean | null, isNullable?: boolean | null, createdAt?: any | null, updatedAt?: any | null } }; -export type MetadataObjectsQueryVariables = Exact<{ [key: string]: never; }>; +export type ObjectMetadataItemsQueryVariables = Exact<{ [key: string]: never; }>; -export type MetadataObjectsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } }; +export type ObjectMetadataItemsQuery = { __typename?: 'Query', objects: { __typename?: 'ObjectConnection', totalCount: number, edges: Array<{ __typename?: 'objectEdge', node: { __typename?: 'object', id: string, dataSourceId: string, nameSingular: string, namePlural: string, labelSingular: string, labelPlural: string, description?: string | null, icon?: string | null, isCustom: boolean, isActive: boolean, createdAt: any, updatedAt: any, fields: { __typename?: 'ObjectFieldsConnection', totalCount: number, edges: Array<{ __typename?: 'fieldEdge', node: { __typename?: 'field', id: string, type: string, name: string, label: string, description?: string | null, icon?: string | null, placeholder?: string | null, isCustom: boolean, isActive: boolean, isNullable: boolean, createdAt: any, updatedAt: any } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } } }>, pageInfo: { __typename?: 'PageInfo', hasNextPage?: boolean | null, hasPreviousPage?: boolean | null, startCursor?: any | null, endCursor?: any | null } } }; -export const CreateOneMetadataObjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneMetadataObject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; +export const CreateOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneObjectMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; export const CreateOneMetadataFieldDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateOneMetadataField"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateOneFieldInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; export const UpdateOneMetadataFieldDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneMetadataField"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateFieldInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"update"},"value":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; -export const UpdateOneMetadataObjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneMetadataObject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"update"},"value":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; -export const DeleteOneMetadataObjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneMetadataObject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; +export const UpdateOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneObjectMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateObjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToUpdate"}}},{"kind":"ObjectField","name":{"kind":"Name","value":"update"},"value":{"kind":"Variable","name":{"kind":"Name","value":"updatePayload"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; +export const DeleteOneObjectMetadataItemDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneObjectMetadataItem"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneObject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; export const DeleteOneMetadataFieldDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteOneMetadataField"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteOneField"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"idToDelete"}}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode; -export const MetadataObjectsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MetadataObjects"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"fields"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const ObjectMetadataItemsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ObjectMetadataItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"objects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"dataSourceId"}},{"kind":"Field","name":{"kind":"Name","value":"nameSingular"}},{"kind":"Field","name":{"kind":"Name","value":"namePlural"}},{"kind":"Field","name":{"kind":"Name","value":"labelSingular"}},{"kind":"Field","name":{"kind":"Name","value":"labelPlural"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"fields"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"paging"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1000"}}]}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"placeholder"}},{"kind":"Field","name":{"kind":"Name","value":"isCustom"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"isNullable"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}},{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}},{"kind":"Field","name":{"kind":"Name","value":"totalCount"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/front/src/modules/metadata/components/MetadataObjectNavItems.tsx b/front/src/modules/metadata/components/MetadataObjectNavItems.tsx deleted file mode 100644 index 833c24dfc0..0000000000 --- a/front/src/modules/metadata/components/MetadataObjectNavItems.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useNavigate } from 'react-router-dom'; - -import { Icon123 } from '@/ui/input/constants/icons'; -import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons'; -import NavItem from '@/ui/navigation/navbar/components/NavItem'; - -import { useFindManyMetadataObjects } from '../hooks/useFindManyMetadataObjects'; - -export const MetadataObjectNavItems = () => { - const { metadataObjects } = useFindManyMetadataObjects(); - - const navigate = useNavigate(); - const { icons } = useLazyLoadIcons(); - - return ( - <> - {metadataObjects - .filter( - (metadataObject) => - metadataObject.isActive && - !metadataObject.namePlural.endsWith('V2'), - ) - .map((metadataObject) => { - return ( - { - navigate(`/objects/${metadataObject.namePlural}`); - }} - /> - ); - })} - - ); -}; diff --git a/front/src/modules/metadata/components/ObjectMetadataNavItems.tsx b/front/src/modules/metadata/components/ObjectMetadataNavItems.tsx new file mode 100644 index 0000000000..54c466c6b0 --- /dev/null +++ b/front/src/modules/metadata/components/ObjectMetadataNavItems.tsx @@ -0,0 +1,42 @@ +import { useNavigate } from 'react-router-dom'; + +import { Icon123 } from '@/ui/input/constants/icons'; +import { useLazyLoadIcons } from '@/ui/input/hooks/useLazyLoadIcons'; +import NavItem from '@/ui/navigation/navbar/components/NavItem'; + +import { useFindManyObjectMetadataItems } from '../hooks/useFindManyObjectMetadataItems'; + +export const ObjectMetadataNavItems = () => { + const { objectMetadataItems } = useFindManyObjectMetadataItems(); + + const navigate = useNavigate(); + const { icons } = useLazyLoadIcons(); + + return ( + <> + {objectMetadataItems + .filter( + (objectMetadataItem) => + objectMetadataItem.isActive && + !objectMetadataItem.namePlural.endsWith('V2'), + ) + .map((objectMetadataItem) => { + return ( + { + navigate(`/objects/${objectMetadataItem.namePlural}`); + }} + /> + ); + })} + + ); +}; diff --git a/front/src/modules/metadata/components/ObjectTableEffect.tsx b/front/src/modules/metadata/components/ObjectTableEffect.tsx index 3bdda9e61b..bda841aba3 100644 --- a/front/src/modules/metadata/components/ObjectTableEffect.tsx +++ b/front/src/modules/metadata/components/ObjectTableEffect.tsx @@ -5,7 +5,7 @@ import { availableTableColumnsScopedState } from '@/ui/object/record-table/state import { useView } from '@/views/hooks/useView'; import { ViewType } from '@/views/types/ViewType'; -import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext'; +import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext'; export const ObjectTableEffect = () => { const { @@ -20,20 +20,20 @@ export const ObjectTableEffect = () => { columnDefinitions, filterDefinitions, sortDefinitions, - foundMetadataObject, - } = useMetadataObjectInContext(); + foundObjectMetadataItem, + } = useObjectMetadataItemInContext(); - const tableScopeId = foundMetadataObject?.namePlural ?? ''; + const tableScopeId = foundObjectMetadataItem?.namePlural ?? ''; const setAvailableTableColumns = useSetRecoilState( availableTableColumnsScopedState(tableScopeId), ); useEffect(() => { - if (!foundMetadataObject) { + if (!foundObjectMetadataItem) { return; } - setViewObjectId?.(foundMetadataObject.id); + setViewObjectId?.(foundObjectMetadataItem.id); setViewType?.(ViewType.Table); setAvailableSortDefinitions?.(sortDefinitions); @@ -49,7 +49,7 @@ export const ObjectTableEffect = () => { setAvailableSortDefinitions, setAvailableFilterDefinitions, setAvailableFieldDefinitions, - foundMetadataObject, + foundObjectMetadataItem, sortDefinitions, filterDefinitions, ]); diff --git a/front/src/modules/metadata/components/RecordShowPage.tsx b/front/src/modules/metadata/components/RecordShowPage.tsx index e0cee7789a..a25074acba 100644 --- a/front/src/modules/metadata/components/RecordShowPage.tsx +++ b/front/src/modules/metadata/components/RecordShowPage.tsx @@ -23,8 +23,8 @@ import { InlineCellHotkeyScope } from '@/ui/object/record-inline-cell/types/Inli import { PageTitle } from '@/ui/utilities/page-title/PageTitle'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; -import { useFindOneMetadataObject } from '../hooks/useFindOneMetadataObject'; import { useFindOneObject } from '../hooks/useFindOneObject'; +import { useFindOneObjectMetadataItem } from '../hooks/useFindOneObjectMetadataItem'; import { useUpdateOneObject } from '../hooks/useUpdateOneObject'; import { formatMetadataFieldAsColumnDefinition } from '../utils/formatMetadataFieldAsColumnDefinition'; @@ -36,7 +36,7 @@ export const RecordShowPage = () => { const { icons } = useLazyLoadIcons(); - const { foundMetadataObject } = useFindOneMetadataObject({ + const { foundObjectMetadataItem } = useFindOneObjectMetadataItem({ objectNameSingular, }); @@ -115,7 +115,7 @@ export const RecordShowPage = () => { avatarType="squared" /> - {foundMetadataObject?.fields + {foundObjectMetadataItem?.fields .toSorted((a, b) => DateTime.fromISO(a.createdAt) .diff(DateTime.fromISO(b.createdAt)) @@ -132,7 +132,7 @@ export const RecordShowPage = () => { formatMetadataFieldAsColumnDefinition({ field: metadataField, position: index, - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, icons, }), useUpdateEntityMutation: useUpdateOneObjectMutation, diff --git a/front/src/modules/metadata/components/RecordTable.tsx b/front/src/modules/metadata/components/RecordTable.tsx index b37494baf9..f1ba424462 100644 --- a/front/src/modules/metadata/components/RecordTable.tsx +++ b/front/src/modules/metadata/components/RecordTable.tsx @@ -17,9 +17,9 @@ import { viewFieldsToColumnDefinitions } from '@/views/utils/viewFieldsToColumnD import { viewFiltersToFilters } from '@/views/utils/viewFiltersToFilters'; import { viewSortsToSorts } from '@/views/utils/viewSortsToSorts'; -import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext'; +import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext'; import { useUpdateOneObject } from '../hooks/useUpdateOneObject'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; import { ObjectTableEffect } from './ObjectTableEffect'; import { ObjectRecordTableEffect } from './RecordTableEffect'; @@ -32,7 +32,7 @@ const StyledContainer = styled.div` `; export type ObjectTableProps = Pick< - MetadataObjectIdentifier, + ObjectMetadataItemIdentifier, 'objectNamePlural' >; @@ -40,9 +40,9 @@ export const ObjectTable = ({ objectNamePlural }: ObjectTableProps) => { const { updateOneObject } = useUpdateOneObject({ objectNamePlural, }); - const { columnDefinitions, foundMetadataObject } = - useMetadataObjectInContext(); - const tableScopeId = foundMetadataObject?.namePlural ?? ''; + const { columnDefinitions, foundObjectMetadataItem } = + useObjectMetadataItemInContext(); + const tableScopeId = foundObjectMetadataItem?.namePlural ?? ''; const viewScopeId = objectNamePlural ?? ''; const { persistViewFields } = useViewFields(viewScopeId); diff --git a/front/src/modules/metadata/components/RecordTableEffect.tsx b/front/src/modules/metadata/components/RecordTableEffect.tsx index fda70cdce7..618740808c 100644 --- a/front/src/modules/metadata/components/RecordTableEffect.tsx +++ b/front/src/modules/metadata/components/RecordTableEffect.tsx @@ -9,11 +9,11 @@ import { tableSortsScopedState } from '@/ui/object/record-table/states/tableSort import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue'; import { useFindManyObjects } from '../hooks/useFindManyObjects'; -import { useMetadataObjectInContext } from '../hooks/useMetadataObjectInContext'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { useObjectMetadataItemInContext } from '../hooks/useObjectMetadataItemInContext'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; export type ObjectRecordTableEffectProps = Pick< - MetadataObjectIdentifier, + ObjectMetadataItemIdentifier, 'objectNamePlural' >; @@ -22,7 +22,7 @@ export const ObjectRecordTableEffect = ({ objectNamePlural, }: ObjectRecordTableEffectProps) => { const setRecordTableData = useSetRecordTableData(); - const { foundMetadataObject } = useMetadataObjectInContext(); + const { foundObjectMetadataItem } = useObjectMetadataItemInContext(); const tableFilters = useRecoilScopedValue( tableFiltersScopedState, @@ -38,11 +38,11 @@ export const ObjectRecordTableEffect = ({ objectNamePlural: objectNamePlural, filter: turnFiltersIntoWhereClauseV2( tableFilters, - foundMetadataObject?.fields ?? [], + foundObjectMetadataItem?.fields ?? [], ), orderBy: turnSortsIntoOrderByV2( tableSorts, - foundMetadataObject?.fields ?? [], + foundObjectMetadataItem?.fields ?? [], ), }); diff --git a/front/src/modules/metadata/components/RecordTablePage.tsx b/front/src/modules/metadata/components/RecordTablePage.tsx index 6590f75294..dacbac5612 100644 --- a/front/src/modules/metadata/components/RecordTablePage.tsx +++ b/front/src/modules/metadata/components/RecordTablePage.tsx @@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import styled from '@emotion/styled'; import { ObjectTable } from '@/metadata/components/RecordTable'; -import { MetadataObjectIdentifier } from '@/metadata/types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '@/metadata/types/ObjectMetadataItemIdentifier'; import { IconBuildingSkyscraper } from '@/ui/display/icon'; import { PageAddButton } from '@/ui/layout/page/PageAddButton'; import { PageBody } from '@/ui/layout/page/PageBody'; @@ -16,8 +16,8 @@ import { TableRecoilScopeContext } from '@/ui/object/record-table/states/recoil- import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; import { useCreateOneObject } from '../hooks/useCreateOneObject'; -import { useFindOneMetadataObject } from '../hooks/useFindOneMetadataObject'; -import { MetadataObjectScope } from '../scopes/MetadataObjectScope'; +import { useFindOneObjectMetadataItem } from '../hooks/useFindOneObjectMetadataItem'; +import { ObjectMetadataItemScope } from '../scopes/ObjectMetadataItemScope'; const StyledTableContainer = styled.div` display: flex; @@ -25,14 +25,14 @@ const StyledTableContainer = styled.div` `; export type RecordTablePageProps = Pick< - MetadataObjectIdentifier, + ObjectMetadataItemIdentifier, 'objectNamePlural' >; export const RecordTablePage = () => { const objectNamePlural = useParams().objectNamePlural ?? ''; - const { objectNotFoundInMetadata, loading } = useFindOneMetadataObject({ + const { objectNotFoundInMetadata, loading } = useFindOneObjectMetadataItem({ objectNamePlural, }); @@ -64,9 +64,11 @@ export const RecordTablePage = () => { CustomRecoilScopeContext={TableRecoilScopeContext} > - + - + diff --git a/front/src/modules/metadata/graphql/mutations.ts b/front/src/modules/metadata/graphql/mutations.ts index b40ef9115a..e4f818bc1c 100644 --- a/front/src/modules/metadata/graphql/mutations.ts +++ b/front/src/modules/metadata/graphql/mutations.ts @@ -1,7 +1,7 @@ import { gql } from '@apollo/client'; export const CREATE_ONE_METADATA_OBJECT = gql` - mutation CreateOneMetadataObject($input: CreateOneObjectInput!) { + mutation CreateOneObjectMetadataItem($input: CreateOneObjectInput!) { createOneObject(input: $input) { id dataSourceId @@ -61,7 +61,7 @@ export const UPDATE_ONE_METADATA_FIELD = gql` `; export const UPDATE_ONE_METADATA_OBJECT = gql` - mutation UpdateOneMetadataObject( + mutation UpdateOneObjectMetadataItem( $idToUpdate: ID! $updatePayload: UpdateObjectInput! ) { @@ -83,7 +83,7 @@ export const UPDATE_ONE_METADATA_OBJECT = gql` `; export const DELETE_ONE_METADATA_OBJECT = gql` - mutation DeleteOneMetadataObject($idToDelete: ID!) { + mutation DeleteOneObjectMetadataItem($idToDelete: ID!) { deleteOneObject(input: { id: $idToDelete }) { id dataSourceId diff --git a/front/src/modules/metadata/graphql/queries.ts b/front/src/modules/metadata/graphql/queries.ts index a032dce3df..204497d55a 100644 --- a/front/src/modules/metadata/graphql/queries.ts +++ b/front/src/modules/metadata/graphql/queries.ts @@ -1,7 +1,7 @@ import { gql } from '@apollo/client'; export const FIND_MANY_METADATA_OBJECTS = gql` - query MetadataObjects { + query ObjectMetadataItems { objects(paging: { first: 1000 }) { edges { node { diff --git a/front/src/modules/metadata/hooks/useCreateOneObject.ts b/front/src/modules/metadata/hooks/useCreateOneObject.ts index beb6eb413f..9eb0aba3fb 100644 --- a/front/src/modules/metadata/hooks/useCreateOneObject.ts +++ b/front/src/modules/metadata/hooks/useCreateOneObject.ts @@ -1,26 +1,26 @@ import { useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; export const useCreateOneObject = ({ objectNamePlural, -}: Pick) => { +}: Pick) => { const { - foundMetadataObject, + foundObjectMetadataItem, objectNotFoundInMetadata, findManyQuery, createOneMutation, - } = useFindOneMetadataObject({ + } = useFindOneObjectMetadataItem({ objectNamePlural, }); // TODO: type this with a minimal type at least with Record const [mutate] = useMutation(createOneMutation); - const createOneObject = foundMetadataObject + const createOneObject = foundObjectMetadataItem ? (input: Record) => { return mutate({ variables: { diff --git a/front/src/modules/metadata/hooks/useCreateOneMetadataObject.ts b/front/src/modules/metadata/hooks/useCreateOneObjectMetadataItem.ts similarity index 68% rename from front/src/modules/metadata/hooks/useCreateOneMetadataObject.ts rename to front/src/modules/metadata/hooks/useCreateOneObjectMetadataItem.ts index bd8a7ce18a..cca4aa6814 100644 --- a/front/src/modules/metadata/hooks/useCreateOneMetadataObject.ts +++ b/front/src/modules/metadata/hooks/useCreateOneObjectMetadataItem.ts @@ -2,8 +2,8 @@ import { ApolloClient, useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; import { - CreateOneMetadataObjectMutation, - CreateOneMetadataObjectMutationVariables, + CreateOneObjectMetadataItemMutation, + CreateOneObjectMetadataItemMutationVariables, } from '~/generated-metadata/graphql'; import { CREATE_ONE_METADATA_OBJECT } from '../graphql/mutations'; @@ -11,18 +11,18 @@ import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries'; import { useApolloMetadataClient } from './useApolloMetadataClient'; -export const useCreateOneMetadataObject = () => { +export const useCreateOneObjectMetadataItem = () => { const apolloMetadataClient = useApolloMetadataClient(); const [mutate] = useMutation< - CreateOneMetadataObjectMutation, - CreateOneMetadataObjectMutationVariables + CreateOneObjectMetadataItemMutation, + CreateOneObjectMetadataItemMutationVariables >(CREATE_ONE_METADATA_OBJECT, { client: apolloMetadataClient ?? ({} as ApolloClient), }); - const createOneMetadataObject = async ( - input: CreateOneMetadataObjectMutationVariables['input']['object'], + const createOneObjectMetadataItem = async ( + input: CreateOneObjectMetadataItemMutationVariables['input']['object'], ) => { return await mutate({ variables: { @@ -38,6 +38,6 @@ export const useCreateOneMetadataObject = () => { }; return { - createOneMetadataObject, + createOneObjectMetadataItem, }; }; diff --git a/front/src/modules/metadata/hooks/useDeleteOneObject.ts b/front/src/modules/metadata/hooks/useDeleteOneObject.ts index 84c6292e9f..6f31540c64 100644 --- a/front/src/modules/metadata/hooks/useDeleteOneObject.ts +++ b/front/src/modules/metadata/hooks/useDeleteOneObject.ts @@ -1,26 +1,26 @@ import { useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; export const useDeleteOneObject = ({ objectNamePlural, -}: Pick) => { +}: Pick) => { const { - foundMetadataObject, + foundObjectMetadataItem, objectNotFoundInMetadata, findManyQuery, deleteOneMutation, - } = useFindOneMetadataObject({ + } = useFindOneObjectMetadataItem({ objectNamePlural, }); // TODO: type this with a minimal type at least with Record const [mutate] = useMutation(deleteOneMutation); - const deleteOneObject = foundMetadataObject + const deleteOneObject = foundObjectMetadataItem ? (input: Record) => { return mutate({ variables: { diff --git a/front/src/modules/metadata/hooks/useDeleteOneMetadataObject.ts b/front/src/modules/metadata/hooks/useDeleteOneObjectMetadataItem.ts similarity index 67% rename from front/src/modules/metadata/hooks/useDeleteOneMetadataObject.ts rename to front/src/modules/metadata/hooks/useDeleteOneObjectMetadataItem.ts index e8603ba0ef..e8b4e22030 100644 --- a/front/src/modules/metadata/hooks/useDeleteOneMetadataObject.ts +++ b/front/src/modules/metadata/hooks/useDeleteOneObjectMetadataItem.ts @@ -2,8 +2,8 @@ import { ApolloClient, useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; import { - DeleteOneMetadataObjectMutation, - DeleteOneMetadataObjectMutationVariables, + DeleteOneObjectMetadataItemMutation, + DeleteOneObjectMetadataItemMutationVariables, } from '~/generated-metadata/graphql'; import { DELETE_ONE_METADATA_OBJECT } from '../graphql/mutations'; @@ -11,18 +11,18 @@ import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries'; import { useApolloMetadataClient } from './useApolloMetadataClient'; -export const useDeleteOneMetadataObject = () => { +export const useDeleteOneObjectMetadataItem = () => { const apolloMetadataClient = useApolloMetadataClient(); const [mutate] = useMutation< - DeleteOneMetadataObjectMutation, - DeleteOneMetadataObjectMutationVariables + DeleteOneObjectMetadataItemMutation, + DeleteOneObjectMetadataItemMutationVariables >(DELETE_ONE_METADATA_OBJECT, { client: apolloMetadataClient ?? ({} as ApolloClient), }); - const deleteOneMetadataObject = async ( - idToDelete: DeleteOneMetadataObjectMutationVariables['idToDelete'], + const deleteOneObjectMetadataItem = async ( + idToDelete: DeleteOneObjectMetadataItemMutationVariables['idToDelete'], ) => { return await mutate({ variables: { @@ -34,6 +34,6 @@ export const useDeleteOneMetadataObject = () => { }; return { - deleteOneMetadataObject, + deleteOneObjectMetadataItem, }; }; diff --git a/front/src/modules/metadata/hooks/useFindAllMetadata.ts b/front/src/modules/metadata/hooks/useFindAllMetadata.ts index 809df24f46..fd49d58bfe 100644 --- a/front/src/modules/metadata/hooks/useFindAllMetadata.ts +++ b/front/src/modules/metadata/hooks/useFindAllMetadata.ts @@ -2,12 +2,12 @@ import { useMemo } from 'react'; import { useQuery } from '@apollo/client'; import { - MetadataObjectsQuery, - MetadataObjectsQueryVariables, + ObjectMetadataItemsQuery, + ObjectMetadataItemsQueryVariables, } from '~/generated-metadata/graphql'; import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries'; -import { formatPagedMetadataObjectsToMetadataObjects } from '../utils/formatPagedMetadataObjectsToMetadataObjects'; +import { formatPagedObjectMetadataItemsToObjectMetadataItems } from '../utils/formatPagedObjectMetadataItemsToObjectMetadataItems'; import { useApolloMetadataClient } from './useApolloMetadataClient'; @@ -16,8 +16,8 @@ export const useFindAllMetadata = () => { const apolloMetadataClient = useApolloMetadataClient(); const { data, fetchMore: fetchMoreInternal } = useQuery< - MetadataObjectsQuery, - MetadataObjectsQueryVariables + ObjectMetadataItemsQuery, + ObjectMetadataItemsQueryVariables >(FIND_MANY_METADATA_OBJECTS, { client: apolloMetadataClient ?? ({} as any), skip: !apolloMetadataClient, @@ -32,14 +32,14 @@ export const useFindAllMetadata = () => { }, }); - const metadataObjects = useMemo(() => { - return formatPagedMetadataObjectsToMetadataObjects({ - pagedMetadataObjects: data, + const objectMetadataItems = useMemo(() => { + return formatPagedObjectMetadataItemsToObjectMetadataItems({ + pagedObjectMetadataItems: data, }); }, [data]); return { - metadataObjects, + objectMetadataItems, hasMore, fetchMore, }; diff --git a/front/src/modules/metadata/hooks/useFindManyMetadataObjects.ts b/front/src/modules/metadata/hooks/useFindManyObjectMetadataItems.ts similarity index 64% rename from front/src/modules/metadata/hooks/useFindManyMetadataObjects.ts rename to front/src/modules/metadata/hooks/useFindManyObjectMetadataItems.ts index 1e3ae0f5a0..a6dd39bea8 100644 --- a/front/src/modules/metadata/hooks/useFindManyMetadataObjects.ts +++ b/front/src/modules/metadata/hooks/useFindManyObjectMetadataItems.ts @@ -3,18 +3,18 @@ import { useQuery } from '@apollo/client'; import { useSnackBar } from '@/ui/feedback/snack-bar/hooks/useSnackBar'; import { - MetadataObjectsQuery, - MetadataObjectsQueryVariables, + ObjectMetadataItemsQuery, + ObjectMetadataItemsQueryVariables, } from '~/generated-metadata/graphql'; import { logError } from '~/utils/logError'; import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries'; -import { formatPagedMetadataObjectsToMetadataObjects } from '../utils/formatPagedMetadataObjectsToMetadataObjects'; +import { formatPagedObjectMetadataItemsToObjectMetadataItems } from '../utils/formatPagedObjectMetadataItemsToObjectMetadataItems'; import { useApolloMetadataClient } from './useApolloMetadataClient'; // TODO: test fetchMore -export const useFindManyMetadataObjects = () => { +export const useFindManyObjectMetadataItems = () => { const apolloMetadataClient = useApolloMetadataClient(); const { enqueueSnackBar } = useSnackBar(); @@ -24,15 +24,15 @@ export const useFindManyMetadataObjects = () => { fetchMore: fetchMoreInternal, loading, error, - } = useQuery( + } = useQuery( FIND_MANY_METADATA_OBJECTS, { client: apolloMetadataClient ?? undefined, skip: !apolloMetadataClient, onError: (error) => { - logError('useFindManyMetadataObjects error : ' + error); + logError('useFindManyObjectMetadataItems error : ' + error); enqueueSnackBar( - `Error during useFindManyMetadataObjects, ${error.message}`, + `Error during useFindManyObjectMetadataItems, ${error.message}`, { variant: 'error', }, @@ -51,14 +51,14 @@ export const useFindManyMetadataObjects = () => { }, }); - const metadataObjects = useMemo(() => { - return formatPagedMetadataObjectsToMetadataObjects({ - pagedMetadataObjects: data, + const objectMetadataItems = useMemo(() => { + return formatPagedObjectMetadataItemsToObjectMetadataItems({ + pagedObjectMetadataItems: data, }); }, [data]); return { - metadataObjects, + objectMetadataItems, hasMore, fetchMore, loading, diff --git a/front/src/modules/metadata/hooks/useFindManyObjects.ts b/front/src/modules/metadata/hooks/useFindManyObjects.ts index 7e0947d365..97118186d9 100644 --- a/front/src/modules/metadata/hooks/useFindManyObjects.ts +++ b/front/src/modules/metadata/hooks/useFindManyObjects.ts @@ -4,11 +4,11 @@ import { useQuery } from '@apollo/client'; import { useSnackBar } from '@/ui/feedback/snack-bar/hooks/useSnackBar'; import { logError } from '~/utils/logError'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; import { PaginatedObjectType } from '../types/PaginatedObjectType'; import { formatPagedObjectsToObjects } from '../utils/formatPagedObjectsToObjects'; -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; // TODO: test with a wrong name // TODO: add zod to validate that we have at least id on each object @@ -19,13 +19,13 @@ export const useFindManyObjects = < filter, orderBy, onCompleted, -}: Pick & { +}: Pick & { filter?: any; orderBy?: any; onCompleted?: (data: any) => void; }) => { - const { foundMetadataObject, objectNotFoundInMetadata, findManyQuery } = - useFindOneMetadataObject({ + const { foundObjectMetadataItem, objectNotFoundInMetadata, findManyQuery } = + useFindOneObjectMetadataItem({ objectNamePlural, }); @@ -34,7 +34,7 @@ export const useFindManyObjects = < const { data, loading, error } = useQuery>( findManyQuery, { - skip: !foundMetadataObject, + skip: !foundObjectMetadataItem, variables: { filter: filter ?? {}, orderBy: orderBy ?? {}, diff --git a/front/src/modules/metadata/hooks/useFindOneObject.ts b/front/src/modules/metadata/hooks/useFindOneObject.ts index 0d45713a72..6bf4baf420 100644 --- a/front/src/modules/metadata/hooks/useFindOneObject.ts +++ b/front/src/modules/metadata/hooks/useFindOneObject.ts @@ -1,8 +1,8 @@ import { useQuery } from '@apollo/client'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; export const useFindOneObject = < ObjectType extends { id: string } & Record, @@ -10,12 +10,12 @@ export const useFindOneObject = < objectNameSingular, objectId, onCompleted, -}: Pick & { +}: Pick & { objectId: string | undefined; onCompleted?: (data: ObjectType) => void; }) => { - const { foundMetadataObject, objectNotFoundInMetadata, findOneQuery } = - useFindOneMetadataObject({ + const { foundObjectMetadataItem, objectNotFoundInMetadata, findOneQuery } = + useFindOneObjectMetadataItem({ objectNameSingular, }); @@ -23,7 +23,7 @@ export const useFindOneObject = < { [nameSingular: string]: ObjectType }, { objectId: string } >(findOneQuery, { - skip: !foundMetadataObject || !objectId, + skip: !foundObjectMetadataItem || !objectId, variables: { objectId: objectId ?? '', }, diff --git a/front/src/modules/metadata/hooks/useFindOneMetadataObject.ts b/front/src/modules/metadata/hooks/useFindOneObjectMetadataItem.ts similarity index 69% rename from front/src/modules/metadata/hooks/useFindOneMetadataObject.ts rename to front/src/modules/metadata/hooks/useFindOneObjectMetadataItem.ts index 3be29866ea..961bc384bd 100644 --- a/front/src/modules/metadata/hooks/useFindOneMetadataObject.ts +++ b/front/src/modules/metadata/hooks/useFindOneObjectMetadataItem.ts @@ -6,7 +6,7 @@ import { FilterDefinition } from '@/ui/object/object-filter-dropdown/types/Filte import { SortDefinition } from '@/ui/object/object-sort-dropdown/types/SortDefinition'; import { ColumnDefinition } from '@/ui/object/record-table/types/ColumnDefinition'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; import { formatMetadataFieldAsColumnDefinition } from '../utils/formatMetadataFieldAsColumnDefinition'; import { formatMetadataFieldAsFilterDefinition } from '../utils/formatMetadataFieldAsFilterDefinition'; import { formatMetadataFieldAsSortDefinition } from '../utils/formatMetadataFieldAsSortDefinition'; @@ -16,15 +16,15 @@ import { generateFindManyCustomObjectsQuery } from '../utils/generateFindManyCus import { generateFindOneCustomObjectQuery } from '../utils/generateFindOneCustomObjectQuery'; import { generateUpdateOneObjectMutation } from '../utils/generateUpdateOneObjectMutation'; -import { useFindManyMetadataObjects } from './useFindManyMetadataObjects'; +import { useFindManyObjectMetadataItems } from './useFindManyObjectMetadataItems'; -export const useFindOneMetadataObject = ({ +export const useFindOneObjectMetadataItem = ({ objectNamePlural, objectNameSingular, -}: MetadataObjectIdentifier) => { - const { metadataObjects, loading } = useFindManyMetadataObjects(); +}: ObjectMetadataItemIdentifier) => { + const { objectMetadataItems, loading } = useFindManyObjectMetadataItems(); - const foundMetadataObject = metadataObjects.find( + const foundObjectMetadataItem = objectMetadataItems.find( (object) => object.namePlural === objectNamePlural || object.nameSingular === objectNameSingular, @@ -33,21 +33,21 @@ export const useFindOneMetadataObject = ({ const { icons } = useLazyLoadIcons(); const objectNotFoundInMetadata = - metadataObjects.length === 0 || - (metadataObjects.length > 0 && !foundMetadataObject); + objectMetadataItems.length === 0 || + (objectMetadataItems.length > 0 && !foundObjectMetadataItem); const columnDefinitions: ColumnDefinition[] = - foundMetadataObject?.fields.map((field, index) => + foundObjectMetadataItem?.fields.map((field, index) => formatMetadataFieldAsColumnDefinition({ position: index, field, - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, icons, }), ) ?? []; const filterDefinitions: FilterDefinition[] = - foundMetadataObject?.fields.map((field) => + foundObjectMetadataItem?.fields.map((field) => formatMetadataFieldAsFilterDefinition({ field, icons, @@ -55,16 +55,16 @@ export const useFindOneMetadataObject = ({ ) ?? []; const sortDefinitions: SortDefinition[] = - foundMetadataObject?.fields.map((field) => + foundObjectMetadataItem?.fields.map((field) => formatMetadataFieldAsSortDefinition({ field, icons, }), ) ?? []; - const findManyQuery = foundMetadataObject + const findManyQuery = foundObjectMetadataItem ? generateFindManyCustomObjectsQuery({ - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, }) : gql` query EmptyQuery { @@ -72,9 +72,9 @@ export const useFindOneMetadataObject = ({ } `; - const findOneQuery = foundMetadataObject + const findOneQuery = foundObjectMetadataItem ? generateFindOneCustomObjectQuery({ - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, }) : gql` query EmptyQuery { @@ -82,9 +82,9 @@ export const useFindOneMetadataObject = ({ } `; - const createOneMutation = foundMetadataObject + const createOneMutation = foundObjectMetadataItem ? generateCreateOneObjectMutation({ - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, }) : gql` mutation EmptyMutation { @@ -92,9 +92,9 @@ export const useFindOneMetadataObject = ({ } `; - const updateOneMutation = foundMetadataObject + const updateOneMutation = foundObjectMetadataItem ? generateUpdateOneObjectMutation({ - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, }) : gql` mutation EmptyMutation { @@ -103,9 +103,9 @@ export const useFindOneMetadataObject = ({ `; // TODO: implement backend delete - const deleteOneMutation = foundMetadataObject + const deleteOneMutation = foundObjectMetadataItem ? generateDeleteOneObjectMutation({ - metadataObject: foundMetadataObject, + objectMetadataItem: foundObjectMetadataItem, }) : gql` mutation EmptyMutation { @@ -114,7 +114,7 @@ export const useFindOneMetadataObject = ({ `; return { - foundMetadataObject, + foundObjectMetadataItem, objectNotFoundInMetadata, columnDefinitions, filterDefinitions, diff --git a/front/src/modules/metadata/hooks/useMetadataObject.ts b/front/src/modules/metadata/hooks/useMetadataObject.ts deleted file mode 100644 index 75412dae6e..0000000000 --- a/front/src/modules/metadata/hooks/useMetadataObject.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; - -import { MetadataObjectScopeInternalContext } from '../scopes/scope-internal-context/MetadataObjectScopeInternalContext'; - -type UseMetadataObjectProps = { - metadataObjectNamePlural?: string; -}; - -export const useMetadataObject = (props?: UseMetadataObjectProps) => { - const scopeId = useAvailableScopeIdOrThrow( - MetadataObjectScopeInternalContext, - props?.metadataObjectNamePlural, - ); - - return { - scopeId, - }; -}; diff --git a/front/src/modules/metadata/hooks/useMetadataObjectForSettings.ts b/front/src/modules/metadata/hooks/useMetadataObjectForSettings.ts deleted file mode 100644 index 218b8b2ac3..0000000000 --- a/front/src/modules/metadata/hooks/useMetadataObjectForSettings.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { MetadataObject } from '../types/MetadataObject'; -import { formatMetadataObjectInput } from '../utils/formatMetadataObjectInput'; -import { getObjectSlug } from '../utils/getObjectSlug'; - -import { useCreateOneMetadataObject } from './useCreateOneMetadataObject'; -import { useDeleteOneMetadataObject } from './useDeleteOneMetadataObject'; -import { useFindManyMetadataObjects } from './useFindManyMetadataObjects'; -import { useUpdateOneMetadataObject } from './useUpdateOneMetadataObject'; - -export const useMetadataObjectForSettings = () => { - const { metadataObjects, loading } = useFindManyMetadataObjects(); - - const activeMetadataObjects = metadataObjects.filter( - ({ isActive }) => isActive, - ); - const disabledMetadataObjects = metadataObjects.filter( - ({ isActive }) => !isActive, - ); - - const findActiveMetadataObjectBySlug = (slug: string) => - activeMetadataObjects.find( - (activeMetadataObject) => getObjectSlug(activeMetadataObject) === slug, - ); - - const { createOneMetadataObject } = useCreateOneMetadataObject(); - const { updateOneMetadataObject } = useUpdateOneMetadataObject(); - const { deleteOneMetadataObject } = useDeleteOneMetadataObject(); - - const createMetadataObject = ( - input: Pick< - MetadataObject, - 'labelPlural' | 'labelSingular' | 'icon' | 'description' - >, - ) => createOneMetadataObject(formatMetadataObjectInput(input)); - - const editMetadataObject = ( - input: Pick< - MetadataObject, - 'id' | 'labelPlural' | 'labelSingular' | 'icon' | 'description' - >, - ) => - updateOneMetadataObject({ - idToUpdate: input.id, - updatePayload: formatMetadataObjectInput(input), - }); - - const activateMetadataObject = (metadataObject: Pick) => - updateOneMetadataObject({ - idToUpdate: metadataObject.id, - updatePayload: { isActive: true }, - }); - - const disableMetadataObject = (metadataObject: Pick) => - updateOneMetadataObject({ - idToUpdate: metadataObject.id, - updatePayload: { isActive: false }, - }); - - const eraseMetadataObject = (metadataObject: Pick) => - deleteOneMetadataObject(metadataObject.id); - - return { - activateMetadataObject, - activeMetadataObjects, - createMetadataObject, - disabledMetadataObjects, - disableMetadataObject, - editMetadataObject, - eraseMetadataObject, - findActiveMetadataObjectBySlug, - loading, - }; -}; diff --git a/front/src/modules/metadata/hooks/useMetadataObjectInContext.ts b/front/src/modules/metadata/hooks/useMetadataObjectInContext.ts deleted file mode 100644 index 2456aa62af..0000000000 --- a/front/src/modules/metadata/hooks/useMetadataObjectInContext.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { useContext } from 'react'; - -import { MetadataObjectScopeInternalContext } from '../scopes/scope-internal-context/MetadataObjectScopeInternalContext'; - -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; - -export const useMetadataObjectInContext = () => { - const context = useContext(MetadataObjectScopeInternalContext); - - if (!context) { - throw new Error( - 'Could not find MetadataObjectScopeInternalContext while in useMetadataObjectInContext', - ); - } - - const { - foundMetadataObject, - loading, - columnDefinitions, - filterDefinitions, - sortDefinitions, - } = useFindOneMetadataObject({ - objectNamePlural: context.objectNamePlural, - }); - - return { - ...context, - foundMetadataObject, - loading, - columnDefinitions, - filterDefinitions, - sortDefinitions, - }; -}; diff --git a/front/src/modules/metadata/hooks/useObjectMetadataItem.ts b/front/src/modules/metadata/hooks/useObjectMetadataItem.ts new file mode 100644 index 0000000000..58da43f3bc --- /dev/null +++ b/front/src/modules/metadata/hooks/useObjectMetadataItem.ts @@ -0,0 +1,18 @@ +import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; + +import { ObjectMetadataItemScopeInternalContext } from '../scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext'; + +type UseObjectMetadataItemProps = { + objectMetadataItemNamePlural?: string; +}; + +export const useObjectMetadataItem = (props?: UseObjectMetadataItemProps) => { + const scopeId = useAvailableScopeIdOrThrow( + ObjectMetadataItemScopeInternalContext, + props?.objectMetadataItemNamePlural, + ); + + return { + scopeId, + }; +}; diff --git a/front/src/modules/metadata/hooks/useObjectMetadataItemForSettings.ts b/front/src/modules/metadata/hooks/useObjectMetadataItemForSettings.ts new file mode 100644 index 0000000000..a3b87e2d77 --- /dev/null +++ b/front/src/modules/metadata/hooks/useObjectMetadataItemForSettings.ts @@ -0,0 +1,79 @@ +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; +import { formatObjectMetadataItemInput } from '../utils/formatObjectMetadataItemInput'; +import { getObjectSlug } from '../utils/getObjectSlug'; + +import { useCreateOneObjectMetadataItem } from './useCreateOneObjectMetadataItem'; +import { useDeleteOneObjectMetadataItem } from './useDeleteOneObjectMetadataItem'; +import { useFindManyObjectMetadataItems } from './useFindManyObjectMetadataItems'; +import { useUpdateOneObjectMetadataItem } from './useUpdateOneObjectMetadataItem'; + +export const useObjectMetadataItemForSettings = () => { + const { objectMetadataItems, loading } = useFindManyObjectMetadataItems(); + + const activeObjectMetadataItems = objectMetadataItems.filter( + ({ isActive }) => isActive, + ); + const disabledObjectMetadataItems = objectMetadataItems.filter( + ({ isActive }) => !isActive, + ); + + const findActiveObjectMetadataItemBySlug = (slug: string) => + activeObjectMetadataItems.find( + (activeObjectMetadataItem) => + getObjectSlug(activeObjectMetadataItem) === slug, + ); + + const { createOneObjectMetadataItem } = useCreateOneObjectMetadataItem(); + const { updateOneObjectMetadataItem } = useUpdateOneObjectMetadataItem(); + const { deleteOneObjectMetadataItem } = useDeleteOneObjectMetadataItem(); + + const createObjectMetadataItem = ( + input: Pick< + ObjectMetadataItem, + 'labelPlural' | 'labelSingular' | 'icon' | 'description' + >, + ) => createOneObjectMetadataItem(formatObjectMetadataItemInput(input)); + + const editObjectMetadataItem = ( + input: Pick< + ObjectMetadataItem, + 'id' | 'labelPlural' | 'labelSingular' | 'icon' | 'description' + >, + ) => + updateOneObjectMetadataItem({ + idToUpdate: input.id, + updatePayload: formatObjectMetadataItemInput(input), + }); + + const activateObjectMetadataItem = ( + objectMetadataItem: Pick, + ) => + updateOneObjectMetadataItem({ + idToUpdate: objectMetadataItem.id, + updatePayload: { isActive: true }, + }); + + const disableObjectMetadataItem = ( + objectMetadataItem: Pick, + ) => + updateOneObjectMetadataItem({ + idToUpdate: objectMetadataItem.id, + updatePayload: { isActive: false }, + }); + + const eraseObjectMetadataItem = ( + objectMetadataItem: Pick, + ) => deleteOneObjectMetadataItem(objectMetadataItem.id); + + return { + activateObjectMetadataItem, + activeObjectMetadataItems, + createObjectMetadataItem, + disabledObjectMetadataItems, + disableObjectMetadataItem, + editObjectMetadataItem, + eraseObjectMetadataItem, + findActiveObjectMetadataItemBySlug, + loading, + }; +}; diff --git a/front/src/modules/metadata/hooks/useObjectMetadataItemInContext.ts b/front/src/modules/metadata/hooks/useObjectMetadataItemInContext.ts new file mode 100644 index 0000000000..f3e1f4df38 --- /dev/null +++ b/front/src/modules/metadata/hooks/useObjectMetadataItemInContext.ts @@ -0,0 +1,34 @@ +import { useContext } from 'react'; + +import { ObjectMetadataItemScopeInternalContext } from '../scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext'; + +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; + +export const useObjectMetadataItemInContext = () => { + const context = useContext(ObjectMetadataItemScopeInternalContext); + + if (!context) { + throw new Error( + 'Could not find ObjectMetadataItemScopeInternalContext while in useObjectMetadataItemInContext', + ); + } + + const { + foundObjectMetadataItem, + loading, + columnDefinitions, + filterDefinitions, + sortDefinitions, + } = useFindOneObjectMetadataItem({ + objectNamePlural: context.objectNamePlural, + }); + + return { + ...context, + foundObjectMetadataItem, + loading, + columnDefinitions, + filterDefinitions, + sortDefinitions, + }; +}; diff --git a/front/src/modules/metadata/hooks/useSeedCustomObjectsTemp.ts b/front/src/modules/metadata/hooks/useSeedCustomObjectsTemp.ts index e2fd0f28ae..916626ebff 100644 --- a/front/src/modules/metadata/hooks/useSeedCustomObjectsTemp.ts +++ b/front/src/modules/metadata/hooks/useSeedCustomObjectsTemp.ts @@ -1,15 +1,15 @@ import { isNonEmptyArray } from '~/utils/isNonEmptyArray'; import { useCreateOneMetadataField } from './useCreateOneMetadataField'; -import { useCreateOneMetadataObject } from './useCreateOneMetadataObject'; +import { useCreateOneObjectMetadataItem } from './useCreateOneObjectMetadataItem'; export const useSeedCustomObjectsTemp = () => { - const { createOneMetadataObject } = useCreateOneMetadataObject(); + const { createOneObjectMetadataItem } = useCreateOneObjectMetadataItem(); const { createOneMetadataField } = useCreateOneMetadataField(); return async () => { - const { data: createdMetadataObject, errors } = - await createOneMetadataObject({ + const { data: createdObjectMetadataItem, errors } = + await createOneObjectMetadataItem({ labelPlural: 'Suppliers', labelSingular: 'Supplier', nameSingular: 'supplier', @@ -19,7 +19,8 @@ export const useSeedCustomObjectsTemp = () => { }); if (!isNonEmptyArray(errors)) { - const supplierObjectId = createdMetadataObject?.createOneObject?.id ?? ''; + const supplierObjectId = + createdObjectMetadataItem?.createOneObject?.id ?? ''; await createOneMetadataField({ objectId: supplierObjectId, diff --git a/front/src/modules/metadata/hooks/useUpdateOneObject.ts b/front/src/modules/metadata/hooks/useUpdateOneObject.ts index 22f74e295d..fab452d7fe 100644 --- a/front/src/modules/metadata/hooks/useUpdateOneObject.ts +++ b/front/src/modules/metadata/hooks/useUpdateOneObject.ts @@ -1,20 +1,20 @@ import { useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; -import { MetadataObjectIdentifier } from '../types/MetadataObjectIdentifier'; +import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentifier'; -import { useFindOneMetadataObject } from './useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from './useFindOneObjectMetadataItem'; export const useUpdateOneObject = ({ objectNamePlural, objectNameSingular, -}: MetadataObjectIdentifier) => { +}: ObjectMetadataItemIdentifier) => { const { - foundMetadataObject, + foundObjectMetadataItem, objectNotFoundInMetadata, findManyQuery, updateOneMutation, - } = useFindOneMetadataObject({ + } = useFindOneObjectMetadataItem({ objectNamePlural, objectNameSingular, }); @@ -24,7 +24,7 @@ export const useUpdateOneObject = ({ refetchQueries: [getOperationName(findManyQuery) ?? ''], }); - const updateOneObject = foundMetadataObject + const updateOneObject = foundObjectMetadataItem ? ({ idToUpdate, input, diff --git a/front/src/modules/metadata/hooks/useUpdateOneMetadataObject.ts b/front/src/modules/metadata/hooks/useUpdateOneObjectMetadataItem.ts similarity index 71% rename from front/src/modules/metadata/hooks/useUpdateOneMetadataObject.ts rename to front/src/modules/metadata/hooks/useUpdateOneObjectMetadataItem.ts index bb22516358..ac8f1f7204 100644 --- a/front/src/modules/metadata/hooks/useUpdateOneMetadataObject.ts +++ b/front/src/modules/metadata/hooks/useUpdateOneObjectMetadataItem.ts @@ -2,8 +2,8 @@ import { useMutation } from '@apollo/client'; import { getOperationName } from '@apollo/client/utilities'; import { - UpdateOneMetadataObjectMutation, - UpdateOneMetadataObjectMutationVariables, + UpdateOneObjectMetadataItemMutation, + UpdateOneObjectMetadataItemMutationVariables, } from '~/generated-metadata/graphql'; import { UPDATE_ONE_METADATA_OBJECT } from '../graphql/mutations'; @@ -12,23 +12,23 @@ import { FIND_MANY_METADATA_OBJECTS } from '../graphql/queries'; import { useApolloMetadataClient } from './useApolloMetadataClient'; // TODO: Slice the Apollo store synchronously in the update function instead of subscribing, so we can use update after read in the same function call -export const useUpdateOneMetadataObject = () => { +export const useUpdateOneObjectMetadataItem = () => { const apolloClientMetadata = useApolloMetadataClient(); const [mutate] = useMutation< - UpdateOneMetadataObjectMutation, - UpdateOneMetadataObjectMutationVariables + UpdateOneObjectMetadataItemMutation, + UpdateOneObjectMetadataItemMutationVariables >(UPDATE_ONE_METADATA_OBJECT, { client: apolloClientMetadata ?? undefined, }); - const updateOneMetadataObject = async ({ + const updateOneObjectMetadataItem = async ({ idToUpdate, updatePayload, }: { - idToUpdate: UpdateOneMetadataObjectMutationVariables['idToUpdate']; + idToUpdate: UpdateOneObjectMetadataItemMutationVariables['idToUpdate']; updatePayload: Pick< - UpdateOneMetadataObjectMutationVariables['updatePayload'], + UpdateOneObjectMetadataItemMutationVariables['updatePayload'], | 'description' | 'icon' | 'isActive' @@ -49,6 +49,6 @@ export const useUpdateOneMetadataObject = () => { }; return { - updateOneMetadataObject, + updateOneObjectMetadataItem, }; }; diff --git a/front/src/modules/metadata/scopes/MetadataObjectScope.tsx b/front/src/modules/metadata/scopes/MetadataObjectScope.tsx deleted file mode 100644 index 428179355b..0000000000 --- a/front/src/modules/metadata/scopes/MetadataObjectScope.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { ReactNode } from 'react'; - -import { MetadataObjectScopeInternalContext } from './scope-internal-context/MetadataObjectScopeInternalContext'; - -type MetadataObjectScopeProps = { - children: ReactNode; - metadataObjectNamePlural: string; -}; - -export const MetadataObjectScope = ({ - children, - metadataObjectNamePlural, -}: MetadataObjectScopeProps) => { - return ( - - {children} - - ); -}; diff --git a/front/src/modules/metadata/scopes/ObjectMetadataItemScope.tsx b/front/src/modules/metadata/scopes/ObjectMetadataItemScope.tsx new file mode 100644 index 0000000000..4ef34d4ac0 --- /dev/null +++ b/front/src/modules/metadata/scopes/ObjectMetadataItemScope.tsx @@ -0,0 +1,24 @@ +import { ReactNode } from 'react'; + +import { ObjectMetadataItemScopeInternalContext } from './scope-internal-context/ObjectMetadataItemScopeInternalContext'; + +type ObjectMetadataItemScopeProps = { + children: ReactNode; + objectMetadataItemNamePlural: string; +}; + +export const ObjectMetadataItemScope = ({ + children, + objectMetadataItemNamePlural, +}: ObjectMetadataItemScopeProps) => { + return ( + + {children} + + ); +}; diff --git a/front/src/modules/metadata/scopes/scope-internal-context/MetadataObjectScopeInternalContext.ts b/front/src/modules/metadata/scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext.ts similarity index 55% rename from front/src/modules/metadata/scopes/scope-internal-context/MetadataObjectScopeInternalContext.ts rename to front/src/modules/metadata/scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext.ts index c36a76cd28..fb062f3bf4 100644 --- a/front/src/modules/metadata/scopes/scope-internal-context/MetadataObjectScopeInternalContext.ts +++ b/front/src/modules/metadata/scopes/scope-internal-context/ObjectMetadataItemScopeInternalContext.ts @@ -1,9 +1,9 @@ import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type MetadataObjectScopeInternalContextProps = ScopedStateKey & { +type ObjectMetadataItemScopeInternalContextProps = ScopedStateKey & { objectNamePlural: string; }; -export const MetadataObjectScopeInternalContext = - createScopeInternalContext(); +export const ObjectMetadataItemScopeInternalContext = + createScopeInternalContext(); diff --git a/front/src/modules/metadata/states/metadataObjectsState.ts b/front/src/modules/metadata/states/metadataObjectsState.ts deleted file mode 100644 index 122425b1c3..0000000000 --- a/front/src/modules/metadata/states/metadataObjectsState.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { atom } from 'recoil'; - -import { MetadataObject } from '../types/MetadataObject'; - -/** - * @deprecated Use `useFindManyMetadataObjects` instead. - */ -export const metadataObjectsState = atom({ - key: 'metadataObjectsState', - default: [], -}); diff --git a/front/src/modules/metadata/states/objectMetadataItemsState.ts b/front/src/modules/metadata/states/objectMetadataItemsState.ts new file mode 100644 index 0000000000..10e8de47f5 --- /dev/null +++ b/front/src/modules/metadata/states/objectMetadataItemsState.ts @@ -0,0 +1,11 @@ +import { atom } from 'recoil'; + +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; + +/** + * @deprecated Use `useFindManyObjectMetadataItems` instead. + */ +export const objectMetadataItemsState = atom({ + key: 'objectMetadataItemsState', + default: [], +}); diff --git a/front/src/modules/metadata/states/selectors/activeMetadataObjectsSelector.ts b/front/src/modules/metadata/states/selectors/activeMetadataObjectsSelector.ts deleted file mode 100644 index 9e52e72340..0000000000 --- a/front/src/modules/metadata/states/selectors/activeMetadataObjectsSelector.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { selector } from 'recoil'; - -import { MetadataObject } from '../../types/MetadataObject'; -import { metadataObjectsState } from '../metadataObjectsState'; - -export const activeMetadataObjectsSelector = selector({ - key: 'activeMetadataObjectsSelector', - get: ({ get }) => - get(metadataObjectsState).filter(({ isActive }) => isActive), -}); diff --git a/front/src/modules/metadata/states/selectors/activeObjectMetadataItemsSelector.ts b/front/src/modules/metadata/states/selectors/activeObjectMetadataItemsSelector.ts new file mode 100644 index 0000000000..977511bb9c --- /dev/null +++ b/front/src/modules/metadata/states/selectors/activeObjectMetadataItemsSelector.ts @@ -0,0 +1,12 @@ +import { selector } from 'recoil'; + +import { ObjectMetadataItem } from '../../types/ObjectMetadataItem'; +import { objectMetadataItemsState } from '../objectMetadataItemsState'; + +export const activeObjectMetadataItemsSelector = selector( + { + key: 'activeObjectMetadataItemsSelector', + get: ({ get }) => + get(objectMetadataItemsState).filter(({ isActive }) => isActive), + }, +); diff --git a/front/src/modules/metadata/states/selectors/disabledMetadataObjectsSelector.ts b/front/src/modules/metadata/states/selectors/disabledMetadataObjectsSelector.ts deleted file mode 100644 index 0274cf2693..0000000000 --- a/front/src/modules/metadata/states/selectors/disabledMetadataObjectsSelector.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { selector } from 'recoil'; - -import { MetadataObject } from '../../types/MetadataObject'; -import { metadataObjectsState } from '../metadataObjectsState'; - -export const disabledMetadataObjectsSelector = selector({ - key: 'disabledMetadataObjectsSelector', - get: ({ get }) => - get(metadataObjectsState).filter(({ isActive }) => !isActive), -}); diff --git a/front/src/modules/metadata/states/selectors/disabledObjectMetadataItemsSelector.ts b/front/src/modules/metadata/states/selectors/disabledObjectMetadataItemsSelector.ts new file mode 100644 index 0000000000..b9a6bc3934 --- /dev/null +++ b/front/src/modules/metadata/states/selectors/disabledObjectMetadataItemsSelector.ts @@ -0,0 +1,12 @@ +import { selector } from 'recoil'; + +import { ObjectMetadataItem } from '../../types/ObjectMetadataItem'; +import { objectMetadataItemsState } from '../objectMetadataItemsState'; + +export const disabledObjectMetadataItemsSelector = selector< + ObjectMetadataItem[] +>({ + key: 'disabledObjectMetadataItemsSelector', + get: ({ get }) => + get(objectMetadataItemsState).filter(({ isActive }) => !isActive), +}); diff --git a/front/src/modules/metadata/types/MetadataObject.ts b/front/src/modules/metadata/types/ObjectMetadataItem.ts similarity index 80% rename from front/src/modules/metadata/types/MetadataObject.ts rename to front/src/modules/metadata/types/ObjectMetadataItem.ts index 1807c93ee1..ff423033e8 100644 --- a/front/src/modules/metadata/types/MetadataObject.ts +++ b/front/src/modules/metadata/types/ObjectMetadataItem.ts @@ -1,6 +1,6 @@ import { Field, Object as GeneratedObject } from '~/generated-metadata/graphql'; -export type MetadataObject = Omit< +export type ObjectMetadataItem = Omit< GeneratedObject, 'fields' | 'dataSourceId' > & { diff --git a/front/src/modules/metadata/types/MetadataObjectIdentifier.ts b/front/src/modules/metadata/types/ObjectMetadataItemIdentifier.ts similarity index 58% rename from front/src/modules/metadata/types/MetadataObjectIdentifier.ts rename to front/src/modules/metadata/types/ObjectMetadataItemIdentifier.ts index c47e27c5fb..0c4d0cbea3 100644 --- a/front/src/modules/metadata/types/MetadataObjectIdentifier.ts +++ b/front/src/modules/metadata/types/ObjectMetadataItemIdentifier.ts @@ -1,4 +1,4 @@ -export type MetadataObjectIdentifier = { +export type ObjectMetadataItemIdentifier = { objectNamePlural?: string; objectNameSingular?: string; }; diff --git a/front/src/modules/metadata/utils/formatMetadataFieldAsColumnDefinition.ts b/front/src/modules/metadata/utils/formatMetadataFieldAsColumnDefinition.ts index 262f50fbd1..6b2c03a740 100644 --- a/front/src/modules/metadata/utils/formatMetadataFieldAsColumnDefinition.ts +++ b/front/src/modules/metadata/utils/formatMetadataFieldAsColumnDefinition.ts @@ -1,19 +1,19 @@ import { FieldMetadata } from '@/ui/object/field/types/FieldMetadata'; import { ColumnDefinition } from '@/ui/object/record-table/types/ColumnDefinition'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; import { parseFieldType } from './parseFieldType'; export const formatMetadataFieldAsColumnDefinition = ({ position, field, - metadataObject, + objectMetadataItem, icons, }: { position: number; - field: MetadataObject['fields'][0]; - metadataObject: Omit; + field: ObjectMetadataItem['fields'][0]; + objectMetadataItem: Omit; icons: Record; }): ColumnDefinition => ({ position, @@ -27,5 +27,5 @@ export const formatMetadataFieldAsColumnDefinition = ({ }, Icon: icons[field.icon ?? 'Icon123'], isVisible: true, - basePathToShowPage: `/object/${metadataObject.nameSingular}/`, + basePathToShowPage: `/object/${objectMetadataItem.nameSingular}/`, }); diff --git a/front/src/modules/metadata/utils/formatMetadataFieldAsFilterDefinition.ts b/front/src/modules/metadata/utils/formatMetadataFieldAsFilterDefinition.ts index 46c7f40536..62257a282d 100644 --- a/front/src/modules/metadata/utils/formatMetadataFieldAsFilterDefinition.ts +++ b/front/src/modules/metadata/utils/formatMetadataFieldAsFilterDefinition.ts @@ -1,12 +1,12 @@ import { FilterDefinition } from '@/ui/object/object-filter-dropdown/types/FilterDefinition'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; export const formatMetadataFieldAsFilterDefinition = ({ field, icons, }: { - field: MetadataObject['fields'][0]; + field: ObjectMetadataItem['fields'][0]; icons: Record; }): FilterDefinition => ({ fieldId: field.id, diff --git a/front/src/modules/metadata/utils/formatMetadataFieldAsSortDefinition.ts b/front/src/modules/metadata/utils/formatMetadataFieldAsSortDefinition.ts index dc20463a6e..2b5fd8d26b 100644 --- a/front/src/modules/metadata/utils/formatMetadataFieldAsSortDefinition.ts +++ b/front/src/modules/metadata/utils/formatMetadataFieldAsSortDefinition.ts @@ -1,12 +1,12 @@ import { SortDefinition } from '@/ui/object/object-sort-dropdown/types/SortDefinition'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; export const formatMetadataFieldAsSortDefinition = ({ field, icons, }: { - field: MetadataObject['fields'][0]; + field: ObjectMetadataItem['fields'][0]; icons: Record; }): SortDefinition => ({ fieldId: field.id, diff --git a/front/src/modules/metadata/utils/formatMetadataObjectInput.ts b/front/src/modules/metadata/utils/formatObjectMetadataItemInput.ts similarity index 74% rename from front/src/modules/metadata/utils/formatMetadataObjectInput.ts rename to front/src/modules/metadata/utils/formatObjectMetadataItemInput.ts index 8c2a5ab0e7..5a1ffd5e91 100644 --- a/front/src/modules/metadata/utils/formatMetadataObjectInput.ts +++ b/front/src/modules/metadata/utils/formatObjectMetadataItemInput.ts @@ -1,10 +1,10 @@ import toCamelCase from 'lodash.camelcase'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; -export const formatMetadataObjectInput = ( +export const formatObjectMetadataItemInput = ( input: Pick< - MetadataObject, + ObjectMetadataItem, 'labelPlural' | 'labelSingular' | 'icon' | 'description' >, ) => ({ diff --git a/front/src/modules/metadata/utils/formatPagedMetadataObjectsToMetadataObjects.ts b/front/src/modules/metadata/utils/formatPagedMetadataObjectsToMetadataObjects.ts deleted file mode 100644 index d297b17a32..0000000000 --- a/front/src/modules/metadata/utils/formatPagedMetadataObjectsToMetadataObjects.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MetadataObjectsQuery } from '~/generated-metadata/graphql'; - -import { MetadataObject } from '../types/MetadataObject'; - -export const formatPagedMetadataObjectsToMetadataObjects = ({ - pagedMetadataObjects: pagedMetadataObjects, -}: { - pagedMetadataObjects: MetadataObjectsQuery | undefined; -}) => { - const formattedObjects: MetadataObject[] = - pagedMetadataObjects?.objects.edges.map((object) => ({ - ...object.node, - fields: object.node.fields.edges.map((field) => field.node), - })) ?? []; - - return formattedObjects; -}; diff --git a/front/src/modules/metadata/utils/formatPagedObjectMetadataItemsToObjectMetadataItems.ts b/front/src/modules/metadata/utils/formatPagedObjectMetadataItemsToObjectMetadataItems.ts new file mode 100644 index 0000000000..41b69bdd15 --- /dev/null +++ b/front/src/modules/metadata/utils/formatPagedObjectMetadataItemsToObjectMetadataItems.ts @@ -0,0 +1,17 @@ +import { ObjectMetadataItemsQuery } from '~/generated-metadata/graphql'; + +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; + +export const formatPagedObjectMetadataItemsToObjectMetadataItems = ({ + pagedObjectMetadataItems: pagedObjectMetadataItems, +}: { + pagedObjectMetadataItems: ObjectMetadataItemsQuery | undefined; +}) => { + const formattedObjects: ObjectMetadataItem[] = + pagedObjectMetadataItems?.objects.edges.map((object) => ({ + ...object.node, + fields: object.node.fields.edges.map((field) => field.node), + })) ?? []; + + return formattedObjects; +}; diff --git a/front/src/modules/metadata/utils/generateCreateOneObjectMutation.ts b/front/src/modules/metadata/utils/generateCreateOneObjectMutation.ts index 14a30cff40..a9b526787e 100644 --- a/front/src/modules/metadata/utils/generateCreateOneObjectMutation.ts +++ b/front/src/modules/metadata/utils/generateCreateOneObjectMutation.ts @@ -2,14 +2,14 @@ import { gql } from '@apollo/client'; import { capitalize } from '~/utils/string/capitalize'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; export const generateCreateOneObjectMutation = ({ - metadataObject, + objectMetadataItem, }: { - metadataObject: MetadataObject; + objectMetadataItem: ObjectMetadataItem; }) => { - const capitalizedObjectName = capitalize(metadataObject.nameSingular); + const capitalizedObjectName = capitalize(objectMetadataItem.nameSingular); return gql` mutation CreateOne${capitalizedObjectName}($input: ${capitalizedObjectName}CreateInput!) { diff --git a/front/src/modules/metadata/utils/generateDeleteOneObjectMutation.ts b/front/src/modules/metadata/utils/generateDeleteOneObjectMutation.ts index 23353fecd4..eaaedb013a 100644 --- a/front/src/modules/metadata/utils/generateDeleteOneObjectMutation.ts +++ b/front/src/modules/metadata/utils/generateDeleteOneObjectMutation.ts @@ -2,15 +2,15 @@ import { gql } from '@apollo/client'; import { capitalize } from '~/utils/string/capitalize'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; // TODO: implement export const generateDeleteOneObjectMutation = ({ - metadataObject, + objectMetadataItem, }: { - metadataObject: MetadataObject; + objectMetadataItem: ObjectMetadataItem; }) => { - const capitalizedObjectName = capitalize(metadataObject.nameSingular); + const capitalizedObjectName = capitalize(objectMetadataItem.nameSingular); return gql` mutation DeleteOne${capitalizedObjectName}($input: ${capitalizedObjectName}DeleteInput!) { diff --git a/front/src/modules/metadata/utils/generateFindManyCustomObjectsQuery.ts b/front/src/modules/metadata/utils/generateFindManyCustomObjectsQuery.ts index 4ed4e0650e..9abd7afa9d 100644 --- a/front/src/modules/metadata/utils/generateFindManyCustomObjectsQuery.ts +++ b/front/src/modules/metadata/utils/generateFindManyCustomObjectsQuery.ts @@ -2,26 +2,28 @@ import { gql } from '@apollo/client'; import { capitalize } from '~/utils/string/capitalize'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; import { mapFieldMetadataToGraphQLQuery } from './mapFieldMetadataToGraphQLQuery'; export const generateFindManyCustomObjectsQuery = ({ - metadataObject, + objectMetadataItem, _fromCursor, }: { - metadataObject: MetadataObject; + objectMetadataItem: ObjectMetadataItem; _fromCursor?: string; }) => { return gql` - query FindMany${metadataObject.namePlural}($filter: ${capitalize( - metadataObject.nameSingular, - )}FilterInput, $orderBy: ${capitalize(metadataObject.nameSingular)}OrderBy) { - ${metadataObject.namePlural}(filter: $filter, orderBy: $orderBy){ + query FindMany${objectMetadataItem.namePlural}($filter: ${capitalize( + objectMetadataItem.nameSingular, + )}FilterInput, $orderBy: ${capitalize( + objectMetadataItem.nameSingular, + )}OrderBy) { + ${objectMetadataItem.namePlural}(filter: $filter, orderBy: $orderBy){ edges { node { id - ${metadataObject.fields + ${objectMetadataItem.fields .map(mapFieldMetadataToGraphQLQuery) .join('\n')} } diff --git a/front/src/modules/metadata/utils/generateFindOneCustomObjectQuery.ts b/front/src/modules/metadata/utils/generateFindOneCustomObjectQuery.ts index be20c0e585..4a996e4e75 100644 --- a/front/src/modules/metadata/utils/generateFindOneCustomObjectQuery.ts +++ b/front/src/modules/metadata/utils/generateFindOneCustomObjectQuery.ts @@ -1,23 +1,25 @@ import { gql } from '@apollo/client'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; import { mapFieldMetadataToGraphQLQuery } from './mapFieldMetadataToGraphQLQuery'; export const generateFindOneCustomObjectQuery = ({ - metadataObject, + objectMetadataItem, }: { - metadataObject: MetadataObject; + objectMetadataItem: ObjectMetadataItem; }) => { return gql` - query FindOne${metadataObject.nameSingular}($objectId: UUID!) { - ${metadataObject.nameSingular}(filter: { + query FindOne${objectMetadataItem.nameSingular}($objectId: UUID!) { + ${objectMetadataItem.nameSingular}(filter: { id: { eq: $objectId } }){ id - ${metadataObject.fields.map(mapFieldMetadataToGraphQLQuery).join('\n')} + ${objectMetadataItem.fields + .map(mapFieldMetadataToGraphQLQuery) + .join('\n')} } } `; diff --git a/front/src/modules/metadata/utils/generateUpdateOneObjectMutation.ts b/front/src/modules/metadata/utils/generateUpdateOneObjectMutation.ts index 47b3014dcf..a31904a1d0 100644 --- a/front/src/modules/metadata/utils/generateUpdateOneObjectMutation.ts +++ b/front/src/modules/metadata/utils/generateUpdateOneObjectMutation.ts @@ -2,14 +2,14 @@ import { gql } from '@apollo/client'; import { capitalize } from '~/utils/string/capitalize'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; export const generateUpdateOneObjectMutation = ({ - metadataObject, + objectMetadataItem, }: { - metadataObject: MetadataObject; + objectMetadataItem: ObjectMetadataItem; }) => { - const capitalizedObjectName = capitalize(metadataObject.nameSingular); + const capitalizedObjectName = capitalize(objectMetadataItem.nameSingular); return gql` mutation UpdateOne${capitalizedObjectName}($idToUpdate: ID!, $input: ${capitalizedObjectName}UpdateInput!) { diff --git a/front/src/modules/metadata/utils/getObjectSlug.ts b/front/src/modules/metadata/utils/getObjectSlug.ts index f7241b4103..465af568df 100644 --- a/front/src/modules/metadata/utils/getObjectSlug.ts +++ b/front/src/modules/metadata/utils/getObjectSlug.ts @@ -1,7 +1,7 @@ import toKebabCase from 'lodash.kebabcase'; -import { MetadataObject } from '../types/MetadataObject'; +import { ObjectMetadataItem } from '../types/ObjectMetadataItem'; export const getObjectSlug = ( - metadataObject: Pick, -) => toKebabCase(metadataObject.labelPlural); + objectMetadataItem: Pick, +) => toKebabCase(objectMetadataItem.labelPlural); diff --git a/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectItemTableRow.tsx b/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectItemTableRow.tsx index 9c3b91501e..0d131a5931 100644 --- a/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectItemTableRow.tsx +++ b/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectItemTableRow.tsx @@ -1,7 +1,7 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { MetadataObject } from '@/metadata/types/MetadataObject'; +import { ObjectMetadataItem } from '@/metadata/types/ObjectMetadataItem'; import { Checkbox } from '@/ui/input/components/Checkbox'; import { useLazyLoadIcon } from '@/ui/input/hooks/useLazyLoadIcon'; import { TableCell } from '@/ui/layout/table/components/TableCell'; @@ -9,7 +9,7 @@ import { TableRow } from '@/ui/layout/table/components/TableRow'; type SettingsAvailableStandardObjectItemTableRowProps = { isSelected?: boolean; - objectItem: MetadataObject; + objectItem: ObjectMetadataItem; onClick?: () => void; }; diff --git a/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectsSection.tsx b/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectsSection.tsx index a25cc8ee06..f72475733f 100644 --- a/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectsSection.tsx +++ b/front/src/modules/settings/data-model/new-object/components/SettingsAvailableStandardObjectsSection.tsx @@ -1,4 +1,4 @@ -import { MetadataObject } from '@/metadata/types/MetadataObject'; +import { ObjectMetadataItem } from '@/metadata/types/ObjectMetadataItem'; import { H2Title } from '@/ui/display/typography/components/H2Title'; import { Section } from '@/ui/layout/section/components/Section'; import { Table } from '@/ui/layout/table/components/Table'; @@ -11,7 +11,7 @@ import { } from './SettingsAvailableStandardObjectItemTableRow'; type SettingsAvailableStandardObjectsSectionProps = { - objectItems: MetadataObject[]; + objectItems: ObjectMetadataItem[]; onChange: (selectedIds: Record) => void; selectedIds: Record; }; diff --git a/front/src/modules/settings/data-model/object-details/components/SettingsObjectItemTableRow.tsx b/front/src/modules/settings/data-model/object-details/components/SettingsObjectItemTableRow.tsx index 9ef64ae511..d4ce5d90a0 100644 --- a/front/src/modules/settings/data-model/object-details/components/SettingsObjectItemTableRow.tsx +++ b/front/src/modules/settings/data-model/object-details/components/SettingsObjectItemTableRow.tsx @@ -3,7 +3,7 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { useFindManyObjects } from '@/metadata/hooks/useFindManyObjects'; -import { MetadataObject } from '@/metadata/types/MetadataObject'; +import { ObjectMetadataItem } from '@/metadata/types/ObjectMetadataItem'; import { Tag } from '@/ui/display/tag/components/Tag'; import { useLazyLoadIcon } from '@/ui/input/hooks/useLazyLoadIcon'; import { TableCell } from '@/ui/layout/table/components/TableCell'; @@ -11,7 +11,7 @@ import { TableRow } from '@/ui/layout/table/components/TableRow'; type SettingsObjectItemTableRowProps = { action: ReactNode; - objectItem: MetadataObject; + objectItem: ObjectMetadataItem; onClick?: () => void; }; diff --git a/front/src/modules/views/hooks/internal/useViewFields.ts b/front/src/modules/views/hooks/internal/useViewFields.ts index 8282ceb77e..359f8046ad 100644 --- a/front/src/modules/views/hooks/internal/useViewFields.ts +++ b/front/src/modules/views/hooks/internal/useViewFields.ts @@ -1,7 +1,7 @@ import { useApolloClient } from '@apollo/client'; import { useRecoilCallback } from 'recoil'; -import { useFindOneMetadataObject } from '@/metadata/hooks/useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from '@/metadata/hooks/useFindOneObjectMetadataItem'; import { currentViewIdScopedState } from '@/views/states/currentViewIdScopedState'; import { savedViewFieldByKeyScopedFamilySelector } from '@/views/states/selectors/savedViewFieldByKeyScopedFamilySelector'; import { viewObjectIdScopeState } from '@/views/states/viewObjectIdScopeState'; @@ -9,7 +9,7 @@ import { ViewField } from '@/views/types/ViewField'; export const useViewFields = (viewScopeId: string) => { const { updateOneMutation, createOneMutation, findManyQuery } = - useFindOneMetadataObject({ + useFindOneObjectMetadataItem({ objectNameSingular: 'viewFieldV2', }); const apolloClient = useApolloClient(); diff --git a/front/src/modules/views/hooks/internal/useViewFilters.ts b/front/src/modules/views/hooks/internal/useViewFilters.ts index 846c509e2c..9285bf581d 100644 --- a/front/src/modules/views/hooks/internal/useViewFilters.ts +++ b/front/src/modules/views/hooks/internal/useViewFilters.ts @@ -2,7 +2,7 @@ import { useApolloClient } from '@apollo/client'; import { produce } from 'immer'; import { useRecoilCallback } from 'recoil'; -import { useFindOneMetadataObject } from '@/metadata/hooks/useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from '@/metadata/hooks/useFindOneObjectMetadataItem'; import { Filter } from '@/ui/object/object-filter-dropdown/types/Filter'; import { currentViewFiltersScopedFamilyState } from '@/views/states/currentViewFiltersScopedFamilyState'; import { currentViewIdScopedState } from '@/views/states/currentViewIdScopedState'; @@ -15,7 +15,7 @@ import { useViewSetStates } from '../useViewSetStates'; export const useViewFilters = (viewScopeId: string) => { const { updateOneMutation, createOneMutation, findManyQuery } = - useFindOneMetadataObject({ + useFindOneObjectMetadataItem({ objectNameSingular: 'viewFilterV2', }); const apolloClient = useApolloClient(); diff --git a/front/src/modules/views/hooks/internal/useViewSorts.ts b/front/src/modules/views/hooks/internal/useViewSorts.ts index 2ef554d6f6..abe0cb55de 100644 --- a/front/src/modules/views/hooks/internal/useViewSorts.ts +++ b/front/src/modules/views/hooks/internal/useViewSorts.ts @@ -2,7 +2,7 @@ import { useApolloClient } from '@apollo/client'; import { produce } from 'immer'; import { useRecoilCallback } from 'recoil'; -import { useFindOneMetadataObject } from '@/metadata/hooks/useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from '@/metadata/hooks/useFindOneObjectMetadataItem'; import { Sort } from '@/ui/object/object-sort-dropdown/types/Sort'; import { currentViewIdScopedState } from '@/views/states/currentViewIdScopedState'; import { currentViewSortsScopedFamilyState } from '@/views/states/currentViewSortsScopedFamilyState'; @@ -15,7 +15,7 @@ import { useViewSetStates } from '../useViewSetStates'; export const useViewSorts = (viewScopeId: string) => { const { updateOneMutation, createOneMutation, findManyQuery } = - useFindOneMetadataObject({ + useFindOneObjectMetadataItem({ objectNameSingular: 'viewSortV2', }); const apolloClient = useApolloClient(); diff --git a/front/src/modules/views/hooks/internal/useViews.ts b/front/src/modules/views/hooks/internal/useViews.ts index af75cc66eb..a10b572e83 100644 --- a/front/src/modules/views/hooks/internal/useViews.ts +++ b/front/src/modules/views/hooks/internal/useViews.ts @@ -1,14 +1,14 @@ import { useApolloClient } from '@apollo/client'; import { useRecoilCallback } from 'recoil'; -import { useFindOneMetadataObject } from '@/metadata/hooks/useFindOneMetadataObject'; +import { useFindOneObjectMetadataItem } from '@/metadata/hooks/useFindOneObjectMetadataItem'; import { viewObjectIdScopeState } from '@/views/states/viewObjectIdScopeState'; import { viewTypeScopedState } from '@/views/states/viewTypeScopedState'; import { View } from '@/views/types/View'; export const useViews = (scopeId: string) => { const { updateOneMutation, createOneMutation, findManyQuery } = - useFindOneMetadataObject({ + useFindOneObjectMetadataItem({ objectNameSingular: 'viewV2', }); const apolloClient = useApolloClient(); diff --git a/front/src/pages/settings/data-model/SettingsNewObject.tsx b/front/src/pages/settings/data-model/SettingsNewObject.tsx index f1fa305bb2..eb1be07c90 100644 --- a/front/src/pages/settings/data-model/SettingsNewObject.tsx +++ b/front/src/pages/settings/data-model/SettingsNewObject.tsx @@ -2,7 +2,7 @@ import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useCreateOneObject } from '@/metadata/hooks/useCreateOneObject'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { getObjectSlug } from '@/metadata/utils/getObjectSlug'; import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons'; import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer'; @@ -27,10 +27,10 @@ export const SettingsNewObject = () => { useState('Standard'); const { - activateMetadataObject: activateObject, - createMetadataObject: createObject, - disabledMetadataObjects: disabledObjects, - } = useMetadataObjectForSettings(); + activateObjectMetadataItem: activateObject, + createObjectMetadataItem: createObject, + disabledObjectMetadataItems: disabledObjects, + } = useObjectMetadataItemForSettings(); const { createOneObject: createOneView } = useCreateOneObject({ objectNamePlural: 'viewsV2', diff --git a/front/src/pages/settings/data-model/SettingsObjectDetail.tsx b/front/src/pages/settings/data-model/SettingsObjectDetail.tsx index 768b729b78..6f34ae339b 100644 --- a/front/src/pages/settings/data-model/SettingsObjectDetail.tsx +++ b/front/src/pages/settings/data-model/SettingsObjectDetail.tsx @@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import styled from '@emotion/styled'; import { useMetadataField } from '@/metadata/hooks/useMetadataField'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { getFieldSlug } from '@/metadata/utils/getFieldSlug'; import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer'; import { SettingsAboutSection } from '@/settings/data-model/object-details/components/SettingsObjectAboutSection'; @@ -34,30 +34,34 @@ export const SettingsObjectDetail = () => { const navigate = useNavigate(); const { objectSlug = '' } = useParams(); - const { disableMetadataObject, findActiveMetadataObjectBySlug, loading } = - useMetadataObjectForSettings(); + const { + disableObjectMetadataItem, + findActiveObjectMetadataItemBySlug, + loading, + } = useObjectMetadataItemForSettings(); - const activeMetadataObject = findActiveMetadataObjectBySlug(objectSlug); + const activeObjectMetadataItem = + findActiveObjectMetadataItemBySlug(objectSlug); useEffect(() => { if (loading) return; - if (!activeMetadataObject) navigate(AppPath.NotFound); - }, [activeMetadataObject, loading, navigate]); + if (!activeObjectMetadataItem) navigate(AppPath.NotFound); + }, [activeObjectMetadataItem, loading, navigate]); const { activateMetadataField, disableMetadataField, eraseMetadataField } = useMetadataField(); - if (!activeMetadataObject) return null; + if (!activeObjectMetadataItem) return null; - const activeMetadataFields = activeMetadataObject.fields.filter( + const activeMetadataFields = activeObjectMetadataItem.fields.filter( (metadataField) => metadataField.isActive, ); - const disabledMetadataFields = activeMetadataObject.fields.filter( + const disabledMetadataFields = activeObjectMetadataItem.fields.filter( (metadataField) => !metadataField.isActive, ); const handleDisable = async () => { - await disableMetadataObject(activeMetadataObject); + await disableObjectMetadataItem(activeObjectMetadataItem); navigate('/settings/objects'); }; @@ -67,20 +71,20 @@ export const SettingsObjectDetail = () => { navigate('./edit')} />
diff --git a/front/src/pages/settings/data-model/SettingsObjectEdit.tsx b/front/src/pages/settings/data-model/SettingsObjectEdit.tsx index 69e9aa53bc..a7e3507f51 100644 --- a/front/src/pages/settings/data-model/SettingsObjectEdit.tsx +++ b/front/src/pages/settings/data-model/SettingsObjectEdit.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { getObjectSlug } from '@/metadata/utils/getObjectSlug'; import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons'; import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer'; @@ -21,13 +21,14 @@ export const SettingsObjectEdit = () => { const { objectSlug = '' } = useParams(); const { - disableMetadataObject, - editMetadataObject, - findActiveMetadataObjectBySlug, + disableObjectMetadataItem, + editObjectMetadataItem, + findActiveObjectMetadataItemBySlug, loading, - } = useMetadataObjectForSettings(); + } = useObjectMetadataItemForSettings(); - const activeMetadataObject = findActiveMetadataObjectBySlug(objectSlug); + const activeObjectMetadataItem = + findActiveObjectMetadataItemBySlug(objectSlug); const [formValues, setFormValues] = useState< Partial<{ @@ -41,44 +42,47 @@ export const SettingsObjectEdit = () => { useEffect(() => { if (loading) return; - if (!activeMetadataObject) { + if (!activeObjectMetadataItem) { navigate(AppPath.NotFound); return; } if (!Object.keys(formValues).length) { setFormValues({ - icon: activeMetadataObject.icon ?? undefined, - labelSingular: activeMetadataObject.labelSingular, - labelPlural: activeMetadataObject.labelPlural, - description: activeMetadataObject.description ?? undefined, + icon: activeObjectMetadataItem.icon ?? undefined, + labelSingular: activeObjectMetadataItem.labelSingular, + labelPlural: activeObjectMetadataItem.labelPlural, + description: activeObjectMetadataItem.description ?? undefined, }); } - }, [activeMetadataObject, formValues, loading, navigate]); + }, [activeObjectMetadataItem, formValues, loading, navigate]); - if (!activeMetadataObject) return null; + if (!activeObjectMetadataItem) return null; const areRequiredFieldsFilled = !!formValues.labelSingular && !!formValues.labelPlural; const hasChanges = - formValues.description !== activeMetadataObject.description || - formValues.icon !== activeMetadataObject.icon || - formValues.labelPlural !== activeMetadataObject.labelPlural || - formValues.labelSingular !== activeMetadataObject.labelSingular; + formValues.description !== activeObjectMetadataItem.description || + formValues.icon !== activeObjectMetadataItem.icon || + formValues.labelPlural !== activeObjectMetadataItem.labelPlural || + formValues.labelSingular !== activeObjectMetadataItem.labelSingular; const canSave = areRequiredFieldsFilled && hasChanges; const handleSave = async () => { - const editedMetadataObject = { ...activeMetadataObject, ...formValues }; + const editedObjectMetadataItem = { + ...activeObjectMetadataItem, + ...formValues, + }; - await editMetadataObject(editedMetadataObject); + await editObjectMetadataItem(editedObjectMetadataItem); - navigate(`/settings/objects/${getObjectSlug(editedMetadataObject)}`); + navigate(`/settings/objects/${getObjectSlug(editedObjectMetadataItem)}`); }; const handleDisable = async () => { - await disableMetadataObject(activeMetadataObject); + await disableObjectMetadataItem(activeObjectMetadataItem); navigate('/settings/objects'); }; @@ -90,13 +94,13 @@ export const SettingsObjectEdit = () => { links={[ { children: 'Objects', href: '/settings/objects' }, { - children: activeMetadataObject.labelPlural, + children: activeObjectMetadataItem.labelPlural, href: `/settings/objects/${objectSlug}`, }, { children: 'Edit' }, ]} /> - {activeMetadataObject.isCustom && ( + {activeObjectMetadataItem.isCustom && ( navigate(`/settings/objects/${objectSlug}`)} @@ -105,7 +109,7 @@ export const SettingsObjectEdit = () => { )} @@ -116,7 +120,7 @@ export const SettingsObjectEdit = () => { } /> { const navigate = useNavigate(); const { objectSlug = '', fieldSlug = '' } = useParams(); - const { findActiveMetadataObjectBySlug, loading } = - useMetadataObjectForSettings(); + const { findActiveObjectMetadataItemBySlug, loading } = + useObjectMetadataItemForSettings(); - const activeMetadataObject = findActiveMetadataObjectBySlug(objectSlug); + const activeObjectMetadataItem = + findActiveObjectMetadataItemBySlug(objectSlug); const { disableMetadataField, editMetadataField } = useMetadataField(); - const activeMetadataField = activeMetadataObject?.fields.find( + const activeMetadataField = activeObjectMetadataItem?.fields.find( (metadataField) => metadataField.isActive && getFieldSlug(metadataField) === fieldSlug, ); @@ -44,7 +45,7 @@ export const SettingsObjectFieldEdit = () => { useEffect(() => { if (loading) return; - if (!activeMetadataObject || !activeMetadataField) { + if (!activeObjectMetadataItem || !activeMetadataField) { navigate(AppPath.NotFound); return; } @@ -58,13 +59,13 @@ export const SettingsObjectFieldEdit = () => { } }, [ activeMetadataField, - activeMetadataObject, + activeObjectMetadataItem, formValues, loading, navigate, ]); - if (!activeMetadataObject || !activeMetadataField) return null; + if (!activeObjectMetadataItem || !activeMetadataField) return null; const areRequiredFieldsFilled = !!formValues.label; @@ -96,7 +97,7 @@ export const SettingsObjectFieldEdit = () => { links={[ { children: 'Objects', href: '/settings/objects' }, { - children: activeMetadataObject.labelPlural, + children: activeObjectMetadataItem.labelPlural, href: `/settings/objects/${objectSlug}`, }, { children: activeMetadataField.label }, diff --git a/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep1.tsx b/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep1.tsx index c62c50edd5..fd6ca594ec 100644 --- a/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep1.tsx +++ b/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep1.tsx @@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import styled from '@emotion/styled'; import { useMetadataField } from '@/metadata/hooks/useMetadataField'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons'; import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer'; import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer'; @@ -37,14 +37,15 @@ export const SettingsObjectNewFieldStep1 = () => { const navigate = useNavigate(); const { objectSlug = '' } = useParams(); - const { findActiveMetadataObjectBySlug, loading } = - useMetadataObjectForSettings(); + const { findActiveObjectMetadataItemBySlug, loading } = + useObjectMetadataItemForSettings(); - const activeMetadataObject = findActiveMetadataObjectBySlug(objectSlug); + const activeObjectMetadataItem = + findActiveObjectMetadataItemBySlug(objectSlug); const { activateMetadataField, disableMetadataField } = useMetadataField(); const [metadataFields, setMetadataFields] = useState( - activeMetadataObject?.fields ?? [], + activeObjectMetadataItem?.fields ?? [], ); const activeMetadataFields = metadataFields.filter((field) => field.isActive); @@ -54,21 +55,22 @@ export const SettingsObjectNewFieldStep1 = () => { const canSave = metadataFields.some( (field, index) => - field.isActive !== activeMetadataObject?.fields[index].isActive, + field.isActive !== activeObjectMetadataItem?.fields[index].isActive, ); useEffect(() => { if (loading) return; - if (!activeMetadataObject) { + if (!activeObjectMetadataItem) { navigate(AppPath.NotFound); return; } - if (!metadataFields.length) setMetadataFields(activeMetadataObject.fields); - }, [activeMetadataObject, metadataFields.length, loading, navigate]); + if (!metadataFields.length) + setMetadataFields(activeObjectMetadataItem.fields); + }, [activeObjectMetadataItem, metadataFields.length, loading, navigate]); - if (!activeMetadataObject) return null; + if (!activeObjectMetadataItem) return null; const handleToggleField = (fieldId: string) => setMetadataFields((previousFields) => @@ -81,7 +83,8 @@ export const SettingsObjectNewFieldStep1 = () => { await Promise.all( metadataFields.map((metadataField, index) => { if ( - metadataField.isActive === activeMetadataObject.fields[index].isActive + metadataField.isActive === + activeObjectMetadataItem.fields[index].isActive ) { return; } @@ -103,7 +106,7 @@ export const SettingsObjectNewFieldStep1 = () => { links={[ { children: 'Objects', href: '/settings/objects' }, { - children: activeMetadataObject.labelPlural, + children: activeObjectMetadataItem.labelPlural, href: `/settings/objects/${objectSlug}`, }, { children: 'New Field' }, diff --git a/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx b/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx index f2da9f63d7..9665af77c9 100644 --- a/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx +++ b/front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx @@ -4,7 +4,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import { useCreateOneObject } from '@/metadata/hooks/useCreateOneObject'; import { useFindManyObjects } from '@/metadata/hooks/useFindManyObjects'; import { useMetadataField } from '@/metadata/hooks/useMetadataField'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { PaginatedObjectTypeResults } from '@/metadata/types/PaginatedObjectTypeResults'; import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons'; import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer'; @@ -23,16 +23,17 @@ export const SettingsObjectNewFieldStep2 = () => { const navigate = useNavigate(); const { objectSlug = '' } = useParams(); - const { findActiveMetadataObjectBySlug, loading } = - useMetadataObjectForSettings(); + const { findActiveObjectMetadataItemBySlug, loading } = + useObjectMetadataItemForSettings(); - const activeMetadataObject = findActiveMetadataObjectBySlug(objectSlug); + const activeObjectMetadataItem = + findActiveObjectMetadataItemBySlug(objectSlug); const { createMetadataField } = useMetadataField(); useEffect(() => { if (loading) return; - if (!activeMetadataObject) navigate(AppPath.NotFound); - }, [activeMetadataObject, loading, navigate]); + if (!activeObjectMetadataItem) navigate(AppPath.NotFound); + }, [activeObjectMetadataItem, loading, navigate]); const [formValues, setFormValues] = useState<{ description?: string; @@ -51,7 +52,7 @@ export const SettingsObjectNewFieldStep2 = () => { objectNamePlural: 'viewsV2', filter: { type: { eq: ViewType.Table }, - objectId: { eq: activeMetadataObject?.id }, + objectId: { eq: activeObjectMetadataItem?.id }, }, onCompleted: async (data: PaginatedObjectTypeResults) => { const views = data.edges; @@ -64,20 +65,20 @@ export const SettingsObjectNewFieldStep2 = () => { }, }); - if (!activeMetadataObject || !objectViews.length) return null; + if (!activeObjectMetadataItem || !objectViews.length) return null; const canSave = !!formValues.label; const handleSave = async () => { const createdField = await createMetadataField({ ...formValues, - objectId: activeMetadataObject.id, + objectId: activeObjectMetadataItem.id, }); objectViews.forEach(async (view) => { await createOneViewField?.({ viewId: view.id, fieldId: createdField.data?.createOneField.id, - position: activeMetadataObject.fields.length, + position: activeObjectMetadataItem.fields.length, isVisible: true, size: 100, }); @@ -93,7 +94,7 @@ export const SettingsObjectNewFieldStep2 = () => { links={[ { children: 'Objects', href: '/settings/objects' }, { - children: activeMetadataObject.labelPlural, + children: activeObjectMetadataItem.labelPlural, href: `/settings/objects/${objectSlug}`, }, { children: 'New Field' }, diff --git a/front/src/pages/settings/data-model/SettingsObjects.tsx b/front/src/pages/settings/data-model/SettingsObjects.tsx index d191486a51..aa46062440 100644 --- a/front/src/pages/settings/data-model/SettingsObjects.tsx +++ b/front/src/pages/settings/data-model/SettingsObjects.tsx @@ -2,7 +2,7 @@ import { useNavigate } from 'react-router-dom'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { useMetadataObjectForSettings } from '@/metadata/hooks/useMetadataObjectForSettings'; +import { useObjectMetadataItemForSettings } from '@/metadata/hooks/useObjectMetadataItemForSettings'; import { getObjectSlug } from '@/metadata/utils/getObjectSlug'; import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer'; import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer'; @@ -35,11 +35,11 @@ export const SettingsObjects = () => { const navigate = useNavigate(); const { - activateMetadataObject, - activeMetadataObjects, - disabledMetadataObjects, - eraseMetadataObject, - } = useMetadataObjectForSettings(); + activateObjectMetadataItem, + activeObjectMetadataItems, + disabledObjectMetadataItems, + eraseObjectMetadataItem, + } = useObjectMetadataItemForSettings(); return ( @@ -66,12 +66,12 @@ export const SettingsObjects = () => { Instances - {!!activeMetadataObjects.length && ( + {!!activeObjectMetadataItems.length && ( - {activeMetadataObjects.map((activeMetadataObject) => ( + {activeObjectMetadataItems.map((activeObjectMetadataItem) => ( { onClick={() => navigate( `/settings/objects/${getObjectSlug( - activeMetadataObject, + activeObjectMetadataItem, )}`, ) } @@ -89,26 +89,32 @@ export const SettingsObjects = () => { ))} )} - {!!disabledMetadataObjects.length && ( + {!!disabledObjectMetadataItems.length && ( - {disabledMetadataObjects.map((disabledMetadataObject) => ( - - activateMetadataObject(disabledMetadataObject) - } - onErase={() => - eraseMetadataObject(disabledMetadataObject) - } - /> - } - /> - ))} + {disabledObjectMetadataItems.map( + (disabledObjectMetadataItem) => ( + + activateObjectMetadataItem( + disabledObjectMetadataItem, + ) + } + onErase={() => + eraseObjectMetadataItem( + disabledObjectMetadataItem, + ) + } + /> + } + /> + ), + )} )}
diff --git a/front/src/testing/graphqlMocks.ts b/front/src/testing/graphqlMocks.ts index 365cc9a106..30fef3b0b7 100644 --- a/front/src/testing/graphqlMocks.ts +++ b/front/src/testing/graphqlMocks.ts @@ -34,7 +34,7 @@ import { mockedApiKeys } from '~/testing/mock-data/api-keys'; import { mockedActivities, mockedTasks } from './mock-data/activities'; import { mockedCompaniesData } from './mock-data/companies'; -import { mockedMetadataObjects } from './mock-data/metadata'; +import { mockedObjectMetadataItems } from './mock-data/metadata'; import { mockedPeopleData } from './mock-data/people'; import { mockedPipelineProgressData } from './mock-data/pipeline-progress'; import { mockedPipelinesData } from './mock-data/pipelines'; @@ -291,7 +291,7 @@ export const graphqlMocks = [ metadataGraphql.query( getOperationName(FIND_MANY_METADATA_OBJECTS) ?? '', (req, res, ctx) => { - return res(ctx.data({ objects: mockedMetadataObjects })); + return res(ctx.data({ objects: mockedObjectMetadataItems })); }, ), ]; diff --git a/front/src/testing/mock-data/metadata.ts b/front/src/testing/mock-data/metadata.ts index 0065c268f6..0c18b1a145 100644 --- a/front/src/testing/mock-data/metadata.ts +++ b/front/src/testing/mock-data/metadata.ts @@ -1,4 +1,4 @@ -export const mockedMetadataObjects = { +export const mockedObjectMetadataItems = { edges: [ { node: {