Files
twenty/packages/twenty-front/src/modules/settings/data-model/validation-schemas/settingsDataModelObjectAboutFormSchema.ts
T
Raphaël Bosi 9c9c34fccf Remove twenty-ui-deprecated and migrate frontend to twenty-ui (#21596)
Migrates `twenty-front`, `twenty-sdk`, and
`twenty-front-component-renderer` from `twenty-ui-deprecated` to
`twenty-ui` (mechanical import swap — the packages have API parity) and
deletes the deprecated package along with its workspace/CI/config
wiring.

Also adds `@linaria/react`/`@linaria/core` as direct deps of
`twenty-front` (it used them transitively via the deprecated package).

Note: move the required status check from `ci-ui-status-check` to
`ci-new-ui-status-check`.

Argos: the Storybook box-model/button-reset baseline shift (the bulk of
the visual diffs) is isolated in #21665 — Storybook now loads
twenty-ui's global `reset.scss`, which the production app already ships.
Once #21665 merges and this branch is rebased, the remaining Argos diffs
are component-level visual-parity items only.
2026-06-17 09:41:11 +00:00

57 lines
1.9 KiB
TypeScript

import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { t } from '@lingui/core/macro';
import { themeColorSchema } from 'twenty-ui/utilities';
import { type ZodType, z } from 'zod';
import { type ReadonlyKeysArray } from '~/types/ReadonlyKeysArray';
import { zodNonEmptyString } from '~/types/ZodNonEmptyString';
import { camelCaseStringSchema } from '~/utils/validation-schemas/camelCaseStringSchema';
type ZodTypeSettingsDataModelFormFields = ZodType<
Pick<
EnrichedObjectMetadataItem,
| 'color'
| 'labelSingular'
| 'labelPlural'
| 'description'
| 'icon'
| 'namePlural'
| 'nameSingular'
| 'isLabelSyncedWithName'
> & { skipNameField?: boolean }
>;
const settingsDataModelFormFieldsSchema = z.object({
color: themeColorSchema.optional(),
description: z.string().nullish(),
icon: z.string().optional(),
labelSingular: zodNonEmptyString,
labelPlural: zodNonEmptyString,
namePlural: zodNonEmptyString.and(camelCaseStringSchema),
nameSingular: zodNonEmptyString.and(camelCaseStringSchema),
isLabelSyncedWithName: z.boolean(),
skipNameField: z.boolean().optional(),
}) satisfies ZodTypeSettingsDataModelFormFields;
export const settingsDataModelObjectAboutFormSchema =
settingsDataModelFormFieldsSchema.superRefine(
({ namePlural, nameSingular }, ctx) => {
const nameAreDifferent =
nameSingular.toLowerCase() !== namePlural.toLowerCase();
if (!nameAreDifferent) {
const nameFields: ReadonlyKeysArray<EnrichedObjectMetadataItem> = [
'nameSingular',
'namePlural',
];
nameFields.forEach((field) =>
ctx.addIssue({
code: 'custom',
message: t`Singular and plural names must be different`,
path: [field],
}),
);
}
},
);
export type SettingsDataModelObjectAboutFormValues = z.infer<
typeof settingsDataModelObjectAboutFormSchema
>;