mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Merge branch 'main' into fix/transfer-timeout-error
This commit is contained in:
commit
65afa72d30
@ -216,6 +216,10 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
||||
schema = yup
|
||||
.mixed(errorsTrads.json)
|
||||
.test('isJSON', errorsTrads.json, (value) => {
|
||||
if (!value || !value.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
JSON.parse(value);
|
||||
|
||||
@ -226,7 +230,9 @@ const createYupSchemaAttribute = (type, validations, options) => {
|
||||
})
|
||||
.nullable()
|
||||
.test('required', errorsTrads.required, (value) => {
|
||||
if (validations.required && !value.length) return false;
|
||||
if (validations.required && (!value || !value.length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
@ -5,14 +5,6 @@ const createDefaultForm = (attributes, allComponentsSchema) => {
|
||||
const attribute = get(attributes, [current], {});
|
||||
const { default: defaultValue, component, type, required, min, repeatable } = attribute;
|
||||
|
||||
if (type === 'json') {
|
||||
acc[current] = null;
|
||||
}
|
||||
|
||||
if (type === 'json' && required === true) {
|
||||
acc[current] = {};
|
||||
}
|
||||
|
||||
if (defaultValue !== undefined) {
|
||||
acc[current] = defaultValue;
|
||||
}
|
||||
|
||||
@ -11,11 +11,6 @@ describe('CONTENT MANAGER | utils | createDefaultForm', () => {
|
||||
expect(createDefaultForm(attributes, {})).toEqual({});
|
||||
});
|
||||
|
||||
it('should set the json type with the correct value', () => {
|
||||
expect(createDefaultForm({ test: { type: 'json' } }, {})).toEqual({ test: null });
|
||||
expect(createDefaultForm({ test: { type: 'json', required: true } }, {})).toEqual({ test: {} });
|
||||
});
|
||||
|
||||
it('should init the requide dynamic zone type with an empty array', () => {
|
||||
expect(createDefaultForm({ test: { type: 'dynamiczone', required: true } })).toEqual({
|
||||
test: [],
|
||||
|
||||
@ -69,6 +69,7 @@ const FormHead = ({
|
||||
})}
|
||||
</Link>
|
||||
}
|
||||
ellipsis
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@ -63,8 +63,8 @@ const Table = ({
|
||||
condition: canUpdate,
|
||||
})}
|
||||
>
|
||||
<Td>
|
||||
<Typography textColor="neutral800" fontWeight="bold">
|
||||
<Td maxWidth={pxToRem(250)}>
|
||||
<Typography textColor="neutral800" fontWeight="bold" ellipsis>
|
||||
{token.name}
|
||||
</Typography>
|
||||
</Td>
|
||||
|
||||
@ -275,6 +275,10 @@ exports[`ADMIN | Pages | API TOKENS | EditView renders and matches the snapshot
|
||||
font-weight: 600;
|
||||
font-size: 2rem;
|
||||
line-height: 1.25;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #32324d;
|
||||
}
|
||||
|
||||
@ -1824,6 +1828,10 @@ exports[`ADMIN | Pages | API TOKENS | EditView renders and matches the snapshot
|
||||
font-weight: 600;
|
||||
font-size: 2rem;
|
||||
line-height: 1.25;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #32324d;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string(translatedErrors.string).required(translatedErrors.required),
|
||||
name: yup.string(translatedErrors.string).max(100).required(translatedErrors.required),
|
||||
type: yup
|
||||
.string(translatedErrors.string)
|
||||
.oneOf(['read-only', 'full-access', 'custom'])
|
||||
|
||||
@ -158,7 +158,7 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.c36 {
|
||||
.c35 {
|
||||
max-width: 15.625rem;
|
||||
}
|
||||
|
||||
@ -255,9 +255,13 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
||||
color: #666687;
|
||||
}
|
||||
|
||||
.c35 {
|
||||
.c36 {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.43;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
color: #32324d;
|
||||
}
|
||||
@ -919,19 +923,19 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
||||
>
|
||||
<td
|
||||
aria-colindex="1"
|
||||
class="c25"
|
||||
class="c35 c25"
|
||||
role="gridcell"
|
||||
tabindex="-1"
|
||||
>
|
||||
<span
|
||||
class="c5 c35"
|
||||
class="c5 c36"
|
||||
>
|
||||
My super token
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
aria-colindex="2"
|
||||
class="c36 c25"
|
||||
class="c35 c25"
|
||||
role="gridcell"
|
||||
tabindex="-1"
|
||||
>
|
||||
|
||||
@ -148,6 +148,10 @@ exports[`ADMIN | Pages | TRANSFER TOKENS | EditView renders and matches the snap
|
||||
font-weight: 600;
|
||||
font-size: 2rem;
|
||||
line-height: 1.25;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #32324d;
|
||||
}
|
||||
|
||||
@ -1121,6 +1125,10 @@ exports[`ADMIN | Pages | TRANSFER TOKENS | EditView renders and matches the snap
|
||||
font-weight: 600;
|
||||
font-size: 2rem;
|
||||
line-height: 1.25;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #32324d;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string(translatedErrors.string).required(translatedErrors.required),
|
||||
name: yup.string(translatedErrors.string).max(100).required(translatedErrors.required),
|
||||
description: yup.string().nullable(),
|
||||
lifespan: yup.number().integer().min(0).nullable().defined(translatedErrors.required),
|
||||
});
|
||||
|
||||
@ -158,7 +158,7 @@ describe('ADMIN | Pages | TRANSFER TOKENS | ListPage', () => {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.c36 {
|
||||
.c35 {
|
||||
max-width: 15.625rem;
|
||||
}
|
||||
|
||||
@ -255,9 +255,13 @@ describe('ADMIN | Pages | TRANSFER TOKENS | ListPage', () => {
|
||||
color: #666687;
|
||||
}
|
||||
|
||||
.c35 {
|
||||
.c36 {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.43;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
color: #32324d;
|
||||
}
|
||||
@ -919,19 +923,19 @@ describe('ADMIN | Pages | TRANSFER TOKENS | ListPage', () => {
|
||||
>
|
||||
<td
|
||||
aria-colindex="1"
|
||||
class="c25"
|
||||
class="c35 c25"
|
||||
role="gridcell"
|
||||
tabindex="-1"
|
||||
>
|
||||
<span
|
||||
class="c5 c35"
|
||||
class="c5 c36"
|
||||
>
|
||||
My super token
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
aria-colindex="2"
|
||||
class="c36 c25"
|
||||
class="c35 c25"
|
||||
role="gridcell"
|
||||
tabindex="-1"
|
||||
>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,7 @@ const formatAttribute = (key, attribute) => {
|
||||
multiple: !!attribute.multiple,
|
||||
required: !!required,
|
||||
configurable: configurable === false ? false : undefined,
|
||||
private: !!attribute.private,
|
||||
allowedTypes: attribute.allowedTypes,
|
||||
pluginOptions,
|
||||
};
|
||||
|
||||
@ -4,20 +4,20 @@ import { useState } from 'react';
|
||||
import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
|
||||
import DateTimePicker from './index';
|
||||
|
||||
<Meta
|
||||
title="components/DateTimePicker"
|
||||
<Meta
|
||||
title="components/DateTimePicker"
|
||||
component={DateTimePicker}
|
||||
argTypes={{
|
||||
label: {
|
||||
control: {
|
||||
type: 'text'
|
||||
}
|
||||
control: {
|
||||
type: 'text',
|
||||
},
|
||||
},
|
||||
value: {
|
||||
control: {
|
||||
type: 'date'
|
||||
}
|
||||
}
|
||||
type: 'date',
|
||||
},
|
||||
},
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -37,7 +37,7 @@ Description...
|
||||
<DateTimePicker
|
||||
onClear={() => setValue(undefined)}
|
||||
value={value}
|
||||
onChange={e => setValue(e)}
|
||||
onChange={(e) => setValue(e)}
|
||||
label="Date time picker"
|
||||
hint="This is a super description"
|
||||
/>
|
||||
@ -53,6 +53,7 @@ Description...
|
||||
<Canvas>
|
||||
<Story name="error">
|
||||
<DateTimePicker
|
||||
label="Date time picker"
|
||||
hint="This is a super description"
|
||||
error="Very very very very very very very long error"
|
||||
/>
|
||||
|
||||
@ -4,6 +4,7 @@ import { useEffect, useState, useRef } from 'react';
|
||||
import { Meta, ArgsTable, Canvas, Story } from '@storybook/addon-docs';
|
||||
import { Button, Box, Main, Flex } from '@strapi/design-system';
|
||||
import useQueryParams from '../../hooks/useQueryParams';
|
||||
import useTracking from '../../hooks/useTracking';
|
||||
import FilterListURLQuery from '../FilterListURLQuery';
|
||||
import FilterPopoverURLQuery from './index';
|
||||
|
||||
@ -51,6 +52,7 @@ import { FilterListURLQuery } from '@strapi/helper-plugin';
|
||||
metadatas: { label: 'city' },
|
||||
},
|
||||
];
|
||||
const { trackUsage } = useTracking();
|
||||
return (
|
||||
<Main>
|
||||
<Flex direction="column" alignItems="stretch" gap={6}>
|
||||
|
||||
@ -142,11 +142,12 @@ const GenericInput = ({
|
||||
labelAction={labelAction}
|
||||
value={value}
|
||||
error={errorMessage}
|
||||
disabled={disabled}
|
||||
hint={hint}
|
||||
required={required}
|
||||
onChange={(json) => {
|
||||
// Default to null when the field is not required and there is no input value
|
||||
const value = !attribute.required && !json.length ? 'null' : json;
|
||||
const value = !attribute.required && !json.length ? null : json;
|
||||
onChange({ target: { name, value } });
|
||||
}}
|
||||
minHeight={pxToRem(252)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user