@centreon/ui-context 1.0.0-MON-191119-npm-develop.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.
- package/README.md +13 -0
- package/package.json +14 -0
- package/src/acknowledgementAtom.ts +9 -0
- package/src/aclAtom.ts +9 -0
- package/src/additionalResources.ts +5 -0
- package/src/browserLocaleAtom.ts +3 -0
- package/src/cloudServicesAtom.ts +5 -0
- package/src/defaults.ts +64 -0
- package/src/downtimeAtom.ts +9 -0
- package/src/federatedModulesAndWidgetsAtoms.ts +7 -0
- package/src/index.ts +43 -0
- package/src/isOnPublicPageAtom.ts +3 -0
- package/src/isResourceStatusFullSearchEnabledAtom.ts +3 -0
- package/src/platformFeauresAtom.ts +12 -0
- package/src/platformNameAtom.ts +5 -0
- package/src/platformVersionsAtom.ts +5 -0
- package/src/refreshIntervalAtom.ts +7 -0
- package/src/resourceStorageOptimizationMode.ts +9 -0
- package/src/statisticsRefreshIntervalAtom.ts +6 -0
- package/src/types.ts +147 -0
- package/src/userAtom.ts +9 -0
- package/src/userPermissionsAtom.ts +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# centreon-ui-context
|
|
2
|
+
|
|
3
|
+
A repository containing the shared context for the Centreon front-end (using the [React Context](https://reactjs.org/docs/context.html))
|
|
4
|
+
|
|
5
|
+
## Linting
|
|
6
|
+
|
|
7
|
+
To lint the code with ESlint, run:
|
|
8
|
+
|
|
9
|
+
`npm run eslint`
|
|
10
|
+
|
|
11
|
+
You can also fix fixable linter errors by running:
|
|
12
|
+
|
|
13
|
+
`npm run eslint:fix`
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@centreon/ui-context",
|
|
3
|
+
"version": "1.0.0-MON-191119-npm-develop.0",
|
|
4
|
+
"description": "Centreon UI shared context",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"author": "centreon@centreon.com",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"lint": "biome check ./src/ --error-on-warnings",
|
|
11
|
+
"lint:fix": "pnpm lint --fix",
|
|
12
|
+
"lint:ci": "biome ci ./src/ --error-on-warnings"
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/aclAtom.ts
ADDED
package/src/defaults.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ListingVariant, ThemeMode, User } from './types';
|
|
2
|
+
|
|
3
|
+
const defaultUser: User = {
|
|
4
|
+
alias: '',
|
|
5
|
+
canManageApiTokens: false,
|
|
6
|
+
default_page: '/monitoring/resources',
|
|
7
|
+
id: undefined,
|
|
8
|
+
isAdmin: undefined,
|
|
9
|
+
isExportButtonEnabled: false,
|
|
10
|
+
locale: null,
|
|
11
|
+
name: '',
|
|
12
|
+
themeMode: ThemeMode.light,
|
|
13
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
14
|
+
use_deprecated_pages: false,
|
|
15
|
+
user_interface_density: ListingVariant.compact
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const defaultResourceStorageOptimizationMode = false;
|
|
19
|
+
|
|
20
|
+
const defaultAcl = {
|
|
21
|
+
actions: {
|
|
22
|
+
host: {
|
|
23
|
+
acknowledgement: false,
|
|
24
|
+
check: false,
|
|
25
|
+
comment: false,
|
|
26
|
+
disacknowledgement: false,
|
|
27
|
+
downtime: false,
|
|
28
|
+
submit_status: false
|
|
29
|
+
},
|
|
30
|
+
service: {
|
|
31
|
+
acknowledgement: false,
|
|
32
|
+
check: false,
|
|
33
|
+
comment: false,
|
|
34
|
+
disacknowledgement: false,
|
|
35
|
+
downtime: false,
|
|
36
|
+
submit_status: false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const defaultDowntime = {
|
|
42
|
+
duration: 3600,
|
|
43
|
+
fixed: true,
|
|
44
|
+
with_services: false
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const defaultRefreshInterval = 15;
|
|
48
|
+
|
|
49
|
+
const defaultAcknowledgement = {
|
|
50
|
+
force_active_checks: false,
|
|
51
|
+
notify: true,
|
|
52
|
+
persistent: false,
|
|
53
|
+
sticky: false,
|
|
54
|
+
with_services: true
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
defaultUser,
|
|
59
|
+
defaultAcl,
|
|
60
|
+
defaultDowntime,
|
|
61
|
+
defaultRefreshInterval,
|
|
62
|
+
defaultAcknowledgement,
|
|
63
|
+
defaultResourceStorageOptimizationMode
|
|
64
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { default as userAtom } from './userAtom';
|
|
2
|
+
export { default as aclAtom } from './aclAtom';
|
|
3
|
+
export { default as downtimeAtom } from './downtimeAtom';
|
|
4
|
+
export { default as refreshIntervalAtom } from './refreshIntervalAtom';
|
|
5
|
+
export { default as statisticsRefreshIntervalAtom } from './statisticsRefreshIntervalAtom';
|
|
6
|
+
export { default as cloudServicesAtom } from './cloudServicesAtom';
|
|
7
|
+
export { default as acknowledgementAtom } from './acknowledgementAtom';
|
|
8
|
+
export { default as resourceStorageOptimizationModeAtom } from './resourceStorageOptimizationMode';
|
|
9
|
+
export { default as platformNameAtom } from './platformNameAtom';
|
|
10
|
+
export { default as userPermissionsAtom } from './userPermissionsAtom';
|
|
11
|
+
|
|
12
|
+
export { ThemeMode, ListingVariant, DashboardGlobalRole } from './types';
|
|
13
|
+
export {
|
|
14
|
+
platformFeaturesAtom,
|
|
15
|
+
featureFlagsDerivedAtom
|
|
16
|
+
} from './platformFeauresAtom';
|
|
17
|
+
|
|
18
|
+
export { platformVersionsAtom } from './platformVersionsAtom';
|
|
19
|
+
|
|
20
|
+
export { isOnPublicPageAtom } from './isOnPublicPageAtom';
|
|
21
|
+
export { additionalResourcesAtom } from './additionalResources';
|
|
22
|
+
export {
|
|
23
|
+
federatedModulesAtom,
|
|
24
|
+
federatedWidgetsAtom
|
|
25
|
+
} from './federatedModulesAndWidgetsAtoms';
|
|
26
|
+
export { browserLocaleAtom } from './browserLocaleAtom';
|
|
27
|
+
export { isResourceStatusFullSearchEnabledAtom } from './isResourceStatusFullSearchEnabledAtom';
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
User,
|
|
31
|
+
UserContext,
|
|
32
|
+
ActionAcl,
|
|
33
|
+
Actions,
|
|
34
|
+
Downtime,
|
|
35
|
+
CloudServices,
|
|
36
|
+
Acknowledgement,
|
|
37
|
+
Acl,
|
|
38
|
+
DashboardRolesAndPermissions,
|
|
39
|
+
FeatureFlags,
|
|
40
|
+
PlatformFeatures,
|
|
41
|
+
AdditionalResource,
|
|
42
|
+
UserPermissions
|
|
43
|
+
} from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { atom } from 'jotai';
|
|
2
|
+
|
|
3
|
+
import { FeatureFlags, PlatformFeatures } from './types';
|
|
4
|
+
|
|
5
|
+
export const platformFeaturesAtom = atom<PlatformFeatures | null>(null);
|
|
6
|
+
export const featureFlagsDerivedAtom = atom<FeatureFlags | null>(
|
|
7
|
+
(get): FeatureFlags => {
|
|
8
|
+
const platformFeatures = get(platformFeaturesAtom);
|
|
9
|
+
|
|
10
|
+
return platformFeatures?.featureFlags as FeatureFlags;
|
|
11
|
+
}
|
|
12
|
+
);
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
|
|
3
|
+
export enum ListingVariant {
|
|
4
|
+
compact = 'compact',
|
|
5
|
+
extended = 'extended'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum DashboardGlobalRole {
|
|
9
|
+
administrator = 'administrator',
|
|
10
|
+
creator = 'creator',
|
|
11
|
+
viewer = 'viewer'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DashboardRolesAndPermissions {
|
|
15
|
+
createDashboards: boolean;
|
|
16
|
+
globalUserRole: DashboardGlobalRole;
|
|
17
|
+
manageAllDashboards: boolean;
|
|
18
|
+
viewDashboards: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface User {
|
|
22
|
+
alias: string;
|
|
23
|
+
canManageApiTokens: boolean;
|
|
24
|
+
dashboard?: DashboardRolesAndPermissions | null;
|
|
25
|
+
default_page?: string | null;
|
|
26
|
+
id?: number;
|
|
27
|
+
isAdmin?: boolean;
|
|
28
|
+
isExportButtonEnabled: boolean;
|
|
29
|
+
locale: string | null;
|
|
30
|
+
name: string;
|
|
31
|
+
themeMode?: ThemeMode;
|
|
32
|
+
timezone: string;
|
|
33
|
+
use_deprecated_pages: boolean;
|
|
34
|
+
user_interface_density: ListingVariant;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum ThemeMode {
|
|
38
|
+
dark = 'dark',
|
|
39
|
+
light = 'light'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CloudServices {
|
|
43
|
+
areCloudServicesEnabled: boolean;
|
|
44
|
+
setAreCloudServicesEnabled: Dispatch<SetStateAction<boolean>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface Acknowledgement {
|
|
48
|
+
force_active_checks: boolean;
|
|
49
|
+
notify: boolean;
|
|
50
|
+
persistent: boolean;
|
|
51
|
+
sticky: boolean;
|
|
52
|
+
with_services: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type UserContext = {
|
|
56
|
+
acknowledgement: Acknowledgement;
|
|
57
|
+
acl: Acl;
|
|
58
|
+
cloudServices: CloudServices | undefined;
|
|
59
|
+
downtime: Downtime;
|
|
60
|
+
refreshInterval: number;
|
|
61
|
+
resourceStorageOptimizationMode: boolean;
|
|
62
|
+
} & User;
|
|
63
|
+
|
|
64
|
+
export interface ActionAcl {
|
|
65
|
+
acknowledgement: boolean;
|
|
66
|
+
check: boolean;
|
|
67
|
+
comment: boolean;
|
|
68
|
+
downtime: boolean;
|
|
69
|
+
submit_status: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface Actions {
|
|
73
|
+
host: ActionAcl;
|
|
74
|
+
service: ActionAcl;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface Acl {
|
|
78
|
+
actions: Actions;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface Downtime {
|
|
82
|
+
duration: number;
|
|
83
|
+
fixed: boolean;
|
|
84
|
+
with_services: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface FeatureFlags {
|
|
88
|
+
adExclusionPeriods?: boolean;
|
|
89
|
+
notification?: boolean;
|
|
90
|
+
vault?: boolean;
|
|
91
|
+
mapVisxViewer?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface PlatformFeatures {
|
|
95
|
+
featureFlags: FeatureFlags;
|
|
96
|
+
isCloudPlatform: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface AdditionalResource {
|
|
100
|
+
baseEndpoint: string;
|
|
101
|
+
defaultMonitoringParameter?: Record<string, boolean | number | string>;
|
|
102
|
+
label: string;
|
|
103
|
+
resourceType: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface FederatedComponentsConfiguration {
|
|
107
|
+
federatedComponents: Array<string>;
|
|
108
|
+
panelMinHeight?: number;
|
|
109
|
+
panelMinWidth?: number;
|
|
110
|
+
path: string;
|
|
111
|
+
title?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface PageComponent {
|
|
115
|
+
children?: string;
|
|
116
|
+
component: string;
|
|
117
|
+
featureFlag?: string;
|
|
118
|
+
route: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface FederatedModule {
|
|
122
|
+
federatedComponentsConfiguration: Array<FederatedComponentsConfiguration>;
|
|
123
|
+
federatedPages: Array<PageComponent>;
|
|
124
|
+
moduleFederationName: string;
|
|
125
|
+
moduleName: string;
|
|
126
|
+
preloadScript?: string;
|
|
127
|
+
remoteEntry: string;
|
|
128
|
+
remoteUrl?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface Version {
|
|
132
|
+
fix: string;
|
|
133
|
+
major: string;
|
|
134
|
+
minor: string;
|
|
135
|
+
version: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface PlatformVersions {
|
|
139
|
+
modules: Record<string, Version>;
|
|
140
|
+
web: Version;
|
|
141
|
+
widgets: Record<string, Version | null>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface UserPermissions {
|
|
145
|
+
top_counter: boolean;
|
|
146
|
+
poller_statistics: boolean;
|
|
147
|
+
}
|
package/src/userAtom.ts
ADDED