2282 Rename components to use the new naming convention part 3 (#2296)

part 3 of the renaming
This commit is contained in:
bosiraphael 2023-10-31 12:38:53 +01:00 committed by GitHub
parent adeaa35e8d
commit a2e84db049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 604 additions and 564 deletions

View File

@ -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 && <MetadataObjectNavItems />}
{isFlexibleBackendEnabled && <ObjectMetadataNavItems />}
</MainNavbar>
) : (
<SettingsNavbar />

View File

@ -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] ?? {};

View File

@ -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<CreateOneMetadataObjectMutation, CreateOneMetadataObjectMutationVariables>;
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<CreateOneObjectMetadataItemMutation, CreateOneObjectMetadataItemMutationVariables>;
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<CreateOneMetadataFieldMutation, CreateOneMetadataFieldMutationVariables>;
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<UpdateOneMetadataFieldMutation, UpdateOneMetadataFieldMutationVariables>;
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<UpdateOneMetadataObjectMutation, UpdateOneMetadataObjectMutationVariables>;
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<DeleteOneMetadataObjectMutation, DeleteOneMetadataObjectMutationVariables>;
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<UpdateOneObjectMetadataItemMutation, UpdateOneObjectMetadataItemMutationVariables>;
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<DeleteOneObjectMetadataItemMutation, DeleteOneObjectMetadataItemMutationVariables>;
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<DeleteOneMetadataFieldMutation, DeleteOneMetadataFieldMutationVariables>;
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<MetadataObjectsQuery, MetadataObjectsQueryVariables>;
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<ObjectMetadataItemsQuery, ObjectMetadataItemsQueryVariables>;

View File

@ -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 (
<NavItem
key={metadataObject.id}
label={metadataObject.labelPlural}
to={`/objects/${metadataObject.namePlural}`}
Icon={metadataObject.icon ? icons[metadataObject.icon] : Icon123}
onClick={() => {
navigate(`/objects/${metadataObject.namePlural}`);
}}
/>
);
})}
</>
);
};

View File

@ -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 (
<NavItem
key={objectMetadataItem.id}
label={objectMetadataItem.labelPlural}
to={`/objects/${objectMetadataItem.namePlural}`}
Icon={
objectMetadataItem.icon
? icons[objectMetadataItem.icon]
: Icon123
}
onClick={() => {
navigate(`/objects/${objectMetadataItem.namePlural}`);
}}
/>
);
})}
</>
);
};

View File

@ -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,
]);

View File

@ -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"
/>
<PropertyBox extraPadding={true}>
{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,

View File

@ -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);

View File

@ -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 ?? [],
),
});

View File

@ -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}
>
<StyledTableContainer>
<MetadataObjectScope metadataObjectNamePlural={objectNamePlural}>
<ObjectMetadataItemScope
objectMetadataItemNamePlural={objectNamePlural}
>
<ObjectTable objectNamePlural={objectNamePlural} />
</MetadataObjectScope>
</ObjectMetadataItemScope>
</StyledTableContainer>
<RecordTableActionBar />
<RecordTableContextMenu />

View File

@ -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

View File

@ -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 {

View File

@ -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<MetadataObjectIdentifier, 'objectNamePlural'>) => {
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'>) => {
const {
foundMetadataObject,
foundObjectMetadataItem,
objectNotFoundInMetadata,
findManyQuery,
createOneMutation,
} = useFindOneMetadataObject({
} = useFindOneObjectMetadataItem({
objectNamePlural,
});
// TODO: type this with a minimal type at least with Record<string, any>
const [mutate] = useMutation(createOneMutation);
const createOneObject = foundMetadataObject
const createOneObject = foundObjectMetadataItem
? (input: Record<string, any>) => {
return mutate({
variables: {

View File

@ -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<any>),
});
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,
};
};

View File

@ -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<MetadataObjectIdentifier, 'objectNamePlural'>) => {
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'>) => {
const {
foundMetadataObject,
foundObjectMetadataItem,
objectNotFoundInMetadata,
findManyQuery,
deleteOneMutation,
} = useFindOneMetadataObject({
} = useFindOneObjectMetadataItem({
objectNamePlural,
});
// TODO: type this with a minimal type at least with Record<string, any>
const [mutate] = useMutation(deleteOneMutation);
const deleteOneObject = foundMetadataObject
const deleteOneObject = foundObjectMetadataItem
? (input: Record<string, any>) => {
return mutate({
variables: {

View File

@ -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<any>),
});
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,
};
};

View File

@ -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,
};

View File

@ -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<MetadataObjectsQuery, MetadataObjectsQueryVariables>(
} = useQuery<ObjectMetadataItemsQuery, ObjectMetadataItemsQueryVariables>(
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,

View File

@ -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<MetadataObjectIdentifier, 'objectNamePlural'> & {
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'> & {
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<PaginatedObjectType<ObjectType>>(
findManyQuery,
{
skip: !foundMetadataObject,
skip: !foundObjectMetadataItem,
variables: {
filter: filter ?? {},
orderBy: orderBy ?? {},

View File

@ -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<string, any>,
@ -10,12 +10,12 @@ export const useFindOneObject = <
objectNameSingular,
objectId,
onCompleted,
}: Pick<MetadataObjectIdentifier, 'objectNameSingular'> & {
}: Pick<ObjectMetadataItemIdentifier, 'objectNameSingular'> & {
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 ?? '',
},

View File

@ -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<FieldMetadata>[] =
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,

View File

@ -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,
};
};

View File

@ -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<MetadataObject, 'id'>) =>
updateOneMetadataObject({
idToUpdate: metadataObject.id,
updatePayload: { isActive: true },
});
const disableMetadataObject = (metadataObject: Pick<MetadataObject, 'id'>) =>
updateOneMetadataObject({
idToUpdate: metadataObject.id,
updatePayload: { isActive: false },
});
const eraseMetadataObject = (metadataObject: Pick<MetadataObject, 'id'>) =>
deleteOneMetadataObject(metadataObject.id);
return {
activateMetadataObject,
activeMetadataObjects,
createMetadataObject,
disabledMetadataObjects,
disableMetadataObject,
editMetadataObject,
eraseMetadataObject,
findActiveMetadataObjectBySlug,
loading,
};
};

View File

@ -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,
};
};

View File

@ -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,
};
};

View File

@ -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<ObjectMetadataItem, 'id'>,
) =>
updateOneObjectMetadataItem({
idToUpdate: objectMetadataItem.id,
updatePayload: { isActive: true },
});
const disableObjectMetadataItem = (
objectMetadataItem: Pick<ObjectMetadataItem, 'id'>,
) =>
updateOneObjectMetadataItem({
idToUpdate: objectMetadataItem.id,
updatePayload: { isActive: false },
});
const eraseObjectMetadataItem = (
objectMetadataItem: Pick<ObjectMetadataItem, 'id'>,
) => deleteOneObjectMetadataItem(objectMetadataItem.id);
return {
activateObjectMetadataItem,
activeObjectMetadataItems,
createObjectMetadataItem,
disabledObjectMetadataItems,
disableObjectMetadataItem,
editObjectMetadataItem,
eraseObjectMetadataItem,
findActiveObjectMetadataItemBySlug,
loading,
};
};

View File

@ -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,
};
};

View File

@ -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,

View File

@ -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,

View File

@ -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,
};
};

View File

@ -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 (
<MetadataObjectScopeInternalContext.Provider
value={{
scopeId: metadataObjectNamePlural,
objectNamePlural: metadataObjectNamePlural,
}}
>
{children}
</MetadataObjectScopeInternalContext.Provider>
);
};

View File

@ -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 (
<ObjectMetadataItemScopeInternalContext.Provider
value={{
scopeId: objectMetadataItemNamePlural,
objectNamePlural: objectMetadataItemNamePlural,
}}
>
{children}
</ObjectMetadataItemScopeInternalContext.Provider>
);
};

View File

@ -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<MetadataObjectScopeInternalContextProps>();
export const ObjectMetadataItemScopeInternalContext =
createScopeInternalContext<ObjectMetadataItemScopeInternalContextProps>();

View File

@ -1,11 +0,0 @@
import { atom } from 'recoil';
import { MetadataObject } from '../types/MetadataObject';
/**
* @deprecated Use `useFindManyMetadataObjects` instead.
*/
export const metadataObjectsState = atom<MetadataObject[]>({
key: 'metadataObjectsState',
default: [],
});

View File

@ -0,0 +1,11 @@
import { atom } from 'recoil';
import { ObjectMetadataItem } from '../types/ObjectMetadataItem';
/**
* @deprecated Use `useFindManyObjectMetadataItems` instead.
*/
export const objectMetadataItemsState = atom<ObjectMetadataItem[]>({
key: 'objectMetadataItemsState',
default: [],
});

View File

@ -1,10 +0,0 @@
import { selector } from 'recoil';
import { MetadataObject } from '../../types/MetadataObject';
import { metadataObjectsState } from '../metadataObjectsState';
export const activeMetadataObjectsSelector = selector<MetadataObject[]>({
key: 'activeMetadataObjectsSelector',
get: ({ get }) =>
get(metadataObjectsState).filter(({ isActive }) => isActive),
});

View File

@ -0,0 +1,12 @@
import { selector } from 'recoil';
import { ObjectMetadataItem } from '../../types/ObjectMetadataItem';
import { objectMetadataItemsState } from '../objectMetadataItemsState';
export const activeObjectMetadataItemsSelector = selector<ObjectMetadataItem[]>(
{
key: 'activeObjectMetadataItemsSelector',
get: ({ get }) =>
get(objectMetadataItemsState).filter(({ isActive }) => isActive),
},
);

View File

@ -1,10 +0,0 @@
import { selector } from 'recoil';
import { MetadataObject } from '../../types/MetadataObject';
import { metadataObjectsState } from '../metadataObjectsState';
export const disabledMetadataObjectsSelector = selector<MetadataObject[]>({
key: 'disabledMetadataObjectsSelector',
get: ({ get }) =>
get(metadataObjectsState).filter(({ isActive }) => !isActive),
});

View File

@ -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),
});

View File

@ -1,6 +1,6 @@
import { Field, Object as GeneratedObject } from '~/generated-metadata/graphql';
export type MetadataObject = Omit<
export type ObjectMetadataItem = Omit<
GeneratedObject,
'fields' | 'dataSourceId'
> & {

View File

@ -1,4 +1,4 @@
export type MetadataObjectIdentifier = {
export type ObjectMetadataItemIdentifier = {
objectNamePlural?: string;
objectNameSingular?: string;
};

View File

@ -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<MetadataObject, 'fields'>;
field: ObjectMetadataItem['fields'][0];
objectMetadataItem: Omit<ObjectMetadataItem, 'fields'>;
icons: Record<string, any>;
}): ColumnDefinition<FieldMetadata> => ({
position,
@ -27,5 +27,5 @@ export const formatMetadataFieldAsColumnDefinition = ({
},
Icon: icons[field.icon ?? 'Icon123'],
isVisible: true,
basePathToShowPage: `/object/${metadataObject.nameSingular}/`,
basePathToShowPage: `/object/${objectMetadataItem.nameSingular}/`,
});

View File

@ -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<string, any>;
}): FilterDefinition => ({
fieldId: field.id,

View File

@ -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<string, any>;
}): SortDefinition => ({
fieldId: field.id,

View File

@ -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'
>,
) => ({

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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!) {

View File

@ -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!) {

View File

@ -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')}
}

View File

@ -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')}
}
}
`;

View File

@ -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!) {

View File

@ -1,7 +1,7 @@
import toKebabCase from 'lodash.kebabcase';
import { MetadataObject } from '../types/MetadataObject';
import { ObjectMetadataItem } from '../types/ObjectMetadataItem';
export const getObjectSlug = (
metadataObject: Pick<MetadataObject, 'labelPlural'>,
) => toKebabCase(metadataObject.labelPlural);
objectMetadataItem: Pick<ObjectMetadataItem, 'labelPlural'>,
) => toKebabCase(objectMetadataItem.labelPlural);

View File

@ -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;
};

View File

@ -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<string, boolean>) => void;
selectedIds: Record<string, boolean>;
};

View File

@ -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;
};

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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<NewObjectType>('Standard');
const {
activateMetadataObject: activateObject,
createMetadataObject: createObject,
disabledMetadataObjects: disabledObjects,
} = useMetadataObjectForSettings();
activateObjectMetadataItem: activateObject,
createObjectMetadataItem: createObject,
disabledObjectMetadataItems: disabledObjects,
} = useObjectMetadataItemForSettings();
const { createOneObject: createOneView } = useCreateOneObject({
objectNamePlural: 'viewsV2',

View File

@ -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 = () => {
<Breadcrumb
links={[
{ children: 'Objects', href: '/settings/objects' },
{ children: activeMetadataObject.labelPlural },
{ children: activeObjectMetadataItem.labelPlural },
]}
/>
<SettingsAboutSection
iconKey={activeMetadataObject.icon ?? undefined}
name={activeMetadataObject.labelPlural || ''}
isCustom={activeMetadataObject.isCustom}
iconKey={activeObjectMetadataItem.icon ?? undefined}
name={activeObjectMetadataItem.labelPlural || ''}
isCustom={activeObjectMetadataItem.isCustom}
onDisable={handleDisable}
onEdit={() => navigate('./edit')}
/>
<Section>
<H2Title
title="Fields"
description={`Customise the fields available in the ${activeMetadataObject.labelSingular} views and their display order in the ${activeMetadataObject.labelSingular} detail view and menus.`}
description={`Customise the fields available in the ${activeObjectMetadataItem.labelSingular} views and their display order in the ${activeObjectMetadataItem.labelSingular} detail view and menus.`}
/>
<Table>
<StyledObjectFieldTableRow>

View File

@ -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 && (
<SaveAndCancelButtons
isSaveDisabled={!canSave}
onCancel={() => navigate(`/settings/objects/${objectSlug}`)}
@ -105,7 +109,7 @@ export const SettingsObjectEdit = () => {
)}
</SettingsHeaderContainer>
<SettingsObjectIconSection
disabled={!activeMetadataObject.isCustom}
disabled={!activeObjectMetadataItem.isCustom}
iconKey={formValues.icon}
label={formValues.labelPlural}
onChange={({ iconKey }) =>
@ -116,7 +120,7 @@ export const SettingsObjectEdit = () => {
}
/>
<SettingsObjectFormSection
disabled={!activeMetadataObject.isCustom}
disabled={!activeObjectMetadataItem.isCustom}
singularName={formValues.labelSingular}
pluralName={formValues.labelPlural}
description={formValues.description}

View File

@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
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 { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
@ -22,13 +22,14 @@ export const SettingsObjectFieldEdit = () => {
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 },

View File

@ -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' },

View File

@ -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<View>) => {
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' },

View File

@ -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 (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
@ -66,12 +66,12 @@ export const SettingsObjects = () => {
<TableHeader align="right">Instances</TableHeader>
<TableHeader></TableHeader>
</StyledObjectTableRow>
{!!activeMetadataObjects.length && (
{!!activeObjectMetadataItems.length && (
<TableSection title="Active">
{activeMetadataObjects.map((activeMetadataObject) => (
{activeObjectMetadataItems.map((activeObjectMetadataItem) => (
<SettingsObjectItemTableRow
key={activeMetadataObject.namePlural}
objectItem={activeMetadataObject}
key={activeObjectMetadataItem.namePlural}
objectItem={activeObjectMetadataItem}
action={
<StyledIconChevronRight
size={theme.icon.size.md}
@ -81,7 +81,7 @@ export const SettingsObjects = () => {
onClick={() =>
navigate(
`/settings/objects/${getObjectSlug(
activeMetadataObject,
activeObjectMetadataItem,
)}`,
)
}
@ -89,26 +89,32 @@ export const SettingsObjects = () => {
))}
</TableSection>
)}
{!!disabledMetadataObjects.length && (
{!!disabledObjectMetadataItems.length && (
<TableSection title="Disabled">
{disabledMetadataObjects.map((disabledMetadataObject) => (
<SettingsObjectItemTableRow
key={disabledMetadataObject.namePlural}
objectItem={disabledMetadataObject}
action={
<SettingsObjectDisabledMenuDropDown
isCustomObject={disabledMetadataObject.isCustom}
scopeKey={disabledMetadataObject.namePlural}
onActivate={() =>
activateMetadataObject(disabledMetadataObject)
}
onErase={() =>
eraseMetadataObject(disabledMetadataObject)
}
/>
}
/>
))}
{disabledObjectMetadataItems.map(
(disabledObjectMetadataItem) => (
<SettingsObjectItemTableRow
key={disabledObjectMetadataItem.namePlural}
objectItem={disabledObjectMetadataItem}
action={
<SettingsObjectDisabledMenuDropDown
isCustomObject={disabledObjectMetadataItem.isCustom}
scopeKey={disabledObjectMetadataItem.namePlural}
onActivate={() =>
activateObjectMetadataItem(
disabledObjectMetadataItem,
)
}
onErase={() =>
eraseObjectMetadataItem(
disabledObjectMetadataItem,
)
}
/>
}
/>
),
)}
</TableSection>
)}
</Table>

View File

@ -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 }));
},
),
];

View File

@ -1,4 +1,4 @@
export const mockedMetadataObjects = {
export const mockedObjectMetadataItems = {
edges: [
{
node: {