@centreon/ui 24.4.11 → 24.4.12
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 +1 -1
- package/src/ThemeProvider/index.tsx +24 -0
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
- package/src/components/Layout/PageLayout/index.ts +3 -1
- package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
package/package.json
CHANGED
|
@@ -147,6 +147,30 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
|
|
|
147
147
|
},
|
|
148
148
|
MuiCssBaseline: {
|
|
149
149
|
styleOverrides: (theme) => `
|
|
150
|
+
::-webkit-scrollbar {
|
|
151
|
+
height: ${theme.spacing(1)};
|
|
152
|
+
width: ${theme.spacing(1)};
|
|
153
|
+
background-color: transparent;
|
|
154
|
+
}
|
|
155
|
+
::-webkit-scrollbar-thumb {
|
|
156
|
+
background-color: ${
|
|
157
|
+
equals(mode, 'dark')
|
|
158
|
+
? theme.palette.divider
|
|
159
|
+
: theme.palette.text.disabled
|
|
160
|
+
};
|
|
161
|
+
border-radius: ${theme.spacing(0.5)};
|
|
162
|
+
}
|
|
163
|
+
::-webkit-scrollbar-thumb:hover {
|
|
164
|
+
background-color: ${theme.palette.primary.main};
|
|
165
|
+
}
|
|
166
|
+
* {
|
|
167
|
+
scrollbar-color: ${
|
|
168
|
+
equals(mode, 'dark')
|
|
169
|
+
? theme.palette.divider
|
|
170
|
+
: theme.palette.text.disabled
|
|
171
|
+
} ${theme.palette.background.default};
|
|
172
|
+
scrollbar-width: thin;
|
|
173
|
+
}
|
|
150
174
|
html {
|
|
151
175
|
margin: 0;
|
|
152
176
|
padding: 0;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IconButton as MuiIconButton,
|
|
5
|
+
IconButtonProps as MuiIconButtonProps
|
|
6
|
+
} from '@mui/material';
|
|
4
7
|
|
|
5
8
|
import { AriaLabelingAttributes } from '../../../@types/aria-attributes';
|
|
6
9
|
import { DataTestAttributes } from '../../../@types/data-attributes';
|
|
@@ -23,7 +26,8 @@ type IconButtonProps = {
|
|
|
23
26
|
size?: 'small' | 'medium' | 'large';
|
|
24
27
|
variant?: 'primary' | 'secondary' | 'ghost';
|
|
25
28
|
} & AriaLabelingAttributes &
|
|
26
|
-
DataTestAttributes
|
|
29
|
+
DataTestAttributes &
|
|
30
|
+
MuiIconButtonProps;
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* @todo re-factor as `iconVariant: 'icon-only'` Button variant, and remove IconButton component (reason: code duplication)
|
|
@@ -11,5 +11,9 @@ export const PageLayoutHeader = ({
|
|
|
11
11
|
}: PageLayoutHeaderProps): JSX.Element => {
|
|
12
12
|
const { classes } = useStyles();
|
|
13
13
|
|
|
14
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
<header className={classes.pageLayoutHeader} id="header">
|
|
16
|
+
{children}
|
|
17
|
+
</header>
|
|
18
|
+
);
|
|
15
19
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next';
|
|
2
|
+
|
|
3
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
4
|
+
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
|
|
5
|
+
|
|
6
|
+
import { Button, Menu } from '../..';
|
|
7
|
+
|
|
8
|
+
interface NamedEntity {
|
|
9
|
+
id: number | string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
create: () => void;
|
|
15
|
+
elements: Array<NamedEntity>;
|
|
16
|
+
goBack: () => void;
|
|
17
|
+
isActive: (id: number | string) => boolean;
|
|
18
|
+
labels: {
|
|
19
|
+
create: string;
|
|
20
|
+
goBack: string;
|
|
21
|
+
};
|
|
22
|
+
navigateToElement: (id: number | string) => () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const PageQuickAccess = ({
|
|
26
|
+
elements,
|
|
27
|
+
isActive,
|
|
28
|
+
navigateToElement,
|
|
29
|
+
goBack,
|
|
30
|
+
create,
|
|
31
|
+
labels
|
|
32
|
+
}: Props): JSX.Element => {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Menu>
|
|
37
|
+
<Menu.Button data-testid="quickaccess" />
|
|
38
|
+
<Menu.Items>
|
|
39
|
+
{elements &&
|
|
40
|
+
elements.map((element) => (
|
|
41
|
+
<Menu.Item
|
|
42
|
+
key={`${element.id}`}
|
|
43
|
+
onClick={navigateToElement(element.id)}
|
|
44
|
+
{...(isActive(element.id) && {
|
|
45
|
+
isActive: true,
|
|
46
|
+
isDisabled: true
|
|
47
|
+
})}
|
|
48
|
+
>
|
|
49
|
+
{element.name}
|
|
50
|
+
</Menu.Item>
|
|
51
|
+
))}
|
|
52
|
+
<Menu.Divider key="divider" />
|
|
53
|
+
<Menu.Item key="create">
|
|
54
|
+
<>
|
|
55
|
+
<Button
|
|
56
|
+
icon={<ArrowBackIcon />}
|
|
57
|
+
iconVariant="start"
|
|
58
|
+
variant="ghost"
|
|
59
|
+
onClick={goBack}
|
|
60
|
+
>
|
|
61
|
+
{t(labels.goBack)}
|
|
62
|
+
</Button>
|
|
63
|
+
<Button
|
|
64
|
+
icon={<AddIcon />}
|
|
65
|
+
iconVariant="start"
|
|
66
|
+
variant="secondary"
|
|
67
|
+
onClick={create}
|
|
68
|
+
>
|
|
69
|
+
{t(labels.create)}
|
|
70
|
+
</Button>
|
|
71
|
+
</>
|
|
72
|
+
</Menu.Item>
|
|
73
|
+
</Menu.Items>
|
|
74
|
+
</Menu>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -2,9 +2,11 @@ import { PageLayout as PageLayoutRoot } from './PageLayout';
|
|
|
2
2
|
import { PageLayoutHeader } from './PageLayoutHeader';
|
|
3
3
|
import { PageLayoutBody } from './PageLayoutBody';
|
|
4
4
|
import { PageLayoutActions } from './PageLayoutActions';
|
|
5
|
+
import { PageQuickAccess } from './PageQuickAccess';
|
|
5
6
|
|
|
6
7
|
export const PageLayout = Object.assign(PageLayoutRoot, {
|
|
7
8
|
Actions: PageLayoutActions,
|
|
8
9
|
Body: PageLayoutBody,
|
|
9
|
-
Header: PageLayoutHeader
|
|
10
|
+
Header: PageLayoutHeader,
|
|
11
|
+
QuickAccess: PageQuickAccess
|
|
10
12
|
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { T } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import { PageHeader } from '..';
|
|
4
|
+
|
|
5
|
+
import { AreaIndicator } from './AreaIndicator';
|
|
6
|
+
|
|
7
|
+
import { PageLayout } from '.';
|
|
8
|
+
|
|
9
|
+
const initialize = (): void => {
|
|
10
|
+
cy.mount({
|
|
11
|
+
Component: (
|
|
12
|
+
<PageLayout>
|
|
13
|
+
<PageLayout.Header>
|
|
14
|
+
<PageHeader>
|
|
15
|
+
<PageHeader.Menu>
|
|
16
|
+
<PageLayout.QuickAccess
|
|
17
|
+
create={cy.stub()}
|
|
18
|
+
elements={[
|
|
19
|
+
{
|
|
20
|
+
id: 1,
|
|
21
|
+
name: 'Entity'
|
|
22
|
+
}
|
|
23
|
+
]}
|
|
24
|
+
goBack={cy.stub()}
|
|
25
|
+
isActive={T}
|
|
26
|
+
labels={{
|
|
27
|
+
create: 'Create',
|
|
28
|
+
goBack: 'Go back'
|
|
29
|
+
}}
|
|
30
|
+
navigateToElement={cy.stub()}
|
|
31
|
+
/>
|
|
32
|
+
</PageHeader.Menu>
|
|
33
|
+
<PageHeader.Main>
|
|
34
|
+
<PageHeader.Title description="Description" title="Title" />
|
|
35
|
+
</PageHeader.Main>
|
|
36
|
+
<PageHeader.Actions>Actions</PageHeader.Actions>
|
|
37
|
+
</PageHeader>
|
|
38
|
+
</PageLayout.Header>
|
|
39
|
+
<PageLayout.Body>
|
|
40
|
+
<PageLayout.Actions>
|
|
41
|
+
<AreaIndicator name="Body actions" />
|
|
42
|
+
</PageLayout.Actions>
|
|
43
|
+
<h1>Content</h1>
|
|
44
|
+
</PageLayout.Body>
|
|
45
|
+
</PageLayout>
|
|
46
|
+
)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe('Page layout', () => {
|
|
51
|
+
beforeEach(initialize);
|
|
52
|
+
|
|
53
|
+
it('displays the page layout', () => {
|
|
54
|
+
cy.makeSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('opens the quick access poppin when the corresponding logo is displayed', () => {
|
|
58
|
+
cy.findByTestId('quickaccess').click();
|
|
59
|
+
|
|
60
|
+
cy.contains('Entity').should('be.visible');
|
|
61
|
+
cy.contains('Create').should('be.visible');
|
|
62
|
+
cy.contains('Go back').should('be.visible');
|
|
63
|
+
|
|
64
|
+
cy.makeSnapshot();
|
|
65
|
+
});
|
|
66
|
+
});
|