Add color to object icon picker in data model (#19368)
Closes [#2291](https://github.com/twentyhq/core-team-issues/issues/2291)
This commit is contained in:
+39
@@ -1,5 +1,44 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`settingsDataModelObjectAboutFormSchema fails when color is not a valid theme color 1`] = `
|
||||
[ZodError: [
|
||||
{
|
||||
"code": "invalid_value",
|
||||
"values": [
|
||||
"red",
|
||||
"ruby",
|
||||
"crimson",
|
||||
"tomato",
|
||||
"orange",
|
||||
"amber",
|
||||
"yellow",
|
||||
"lime",
|
||||
"grass",
|
||||
"green",
|
||||
"jade",
|
||||
"mint",
|
||||
"turquoise",
|
||||
"cyan",
|
||||
"sky",
|
||||
"blue",
|
||||
"iris",
|
||||
"violet",
|
||||
"purple",
|
||||
"plum",
|
||||
"pink",
|
||||
"bronze",
|
||||
"gold",
|
||||
"brown",
|
||||
"gray"
|
||||
],
|
||||
"path": [
|
||||
"color"
|
||||
],
|
||||
"message": "Invalid option: expected one of \\"red\\"|\\"ruby\\"|\\"crimson\\"|\\"tomato\\"|\\"orange\\"|\\"amber\\"|\\"yellow\\"|\\"lime\\"|\\"grass\\"|\\"green\\"|\\"jade\\"|\\"mint\\"|\\"turquoise\\"|\\"cyan\\"|\\"sky\\"|\\"blue\\"|\\"iris\\"|\\"violet\\"|\\"purple\\"|\\"plum\\"|\\"pink\\"|\\"bronze\\"|\\"gold\\"|\\"brown\\"|\\"gray\\""
|
||||
}
|
||||
]]
|
||||
`;
|
||||
|
||||
exports[`settingsDataModelObjectAboutFormSchema fails when isLabelSyncedWithName is not a boolean 1`] = `
|
||||
[ZodError: [
|
||||
{
|
||||
|
||||
+11
@@ -6,6 +6,7 @@ import { type EachTestingContext } from 'twenty-shared/testing';
|
||||
|
||||
describe('settingsDataModelObjectAboutFormSchema', () => {
|
||||
const validInput: SettingsDataModelObjectAboutFormValues = {
|
||||
color: 'gray',
|
||||
description: 'A valid description',
|
||||
icon: 'IconName',
|
||||
labelPlural: 'Labels Plural',
|
||||
@@ -148,6 +149,16 @@ describe('settingsDataModelObjectAboutFormSchema', () => {
|
||||
expectedSuccess: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'fails when color is not a valid theme color',
|
||||
context: {
|
||||
input: {
|
||||
...validInput,
|
||||
color: 'not-a-color',
|
||||
},
|
||||
expectedSuccess: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
test.each([...passingTestsUseCase, ...failsValidationTestsUseCase])(
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
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';
|
||||
@@ -8,6 +9,7 @@ import { camelCaseStringSchema } from '~/utils/validation-schemas/camelCaseStrin
|
||||
type ZodTypeSettingsDataModelFormFields = ZodType<
|
||||
Pick<
|
||||
EnrichedObjectMetadataItem,
|
||||
| 'color'
|
||||
| 'labelSingular'
|
||||
| 'labelPlural'
|
||||
| 'description'
|
||||
@@ -18,6 +20,7 @@ type ZodTypeSettingsDataModelFormFields = ZodType<
|
||||
> & { skipNameField?: boolean }
|
||||
>;
|
||||
const settingsDataModelFormFieldsSchema = z.object({
|
||||
color: themeColorSchema.optional(),
|
||||
description: z.string().nullish(),
|
||||
icon: z.string().optional(),
|
||||
labelSingular: zodNonEmptyString,
|
||||
|
||||
Reference in New Issue
Block a user