9f30915f6f
## Context Follow-up to #21228, which deprecated `isCustom` on object/field metadata but kept it exposed because the frontend still relied on it. This removes it from the GraphQL API and the frontend entirely. ## Implementation ### Server - Remove `isCustom` `@Field` from the `Object`, `Field`, and `MinimalObjectMetadata` GraphQL types - Remove the `isCustom` `@ResolveField` resolvers and the `isCustomLoader` dataloader (+ payload/interface) - Remove `isCustom` as an internal `@HideField()` on the Object/Field DTOs used by the i18n standard-override gate > Use an explicit isStandard instead (which is the correct gating) ### Frontend - Add `getIsMetadataItemCustom` helper + `useGetIsMetadataItemCustom` hook: an item is custom when `applicationId === currentWorkspace.workspaceCustomApplication.id` - Migrate all consumers off `objectMetadataItem.isCustom` / `fieldMetadataItem.isCustom`; `isRecordFieldReadOnly` now takes a precomputed `isFieldCustom` - Drop `isCustom` from the metadata fragment/mutations/minimal query, FE types, zod schemas, and mock generators; regenerate GraphQL types ## Notes - Breaking change on the (already-deprecated) `Object.isCustom` / `Field.isCustom` GraphQL fields and the `isCustom` filter - FE semantic is "belongs to the workspace custom app" (third-party-app objects/fields are treated as non-custom) - `isCustom` on IndexMetadata / View / Skill / Agent is a separate column and is untouched - Breaking changes on REST metadata API
116 lines
3.4 KiB
TypeScript
116 lines
3.4 KiB
TypeScript
import request from 'supertest';
|
|
|
|
import { WORKSPACE_MEMBER_DATA_SEED_IDS } from 'src/engine/workspace-manager/dev-seeder/data/constants/workspace-member-data-seeds.constant';
|
|
|
|
const client = request(`http://localhost:${APP_PORT}`);
|
|
|
|
const objectsQuery = {
|
|
query: `
|
|
query ObjectsI18n {
|
|
objects(paging: { first: 100 }) {
|
|
edges {
|
|
node {
|
|
nameSingular
|
|
labelSingular
|
|
labelPlural
|
|
description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
};
|
|
|
|
type ObjectNode = {
|
|
nameSingular: string;
|
|
labelSingular: string;
|
|
labelPlural: string;
|
|
description: string;
|
|
};
|
|
|
|
const updateWorkspaceMemberLocale = async (locale: string) => {
|
|
const response = await client
|
|
.post('/metadata')
|
|
.set('Authorization', `Bearer ${APPLE_JANE_ADMIN_ACCESS_TOKEN}`)
|
|
.send({
|
|
query: `
|
|
mutation UpdateWorkspaceMemberSettings(
|
|
$input: UpdateWorkspaceMemberSettingsInput!
|
|
) {
|
|
updateWorkspaceMemberSettings(input: $input)
|
|
}
|
|
`,
|
|
variables: {
|
|
input: {
|
|
workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
|
|
update: { locale },
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(response.body.errors).toBeUndefined();
|
|
expect(response.body.data.updateWorkspaceMemberSettings).toBe(true);
|
|
};
|
|
|
|
const queryMetadataObjects = () =>
|
|
client
|
|
.post('/metadata')
|
|
.set('Authorization', `Bearer ${APPLE_JANE_ADMIN_ACCESS_TOKEN}`)
|
|
.send(objectsQuery);
|
|
|
|
const findObjectByName = (
|
|
edges: Array<{ node: ObjectNode }>,
|
|
nameSingular: string,
|
|
): ObjectNode | undefined =>
|
|
edges.find((edge) => edge.node.nameSingular === nameSingular)?.node;
|
|
|
|
describe('object metadata i18n', () => {
|
|
afterAll(async () => {
|
|
await updateWorkspaceMemberLocale('en');
|
|
});
|
|
|
|
it('should return English labels when user locale is en', async () => {
|
|
const response = await queryMetadataObjects();
|
|
|
|
expect(response.body.data).toBeDefined();
|
|
expect(response.body.errors).toBeUndefined();
|
|
|
|
const edges = response.body.data.objects.edges;
|
|
const company = findObjectByName(edges, 'company');
|
|
|
|
expect(company).toBeDefined();
|
|
expect(company!.labelSingular).toBe('Company');
|
|
expect(company!.labelPlural).toBe('Companies');
|
|
expect(company!.description).toBe('A company');
|
|
});
|
|
|
|
it('should return French labels when user locale is fr-FR', async () => {
|
|
await updateWorkspaceMemberLocale('fr-FR');
|
|
|
|
const response = await queryMetadataObjects();
|
|
|
|
expect(response.body.data).toBeDefined();
|
|
expect(response.body.errors).toBeUndefined();
|
|
|
|
const edges = response.body.data.objects.edges;
|
|
const company = findObjectByName(edges, 'company');
|
|
const person = findObjectByName(edges, 'person');
|
|
const opportunity = findObjectByName(edges, 'opportunity');
|
|
|
|
expect(company).toBeDefined();
|
|
expect(company!.labelSingular).toBe('Entreprise');
|
|
expect(company!.labelPlural).toBe('Entreprises');
|
|
expect(company!.description).toBe('Une entreprise');
|
|
|
|
expect(person).toBeDefined();
|
|
expect(person!.labelSingular).toBe('Personne');
|
|
expect(person!.labelPlural).toBe('Personnes');
|
|
expect(person!.description).toBe('Une personne');
|
|
|
|
expect(opportunity).toBeDefined();
|
|
expect(opportunity!.labelSingular).toBe('Opportunité');
|
|
expect(opportunity!.labelPlural).toBe('Opportunités');
|
|
expect(opportunity!.description).toBe('Une opportunité');
|
|
});
|
|
});
|