@centreon/ui 23.10.22-MON-19195-save-dashboard-changes.8 → 23.10.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.22-MON-19195-save-dashboard-changes.8",
3
+ "version": "23.10.23",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -1,4 +1,4 @@
1
- import { ComponentStory } from '@storybook/react';
1
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Theme } from '@mui/material';
@@ -13,7 +13,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
13
13
  }
14
14
  }));
15
15
 
16
- const meta = {
16
+ export default {
17
17
  argTypes: {
18
18
  labelLoading: { control: 'text' },
19
19
  labelSave: { control: 'text' },
@@ -26,13 +26,8 @@ const meta = {
26
26
 
27
27
  component: ButtonSave,
28
28
 
29
- parameters: {
30
- chromatic: { delay: 300 }
31
- },
32
29
  title: 'Button/Save'
33
- };
34
-
35
- export default meta;
30
+ } as ComponentMeta<typeof ButtonSave>;
36
31
 
37
32
  const TemplateButtonSave: ComponentStory<typeof ButtonSave> = (args) => (
38
33
  <ButtonSave {...args} />
@@ -47,7 +42,7 @@ export const loading = (): JSX.Element => <ButtonSave loading />;
47
42
  export const succeeded = (): JSX.Element => <ButtonSave succeeded />;
48
43
 
49
44
  export const normalWithText = (): JSX.Element => (
50
- <ButtonSave labelSave="Save" size="medium" />
45
+ <ButtonSave labelSave="Save" />
51
46
  );
52
47
 
53
48
  export const largeWithText = (): JSX.Element => (
@@ -55,7 +50,7 @@ export const largeWithText = (): JSX.Element => (
55
50
  );
56
51
 
57
52
  export const loadingWithTextAndMediumSize = (): JSX.Element => (
58
- <ButtonSave loading labelLoading="Loading" size="medium" />
53
+ <ButtonSave loading labelLoading="Loading" />
59
54
  );
60
55
 
61
56
  export const succeededWithText = (): JSX.Element => (
@@ -64,8 +64,8 @@ const Button = ({
64
64
  type={type}
65
65
  variant={muiVariantMap[variant]}
66
66
  onClick={(e) => onClick?.(e)}
67
- {...MuiOverrideProps}
68
67
  {...attr}
68
+ {...MuiOverrideProps}
69
69
  >
70
70
  {children}
71
71
  </MuiButton>
@@ -1,4 +1,4 @@
1
1
  export type DashboardResource = {
2
- description?: string | null;
2
+ description?: string;
3
3
  name: string;
4
4
  };
@@ -11,8 +11,7 @@ import { useStyles } from './DashboardForm.styles';
11
11
  import {
12
12
  labelMustBeAtLeast,
13
13
  labelMustBeMost,
14
- labelRequired,
15
- labelCharacters
14
+ labelRequired
16
15
  } from './translatedLabels';
17
16
  import {
18
17
  DashboardFormActions,
@@ -44,7 +43,7 @@ const DashboardForm = ({
44
43
 
45
44
  const formProps = useMemo<FormProps<DashboardResource>>(
46
45
  () => ({
47
- initialValues: resource ?? { description: null, name: '' },
46
+ initialValues: resource ?? { name: '' },
48
47
  inputs: [
49
48
  {
50
49
  fieldName: 'name',
@@ -56,7 +55,7 @@ const DashboardForm = ({
56
55
  {
57
56
  fieldName: 'description',
58
57
  group: 'main',
59
- label: labels?.entity?.description || '',
58
+ label: labels?.entity?.description,
60
59
  text: {
61
60
  multilineRows: 3
62
61
  },
@@ -66,12 +65,9 @@ const DashboardForm = ({
66
65
  submit: (values, bag) => onSubmit?.(values, bag),
67
66
  validationSchema: Yup.object().shape({
68
67
  description: Yup.string()
69
- .label(labels?.entity?.description || '')
70
- .max(
71
- 180,
72
- (p) =>
73
- `${p.label} ${t(labelMustBeMost)} ${p.max} ${t(labelCharacters)}`
74
- )
68
+ .label(labels?.entity?.description)
69
+ .max(180, ({ max, label }) => t(labelMustBeMost, { label, max }))
70
+ .optional()
75
71
  .nullable(),
76
72
  name: Yup.string()
77
73
  .label(labels?.entity?.name)
@@ -3,4 +3,3 @@ export const labelMustBeMost = '{{label}} can be at most {{max}} characters';
3
3
  export const labelMustBeAtLeast =
4
4
  '{{label}} should be at least {{min}} characters long';
5
5
  export const labelRequired = 'Required';
6
- export const labelCharacters = 'characters';