@centreon/ui 23.10.2 → 23.10.3-0

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.
Files changed (54) hide show
  1. package/README.md +44 -14
  2. package/package.json +41 -23
  3. package/public/README.md +39 -0
  4. package/src/@assets/README.md +5 -0
  5. package/src/@assets/brand/centreon-logo-one-line-dark.svg +1 -0
  6. package/src/@assets/brand/centreon-logo-one-line-light.svg +1 -0
  7. package/src/@types/globals.d.ts +9 -0
  8. package/src/@types/vite-env.d.ts +2 -0
  9. package/src/Dialog/Duplicate/index.test.tsx +1 -1
  10. package/src/FallbackPage/FallbackPage.tsx +2 -2
  11. package/src/Home.stories.mdx +1 -84
  12. package/src/Image/index.stories.tsx +2 -2
  13. package/src/Image/index.test.tsx +3 -3
  14. package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +1 -1
  15. package/src/InputField/Select/Autocomplete/Connected/index.stories.tsx +0 -3
  16. package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +1 -1
  17. package/src/InputField/Select/Autocomplete/Draggable/index.stories.tsx +0 -2
  18. package/src/Listing/index.test.tsx +1 -1
  19. package/src/Logo/CentreonLogo.tsx +2 -2
  20. package/src/Module/LicensedModule/LicenseCheck/index.stories.tsx +0 -2
  21. package/src/Panel/Section/index.test.tsx +1 -1
  22. package/src/ThemeProvider/index.tsx +30 -1
  23. package/src/WallpaperPage/index.stories.tsx +1 -1
  24. package/src/Wizard/ActionsBar.test.tsx +1 -1
  25. package/src/Wizard/index.test.tsx +1 -1
  26. package/.storybook/main.js +0 -82
  27. package/.storybook/preview.tsx +0 -21
  28. package/cypress/support/commands.ts +0 -19
  29. package/cypress/support/component-index.html +0 -12
  30. package/cypress/support/component.tsx +0 -5
  31. package/cypress.config.ts +0 -5
  32. package/jest.config.js +0 -20
  33. package/setupTests.js +0 -86
  34. package/src/storyshots.test.js +0 -52
  35. package/src/testRenderer.tsx +0 -56
  36. package/testRunner.js +0 -36
  37. package/tsconfig.json +0 -29
  38. package/types/declarations.d.ts +0 -9
  39. /package/{assets → public/brand}/centreon-logo-one-line-dark.svg +0 -0
  40. /package/{assets → public/brand}/centreon-logo-one-line-light.svg +0 -0
  41. /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.ttf +0 -0
  42. /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.woff +0 -0
  43. /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.woff2 +0 -0
  44. /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.ttf +0 -0
  45. /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.woff +0 -0
  46. /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.woff2 +0 -0
  47. /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.ttf +0 -0
  48. /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.woff +0 -0
  49. /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.woff2 +0 -0
  50. /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.ttf +0 -0
  51. /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.woff +0 -0
  52. /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.woff2 +0 -0
  53. /package/{assets → src/@assets/images}/not-authorized-template-background-dark.svg +0 -0
  54. /package/{assets → src/@assets/images}/not-authorized-template-background-light.svg +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  resetMocks,
8
8
  mockResponse,
9
9
  getFetchCall
10
- } from '../../../../testRenderer';
10
+ } from '../../../../../test/testRenderer';
11
11
  import buildListingEndpoint from '../../../../api/buildListingEndpoint';
12
12
  import { ConditionsSearchParameter } from '../../../../api/buildListingEndpoint/models';
13
13
  import TestQueryProvider from '../../../../api/TestQueryProvider';
@@ -1,7 +1,6 @@
1
1
  import { useState } from 'react';
2
2
 
3
3
  import { isNil, not } from 'ramda';
4
- import withMock from 'storybook-addon-mock';
5
4
 
6
5
  import { Tooltip, Typography } from '@mui/material';
7
6
 
@@ -15,7 +14,6 @@ import MultiDraggableAutocompleteField from './Multi';
15
14
  import { ItemActionProps } from '.';
16
15
 
17
16
  export default {
18
- decorators: [withMock],
19
17
  title: 'InputField/Autocomplete/Draggable'
20
18
  };
21
19
 
@@ -2,7 +2,7 @@ import { useState } from 'react';
2
2
 
3
3
  import { prop } from 'ramda';
4
4
 
5
- import { render, fireEvent, within } from '../testRenderer';
5
+ import { render, fireEvent, within } from '../../test/testRenderer';
6
6
 
7
7
  import { ColumnType } from './models';
8
8
  import { labelAddColumns } from './translatedLabels';
@@ -6,8 +6,8 @@ import { makeStyles } from 'tss-react/mui';
6
6
  import { Image, ImageVariant } from '..';
7
7
  import LoadingSkeleton from '../LoadingSkeleton';
8
8
  import { useThemeMode } from '../utils/useThemeMode';
9
- import CentreonLogoLight from '../../assets/centreon-logo-one-line-light.svg';
10
- import CentreonLogoDark from '../../assets/centreon-logo-one-line-dark.svg';
9
+ import CentreonLogoLight from '../@assets/brand/centreon-logo-one-line-light.svg';
10
+ import CentreonLogoDark from '../@assets/brand/centreon-logo-one-line-dark.svg';
11
11
 
12
12
  import { labelCentreonLogo } from './translatedLabels';
13
13
 
@@ -1,5 +1,4 @@
1
1
  import { ComponentMeta, ComponentStory } from '@storybook/react';
2
- import withMock from 'storybook-addon-mock';
3
2
  import { makeStyles } from 'tss-react/mui';
4
3
 
5
4
  import { Alert, Container } from '@mui/material';
@@ -20,7 +19,6 @@ export default {
20
19
  moduleName: { control: 'text' }
21
20
  },
22
21
  component: LicenseCheck,
23
- decorators: [withMock],
24
22
  title: 'LicenseCheck'
25
23
  } as ComponentMeta<typeof LicenseCheck>;
26
24
 
@@ -1,4 +1,4 @@
1
- import { render, fireEvent } from '../../testRenderer';
1
+ import { render, fireEvent } from '../../../test/testRenderer';
2
2
 
3
3
  import SectionPanel from '.';
4
4
 
@@ -17,6 +17,10 @@ import { autocompleteClasses } from '@mui/material/Autocomplete';
17
17
  import { ThemeOptions } from '@mui/material/styles/createTheme';
18
18
 
19
19
  import { ThemeMode, userAtom } from '@centreon/ui-context';
20
+ import RobotoLightWoff2 from '@centreon/ui/fonts/roboto-light-webfont.woff2';
21
+ import RobotoRegularWoff2 from '@centreon/ui/fonts/roboto-regular-webfont.woff2';
22
+ import RobotoMediumWoff2 from '@centreon/ui/fonts/roboto-medium-webfont.woff2';
23
+ import RobotoBoldWoff2 from '@centreon/ui/fonts/roboto-bold-webfont.woff2';
20
24
 
21
25
  import { getPalette } from './palettes';
22
26
 
@@ -180,6 +184,30 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
180
184
  padding: 0;
181
185
  width: 100%;
182
186
  }
187
+ @font-face {
188
+ font-family: 'Roboto';
189
+ font-style: normal;
190
+ font-weight: 300;
191
+ src: local('Roboto'), local('Roboto-Light'), url(${RobotoLightWoff2}) format('woff2');
192
+ }
193
+ @font-face {
194
+ font-family: 'Roboto';
195
+ font-style: normal;
196
+ font-weight: 400;
197
+ src: local('Roboto'), local('Roboto-Regular'), url(${RobotoRegularWoff2}) format('woff2');
198
+ }
199
+ @font-face {
200
+ font-family: 'Roboto';
201
+ font-style: normal;
202
+ font-weight: 500;
203
+ src: local('Roboto'), local('Roboto-Medium'), url(${RobotoMediumWoff2}) format('woff2');
204
+ }
205
+ @font-face {
206
+ font-family: 'Roboto';
207
+ font-style: normal;
208
+ font-weight: 600;
209
+ src: local('Roboto'), local('Roboto-Bold'), url(${RobotoBoldWoff2}) format('woff2');
210
+ }
183
211
  `
184
212
  },
185
213
  MuiInputBase: {
@@ -253,7 +281,8 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
253
281
  },
254
282
  caption: {
255
283
  fontSize: '0.625rem'
256
- }
284
+ },
285
+ fontFamily: 'Roboto, Arial'
257
286
  }
258
287
  });
259
288
 
@@ -1,6 +1,6 @@
1
1
  import { ComponentMeta } from '@storybook/react';
2
2
 
3
- import image from '../../assets/not-authorized-template-background-light.svg';
3
+ import image from '../@assets/images/not-authorized-template-background-light.svg';
4
4
 
5
5
  import WallpaperPage from '.';
6
6
 
@@ -1,4 +1,4 @@
1
- import { render, screen, fireEvent } from '../testRenderer';
1
+ import { render, screen, fireEvent } from '../../test/testRenderer';
2
2
 
3
3
  import ActionsBar from './ActionsBar';
4
4
 
@@ -8,7 +8,7 @@ import {
8
8
  waitFor,
9
9
  screen,
10
10
  RenderResult
11
- } from '../testRenderer';
11
+ } from '../../test/testRenderer';
12
12
 
13
13
  import { StepComponentProps } from './models';
14
14
 
@@ -1,82 +0,0 @@
1
- const { equals } = require("ramda");
2
-
3
- const excludeNodeModulesExceptCentreonUi =
4
- /node_modules(\\|\/)(?!(centreon-frontend(\\|\/)packages(\\|\/)(ui-context|centreon-ui)))/;
5
-
6
- module.exports = {
7
- core: {
8
- builder: 'webpack5',
9
- },
10
- features: {
11
- previewMdx2: true,
12
- },
13
- stories: ['../src/*.stories.mdx', '../src/**/*.stories.@(jsx|tsx)'],
14
- typescript: {
15
- reactDocgen: 'react-docgen-typescript'
16
- },
17
- addons: [
18
- 'storybook-addon-mock/register',
19
- 'storybook-dark-mode',
20
- '@storybook/addon-controls',
21
- {
22
- name: '@storybook/addon-docs',
23
- options: {
24
- configureJSX: true,
25
- },
26
- },
27
- ],
28
- webpackFinal: (config) => {
29
- delete config.resolve.alias['emotion-theming'];
30
- delete config.resolve.alias['@emotion/styled'];
31
- delete config.resolve.alias['@emotion/core'];
32
-
33
- const configWithoutEmotionAliases = {
34
- ...config,
35
- resolve: {
36
- ...config.resolve,
37
- extensions: ['.js', '.ts', '.tsx'],
38
- },
39
- module: {
40
- ...config.module,
41
- rules: [
42
- {
43
- test: /\.tsx?$/,
44
- exclude: /node_modules(\\|\/)(?!(@centreon))/,
45
- use: {
46
- loader: 'swc-loader',
47
- options: {
48
- jsc: {
49
- transform: {
50
- react: {
51
- runtime: 'automatic',
52
- },
53
- },
54
- parser: {
55
- syntax: 'typescript',
56
- },
57
- },
58
- parseMap: true,
59
- },
60
- }
61
- },
62
- {
63
- exclude: excludeNodeModulesExceptCentreonUi,
64
- test: /\.(bmp|png|jpg|jpeg|gif|svg)$/,
65
- use: [
66
- {
67
- loader: 'url-loader',
68
- options: {
69
- limit: 10000,
70
- name: '[name].[hash:8].[ext]',
71
- },
72
- },
73
- ],
74
- },
75
- ...(config.module.rules.filter(({ type }) => !equals(type, 'asset/resource'))),
76
- ],
77
- },
78
- }
79
-
80
- return configWithoutEmotionAliases;
81
- }
82
- };
@@ -1,21 +0,0 @@
1
- import { addDecorator } from '@storybook/react';
2
-
3
- import { useDarkMode } from 'storybook-dark-mode';
4
-
5
- import { ThemeMode } from '@centreon/ui-context';
6
-
7
- import StoryBookThemeProvider from '../src/StoryBookThemeProvider';
8
- import QueryProvider from '../src/api/QueryProvider';
9
- import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
10
-
11
-
12
- const withThemeProvider = (story): JSX.Element => (
13
- <StoryBookThemeProvider themeMode={useDarkMode() ? ThemeMode.dark : ThemeMode.light}>
14
- <QueryProvider>
15
- {story()}
16
- <ReactQueryDevtools />
17
- </QueryProvider>
18
- </StoryBookThemeProvider>
19
- );
20
-
21
- addDecorator(withThemeProvider);
@@ -1,19 +0,0 @@
1
- import { mount } from 'cypress/react18';
2
- import '@testing-library/cypress/add-commands';
3
-
4
- Cypress.Commands.add('mount', ({ Component, options }: MountProps) => {
5
- return mount(Component, options);
6
- });
7
-
8
- interface MountProps {
9
- Component: JSX.Element;
10
- options?: object;
11
- }
12
-
13
- declare global {
14
- namespace Cypress {
15
- interface Chainable {
16
- mount: ({ Component, options = {} }: MountProps) => Cypress.Chainable;
17
- }
18
- }
19
- }
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
- <title>Components App</title>
8
- </head>
9
- <body>
10
- <div data-cy-root></div>
11
- </body>
12
- </html>
@@ -1,5 +0,0 @@
1
- import './commands';
2
-
3
- import enableVisualTesting from '@centreon/js-config/cypress/component/enableVisualTesting';
4
-
5
- enableVisualTesting();
package/cypress.config.ts DELETED
@@ -1,5 +0,0 @@
1
- const defineCypressConfig = require('@centreon/js-config/cypress/component/configuration');
2
-
3
- module.exports = defineCypressConfig({
4
- specPattern: './src/**/*.cypress.spec.tsx'
5
- });
package/jest.config.js DELETED
@@ -1,20 +0,0 @@
1
- const baseConfig = require('../js-config/jest');
2
-
3
- module.exports = {
4
- ...baseConfig,
5
- moduleNameMapper: {
6
- '\\.(s?css|png|svg)$': 'identity-obj-proxy',
7
- '^react($|/.+)': '<rootDir>/../../node_modules/react$1'
8
- },
9
- reporters: ['default', ['jest-junit', { outputName: 'junit.xml' }]],
10
- roots: ['<rootDir>/src/'],
11
- setupFilesAfterEnv: [
12
- '<rootDir>/setupTests.js',
13
- '@testing-library/jest-dom/extend-expect'
14
- ],
15
- testResultsProcessor: 'jest-junit',
16
- transform: {
17
- ...baseConfig.transform,
18
- '^.+\\.mdx?$': '@storybook/addon-docs/jest-transform-mdx'
19
- }
20
- };
package/setupTests.js DELETED
@@ -1,86 +0,0 @@
1
- /* eslint-disable no-underscore-dangle */
2
- /* eslint-disable no-undef */
3
- // import '@testing-library/jest-dom/extend-expect';
4
- import i18n from 'i18next';
5
- import { initReactI18next } from 'react-i18next';
6
- import fetchMock from 'jest-fetch-mock';
7
-
8
- const mockedMatchMedia = () => ({
9
- addListener: () => {},
10
- matches: false,
11
- removeListener: () => {}
12
- });
13
-
14
- window.matchMedia = window.matchMedia || mockedMatchMedia;
15
-
16
- document.createRange = () => ({
17
- commonAncestorContainer: {
18
- nodeName: 'BODY',
19
- ownerDocument: document
20
- },
21
- setEnd: () => {},
22
- setStart: () => {}
23
- });
24
-
25
- global.IntersectionObserver = class IntersectionObserver {
26
- observe() {
27
- this.a = '';
28
-
29
- return null;
30
- }
31
-
32
- disconnect() {
33
- this.a = '';
34
-
35
- return null;
36
- }
37
- };
38
-
39
- Object.defineProperty(window, 'matchMedia', {
40
- value: jest.fn().mockImplementation((query) => ({
41
- addEventListener: jest.fn(),
42
- addListener: jest.fn(),
43
- dispatchEvent: jest.fn(),
44
- matches: false,
45
- media: query,
46
- onchange: null,
47
- removeEventListener: jest.fn(),
48
- removeListener: jest.fn()
49
- })),
50
- writable: true
51
- });
52
-
53
- Object.defineProperty(Image.prototype, 'onload', {
54
- get() {
55
- return this._onload;
56
- },
57
- set(onload) {
58
- onloadRef = onload;
59
- this._onload = onload;
60
- }
61
- });
62
- Object.defineProperty(Image.prototype, 'onerror', {
63
- get() {
64
- return this._onerror;
65
- },
66
- set(onerror) {
67
- onerrorRef = onerror;
68
- this._onerror = onerror;
69
- }
70
- });
71
-
72
- i18n.use(initReactI18next).init({
73
- fallbackLng: 'en',
74
- keySeparator: false,
75
- lng: 'en',
76
- nsSeparator: false,
77
- resources: {}
78
- });
79
-
80
- window.Image = () => ({
81
- onerror: () => {},
82
- onload: () => {},
83
- src: null
84
- });
85
-
86
- fetchMock.enableMocks();
@@ -1,52 +0,0 @@
1
- import initStoryshots from '@storybook/addon-storyshots';
2
- import { imageSnapshot } from '@storybook/addon-storyshots-puppeteer';
3
-
4
- jest.unmock('axios');
5
-
6
- const getMatchOptions = () => {
7
- return {
8
- failureThreshold: 0.2,
9
- failureThresholdType: 'percent'
10
- };
11
- };
12
-
13
- const beforeScreenshot = async (page) => {
14
- await page.addStyleTag({
15
- content: `
16
- *,
17
- *::before,
18
- *::after {
19
- animation-delay: -1s !important;
20
- animation-duration: 0s !important;
21
- animation-iteration-count: 1 !important;
22
- background-attachment: initial !important;
23
- scroll-behavior: auto !important;
24
- transition-duration: 0s !important;
25
- transition: none !important;
26
- }`
27
- });
28
-
29
- await page.setViewport({
30
- height: 1000,
31
- width: 1000
32
- });
33
- };
34
-
35
- const getStoryKindRegex = () => {
36
- const config = JSON.parse(process.env.TEST_CONFIGURATION);
37
- if (!config.story) {
38
- return null;
39
- }
40
-
41
- return new RegExp(`^(${config.story || ''})$`, 'g');
42
- };
43
-
44
- initStoryshots({
45
- storyKindRegex: getStoryKindRegex(),
46
- suite: 'Image StoryShots',
47
- test: imageSnapshot({
48
- beforeScreenshot,
49
- getMatchOptions,
50
- storybookUrl: `file://${__dirname}/../.out`
51
- })
52
- });
@@ -1,56 +0,0 @@
1
- import { ReactElement } from 'react';
2
-
3
- import {
4
- render as rtlRender,
5
- RenderOptions,
6
- RenderResult
7
- } from '@testing-library/react';
8
- import fetchMock, { MockParams } from 'jest-fetch-mock';
9
-
10
- import { ThemeMode } from '@centreon/ui-context';
11
-
12
- import ThemeProvider from './StoryBookThemeProvider';
13
-
14
- interface Props {
15
- children: ReactElement;
16
- }
17
-
18
- const ThemeProviderWrapper = ({ children }: Props): JSX.Element => {
19
- return <ThemeProvider themeMode={ThemeMode.light}>{children}</ThemeProvider>;
20
- };
21
-
22
- const render = (ui: ReactElement, options?: RenderOptions): RenderResult =>
23
- rtlRender(ui, {
24
- wrapper: ThemeProviderWrapper as (props) => ReactElement | null,
25
- ...options
26
- });
27
-
28
- // re-export everything
29
- export * from '@testing-library/react';
30
-
31
- // override render method
32
- export { render };
33
-
34
- interface MockResponse {
35
- data: object | unknown;
36
- options?: MockParams;
37
- }
38
-
39
- export const mockResponse = ({ data, options }: MockResponse): void => {
40
- fetchMock.mockResponse(JSON.stringify(data), options);
41
- };
42
-
43
- export const mockResponseOnce = ({ data, options }: MockResponse): void => {
44
- fetchMock.once(JSON.stringify(data), options);
45
- };
46
-
47
- export const resetMocks = (): void => {
48
- fetchMock.resetMocks();
49
- };
50
-
51
- export const getFetchCall = (
52
- index,
53
- secondIndex = 0
54
- ): string | Request | undefined | RequestInit => {
55
- return fetchMock.mock.calls[index][secondIndex];
56
- };
package/testRunner.js DELETED
@@ -1,36 +0,0 @@
1
- /* eslint-disable array-callback-return */
2
- /* eslint-disable consistent-return */
3
- const config = {
4
- story: null
5
- };
6
-
7
- const argv = process.argv.slice(0, 2);
8
-
9
- process.argv.reduce((cmd, arg) => {
10
- if (cmd) {
11
- config[cmd] = arg;
12
-
13
- return;
14
- }
15
-
16
- if (arg.startsWith('--')) {
17
- const sub = arg.substring('--'.length);
18
- if (Object.keys(config).includes(sub)) {
19
- if (typeof config[sub] === 'boolean') {
20
- config[cmd] = true;
21
-
22
- return;
23
- }
24
-
25
- return sub;
26
- }
27
- }
28
-
29
- argv.push(arg);
30
- });
31
-
32
- process.argv = argv;
33
-
34
- process.env.TEST_CONFIGURATION = JSON.stringify(config);
35
-
36
- require('jest/bin/jest');
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "extends": "../js-config/tsconfig/index.json",
3
- "compilerOptions": {
4
- "baseUrl": "./",
5
- "typeRoots": [
6
- "./types",
7
- "./node_modules/@types"
8
- ],
9
- "outDir": "./dist",
10
- "declaration": true,
11
- "skipLibCheck": true,
12
- "pretty": true,
13
- "emitDeclarationOnly": true,
14
- "types": [],
15
- "esModuleInterop": true
16
- },
17
- "include": [
18
- "./src",
19
- "./types"
20
- ],
21
- "exclude": [
22
- "./node_modules",
23
- "./dist",
24
- "./src/**/*.test.ts",
25
- "./src/**/*.test.tsx",
26
- "./src/**/*.stories.tsx",
27
- "../../node_modules",
28
- ]
29
- }
@@ -1,9 +0,0 @@
1
- declare module '*.scss' {
2
- export const content: { [className: string]: string };
3
- export default content;
4
- }
5
-
6
- declare module '*.svg' {
7
- const content: string;
8
- export default content;
9
- }