@centreon/ui 23.10.22-MON-19195-save-dashboard-changes.2 → 23.10.22-MON-19195-save-dashboard-changes.3
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.
|
|
3
|
+
"version": "23.10.22-MON-19195-save-dashboard-changes.3",
|
|
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 {
|
|
1
|
+
import { 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
|
-
|
|
16
|
+
const meta = {
|
|
17
17
|
argTypes: {
|
|
18
18
|
labelLoading: { control: 'text' },
|
|
19
19
|
labelSave: { control: 'text' },
|
|
@@ -26,8 +26,13 @@ export default {
|
|
|
26
26
|
|
|
27
27
|
component: ButtonSave,
|
|
28
28
|
|
|
29
|
+
parameters: {
|
|
30
|
+
chromatic: { delay: 300 }
|
|
31
|
+
},
|
|
29
32
|
title: 'Button/Save'
|
|
30
|
-
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
31
36
|
|
|
32
37
|
const TemplateButtonSave: ComponentStory<typeof ButtonSave> = (args) => (
|
|
33
38
|
<ButtonSave {...args} />
|
|
@@ -42,7 +47,7 @@ export const loading = (): JSX.Element => <ButtonSave loading />;
|
|
|
42
47
|
export const succeeded = (): JSX.Element => <ButtonSave succeeded />;
|
|
43
48
|
|
|
44
49
|
export const normalWithText = (): JSX.Element => (
|
|
45
|
-
<ButtonSave labelSave="Save" />
|
|
50
|
+
<ButtonSave labelSave="Save" size="medium" />
|
|
46
51
|
);
|
|
47
52
|
|
|
48
53
|
export const largeWithText = (): JSX.Element => (
|
|
@@ -50,7 +55,7 @@ export const largeWithText = (): JSX.Element => (
|
|
|
50
55
|
);
|
|
51
56
|
|
|
52
57
|
export const loadingWithTextAndMediumSize = (): JSX.Element => (
|
|
53
|
-
<ButtonSave loading labelLoading="Loading" />
|
|
58
|
+
<ButtonSave loading labelLoading="Loading" size="medium" />
|
|
54
59
|
);
|
|
55
60
|
|
|
56
61
|
export const succeededWithText = (): JSX.Element => (
|
|
@@ -17,6 +17,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
|
|
|
17
17
|
|
|
18
18
|
interface Props extends Record<string, unknown> {
|
|
19
19
|
className?: string;
|
|
20
|
+
hasStartIcon?: boolean;
|
|
20
21
|
labelLoading?: string;
|
|
21
22
|
labelSave?: string;
|
|
22
23
|
labelSucceeded?: string;
|
|
@@ -45,6 +46,7 @@ const SaveButton = ({
|
|
|
45
46
|
labelSave = '',
|
|
46
47
|
size = 'small',
|
|
47
48
|
className,
|
|
49
|
+
hasStartIcon = true,
|
|
48
50
|
...rest
|
|
49
51
|
}: Props): JSX.Element => {
|
|
50
52
|
const { classes, cx } = useStyles();
|
|
@@ -70,9 +72,11 @@ const SaveButton = ({
|
|
|
70
72
|
data-testid={labelSave}
|
|
71
73
|
id={getNormalizedId(labelSave)}
|
|
72
74
|
loading={loading}
|
|
73
|
-
loadingPosition={labelLoading &&
|
|
75
|
+
loadingPosition={labelLoading && hasStartIcon ? 'start' : 'center'}
|
|
74
76
|
size={size}
|
|
75
|
-
startIcon={
|
|
77
|
+
startIcon={
|
|
78
|
+
hasStartIcon && <StartIcon startIconConfig={startIconConfig} />
|
|
79
|
+
}
|
|
76
80
|
variant="contained"
|
|
77
81
|
{...rest}
|
|
78
82
|
>
|
|
@@ -30,12 +30,6 @@ const ModalActions = ({
|
|
|
30
30
|
}: ModalActionsProps): ReactElement => {
|
|
31
31
|
const { classes } = useStyles();
|
|
32
32
|
|
|
33
|
-
const icon = isDanger
|
|
34
|
-
? {
|
|
35
|
-
startIcon: undefined
|
|
36
|
-
}
|
|
37
|
-
: null;
|
|
38
|
-
|
|
39
33
|
return (
|
|
40
34
|
<div className={classes.modalActions}>
|
|
41
35
|
{children || (
|
|
@@ -54,13 +48,12 @@ const ModalActions = ({
|
|
|
54
48
|
aria-label="confirm"
|
|
55
49
|
color={isDanger ? 'error' : 'primary'}
|
|
56
50
|
data-testid="confirm_confirmation"
|
|
51
|
+
hasStartIcon={!isDanger}
|
|
57
52
|
labelLoading={labels?.loading}
|
|
58
53
|
labelSave={labels?.confirm}
|
|
59
54
|
loading={isLoading}
|
|
60
|
-
size="small"
|
|
61
55
|
type="submit"
|
|
62
56
|
onClick={() => onConfirm?.()}
|
|
63
|
-
{...icon}
|
|
64
57
|
/>
|
|
65
58
|
</>
|
|
66
59
|
)}
|