@camunda/ccma-saas-frontend 0.15.0 → 0.16.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/lib/esm/components/c4-cluster-list/c4-cluster-list.js +4 -10
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.types.d.ts +1 -4
- package/lib/esm/components/c4-cluster-overview/applications.js +91 -16
- package/lib/esm/components/c4-cluster-overview/c4-cluster-overview.d.ts +31 -1
- package/lib/esm/components/c4-cluster-overview/c4-cluster-overview.js +28 -0
- package/lib/esm/components/c4-cluster-overview/cluster-details.js +12 -47
- package/lib/esm/components/c4-cluster-overview/cluster-load.js +3 -2
- package/lib/esm/components/c4-cluster-overview/ds-status-icon-text.d.ts +33 -0
- package/lib/esm/components/c4-cluster-overview/ds-status-icon-text.js +34 -0
- package/lib/esm/components/c4-console-dashboard/c4-console-dashboard.js +6 -5
- package/lib/esm/components/c4-hub-upgrade-banner/c4-hub-upgrade-banner.d.ts +1 -1
- package/lib/esm/components/c4-hub-upgrade-banner/c4-hub-upgrade-banner.js +1 -1
- package/lib/esm/components/c4-sm-cluster-details/details.js +2 -8
- package/lib/esm/components/c4-usage-history/elements/usage-history-charts.d.ts +3 -3
- package/lib/esm/components/c4-usage-metrics-per-cluster/c4-usage-metrics-per-cluster.js +2 -8
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/runtime/c4-console-events-context.d.ts +5 -1
- package/lib/esm/runtime/c4-console-events-context.js +16 -2
- package/lib/esm/runtime/c4-console-runtime-context.d.ts +7 -6
- package/lib/esm/runtime/c4-console-runtime-context.js +29 -12
- package/lib/esm/runtime/c4-console-runtime.types.d.ts +7 -7
- package/lib/esm/runtime/c4-user-notifications-context.js +6 -2
- package/lib/esm/runtime/c4-user-notifications-context.types.d.ts +5 -1
- package/lib/esm/runtime/use-hub-api-naming.d.ts +8 -11
- package/lib/esm/runtime/use-hub-api-naming.js +9 -12
- package/lib/esm/runtime/use-is-qa-user.d.ts +23 -0
- package/lib/esm/runtime/use-is-qa-user.js +64 -0
- package/lib/esm/ui/c4-cluster-tag.d.ts +11 -0
- package/lib/esm/ui/c4-cluster-tag.js +39 -0
- package/lib/esm/ui/index.js +8 -7
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +0 -3
- package/lib/esm/widgets/cluster-details/c4-cluster-details-page.js +3 -4
- package/lib/esm/widgets/cluster-details/c4-cluster-details-page.types.d.ts +1 -1
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +2 -14
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +3 -3
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +0 -5
- package/lib/esm/widgets/clusters/c4-clusters-page.js +0 -4
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.d.ts +1 -1
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +6 -16
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.types.d.ts +0 -3
- package/lib/esm/widgets/dashboard/c4-dashboard-app.js +5 -6
- package/lib/esm/widgets/dashboard/c4-dashboard-app.types.d.ts +2 -3
- package/lib/esm/widgets/management/c4-management-app.d.ts +1 -1
- package/lib/esm/widgets/management/c4-management-app.js +19 -33
- package/lib/esm/widgets/management/c4-management-app.types.d.ts +4 -9
- package/lib/esm/widgets/management/tabs/c4-management-billing-tab.d.ts +0 -1
- package/lib/esm/widgets/management/tabs/c4-management-billing-tab.js +1 -2
- package/lib/esm/widgets/management/tabs/c4-management-usage-tab.d.ts +2 -2
- package/package.json +19 -19
- package/lib/esm/runtime/cluster-duplication.d.ts +0 -10
- package/lib/esm/runtime/cluster-duplication.js +0 -15
|
@@ -5,7 +5,11 @@ interface C4ConsoleEventsState {
|
|
|
5
5
|
}
|
|
6
6
|
export interface C4ConsoleEventsProviderProps {
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Set `false` to disable the live subscription, for example in Storybook or
|
|
10
|
+
* in tests. Default `true`. The provider also opens no stream for a QA user
|
|
11
|
+
* (`useIsQaUser`).
|
|
12
|
+
*/
|
|
9
13
|
live?: boolean;
|
|
10
14
|
}
|
|
11
15
|
export declare const C4ConsoleEventsProvider: ({ children, live, }: C4ConsoleEventsProviderProps) => React.JSX.Element;
|
|
@@ -8,6 +8,7 @@ import { ExternalConsoleService, } from '@camunda/ccma-api';
|
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
import { useC4ConsoleRuntime } from './c4-console-runtime-context.js';
|
|
10
10
|
import { toApiConfig } from './to-api-config.js';
|
|
11
|
+
import { useIsQaUser } from './use-is-qa-user.js';
|
|
11
12
|
/**
|
|
12
13
|
* Bridges the Console org/cluster SSE stream to the `clusterchange` window
|
|
13
14
|
* event that `C4ConsoleDataProvider` (and legacy c3 `useClusterUpdate`
|
|
@@ -24,9 +25,19 @@ const EventsContext = createContext(undefined);
|
|
|
24
25
|
let mountedBridgeCount = 0;
|
|
25
26
|
export const C4ConsoleEventsProvider = ({ children, live = true, }) => {
|
|
26
27
|
const runtime = useC4ConsoleRuntime();
|
|
28
|
+
// An automated QA run opens a new browser for each test, and no test reads
|
|
29
|
+
// the stream. The stream waits until the provider knows the user is no QA user.
|
|
30
|
+
const isQaUser = useIsQaUser(runtime);
|
|
31
|
+
const connects = live && isQaUser === false;
|
|
27
32
|
const [state, setState] = useState(live ? 'connecting' : 'closed');
|
|
33
|
+
// The provider opens no stream in these two cases, thus its state is closed.
|
|
28
34
|
useEffect(() => {
|
|
29
|
-
if (!live ||
|
|
35
|
+
if (!live || isQaUser) {
|
|
36
|
+
setState('closed');
|
|
37
|
+
}
|
|
38
|
+
}, [live, isQaUser]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!connects || typeof window === 'undefined') {
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
43
|
mountedBridgeCount += 1;
|
|
@@ -37,6 +48,9 @@ export const C4ConsoleEventsProvider = ({ children, live = true, }) => {
|
|
|
37
48
|
'double-dispatches SSE events. Mount exactly one. See ' +
|
|
38
49
|
'packages/c4/docs/runtime.md.');
|
|
39
50
|
}
|
|
51
|
+
// `connectSse` starts in `connecting` but does not report it. After a QA
|
|
52
|
+
// session the state is `closed`, and it would stay so until the stream opens.
|
|
53
|
+
setState('connecting');
|
|
40
54
|
const connection = ExternalConsoleService.streamOrgEvents({
|
|
41
55
|
config: toApiConfig(runtime),
|
|
42
56
|
onStateChange: setState,
|
|
@@ -48,7 +62,7 @@ export const C4ConsoleEventsProvider = ({ children, live = true, }) => {
|
|
|
48
62
|
mountedBridgeCount -= 1;
|
|
49
63
|
connection.close();
|
|
50
64
|
};
|
|
51
|
-
}, [
|
|
65
|
+
}, [connects, runtime]);
|
|
52
66
|
const value = useMemo(() => ({ state }), [state]);
|
|
53
67
|
return (_jsx(EventsContext.Provider, { value: value, children: children }));
|
|
54
68
|
};
|
|
@@ -29,14 +29,15 @@ export declare const useC4ConsoleStage: () => ConsoleStage | undefined;
|
|
|
29
29
|
* boolean. Thus a flag must hold the behavior that the other hosts of this
|
|
30
30
|
* package must NOT get by default.
|
|
31
31
|
*
|
|
32
|
-
* The key is the
|
|
33
|
-
*
|
|
32
|
+
* The key is the key of the row in the flag table, for example
|
|
33
|
+
* `console.byoidp`. A key with no row reads as off.
|
|
34
34
|
*
|
|
35
35
|
* The value comes from one of two places. A host that gives
|
|
36
36
|
* `config.featureFlags` answers it itself. Every other host gets the flags
|
|
37
|
-
* that `C4ConsoleRuntimeProvider` reads from
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* must not run
|
|
37
|
+
* that `C4ConsoleRuntimeProvider` reads from control-backend, or from
|
|
38
|
+
* accounts-backend when control-backend fails. That read is a request, thus a
|
|
39
|
+
* flag is off on the first render and the component renders again when the
|
|
40
|
+
* flags arrive. Do not use this hook for a one-time effect that must not run
|
|
41
|
+
* twice.
|
|
41
42
|
*/
|
|
42
43
|
export declare const useC4FeatureFlag: (flagKey: string) => boolean;
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
5
5
|
* You may not use this file except in compliance with the commercial license.
|
|
6
6
|
*/
|
|
7
|
-
import { ExternalAccountsService } from '@camunda/ccma-api';
|
|
7
|
+
import { ControlFeatureFlagsService, ExternalAccountsService, } from '@camunda/ccma-api';
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
9
9
|
import { toApiConfig } from './to-api-config.js';
|
|
10
10
|
const RuntimeContext = createContext(undefined);
|
|
@@ -47,7 +47,7 @@ function useSyncCarbonThemeToDesignSystem(designSystem) {
|
|
|
47
47
|
};
|
|
48
48
|
}, [designSystem]);
|
|
49
49
|
}
|
|
50
|
-
/** Reads a dot path such as `console.
|
|
50
|
+
/** Reads a dot path such as `console.byoidp` out of the flags. */
|
|
51
51
|
function readFlag(flags, flagKey) {
|
|
52
52
|
if (!flags) {
|
|
53
53
|
return false;
|
|
@@ -62,8 +62,10 @@ function readFlag(flags, flagKey) {
|
|
|
62
62
|
return value === true;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Reads the flags of the caller
|
|
66
|
-
*
|
|
65
|
+
* Reads the flags of the caller, one time per organization and user, from
|
|
66
|
+
* `GET /api/feature-flags/evaluate` of control-backend. When that request
|
|
67
|
+
* fails, it reads `GET external/feature-flags` of accounts-backend. When both
|
|
68
|
+
* fail, every flag reads as off.
|
|
67
69
|
*
|
|
68
70
|
* It fetches nothing when the host gives `config.featureFlags`, thus a host
|
|
69
71
|
* that evaluates the flags itself makes no request. It also fetches nothing
|
|
@@ -118,7 +120,7 @@ function useFetchedFeatureFlags(config) {
|
|
|
118
120
|
}
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
|
-
const
|
|
123
|
+
const request = {
|
|
122
124
|
// The token above is current, thus the request reuses it. A second
|
|
123
125
|
// call to `getAccessToken` of the host is not necessary.
|
|
124
126
|
config: {
|
|
@@ -126,7 +128,21 @@ function useFetchedFeatureFlags(config) {
|
|
|
126
128
|
auth: { getToken: async () => token },
|
|
127
129
|
},
|
|
128
130
|
params: { orgId },
|
|
129
|
-
}
|
|
131
|
+
};
|
|
132
|
+
let fetched;
|
|
133
|
+
try {
|
|
134
|
+
fetched = await ControlFeatureFlagsService.evaluate(request);
|
|
135
|
+
}
|
|
136
|
+
catch (controlError) {
|
|
137
|
+
// Control-backend can be down or limited. accounts-backend holds the
|
|
138
|
+
// same rows from its own copy in Redis, and it answers with the last
|
|
139
|
+
// rows that it knows. That is better than every flag off for a host
|
|
140
|
+
// that serves customers.
|
|
141
|
+
configRef.current.telemetry?.captureException?.(controlError, {
|
|
142
|
+
source: 'C4ConsoleRuntimeProvider.featureFlags.control',
|
|
143
|
+
});
|
|
144
|
+
fetched = await ExternalAccountsService.getFeatureFlags(request);
|
|
145
|
+
}
|
|
130
146
|
if (!cancelled) {
|
|
131
147
|
setFlags(fetched);
|
|
132
148
|
}
|
|
@@ -285,15 +301,16 @@ export const useC4ConsoleStage = () => {
|
|
|
285
301
|
* boolean. Thus a flag must hold the behavior that the other hosts of this
|
|
286
302
|
* package must NOT get by default.
|
|
287
303
|
*
|
|
288
|
-
* The key is the
|
|
289
|
-
*
|
|
304
|
+
* The key is the key of the row in the flag table, for example
|
|
305
|
+
* `console.byoidp`. A key with no row reads as off.
|
|
290
306
|
*
|
|
291
307
|
* The value comes from one of two places. A host that gives
|
|
292
308
|
* `config.featureFlags` answers it itself. Every other host gets the flags
|
|
293
|
-
* that `C4ConsoleRuntimeProvider` reads from
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* must not run
|
|
309
|
+
* that `C4ConsoleRuntimeProvider` reads from control-backend, or from
|
|
310
|
+
* accounts-backend when control-backend fails. That read is a request, thus a
|
|
311
|
+
* flag is off on the first render and the component renders again when the
|
|
312
|
+
* flags arrive. Do not use this hook for a one-time effect that must not run
|
|
313
|
+
* twice.
|
|
297
314
|
*/
|
|
298
315
|
export const useC4FeatureFlag = (flagKey) => {
|
|
299
316
|
return useContext(RuntimeContext)?.featureFlags?.isEnabled?.(flagKey) ?? false;
|
|
@@ -71,15 +71,15 @@ export interface C4ConsoleRuntimeConfig {
|
|
|
71
71
|
* Overrides the feature flags of the host.
|
|
72
72
|
*
|
|
73
73
|
* Omit it and `C4ConsoleRuntimeProvider` reads the flags from
|
|
74
|
-
* `GET
|
|
75
|
-
*
|
|
76
|
-
* the
|
|
74
|
+
* `GET /api/feature-flags/evaluate` on control-backend. When that request
|
|
75
|
+
* fails, it reads `GET external/feature-flags` on accounts-backend. Thus the
|
|
76
|
+
* deployed backend owns the values, and the host holds no copy of the
|
|
77
|
+
* rules. This is the path for an external host such as Camunda Hub.
|
|
77
78
|
*
|
|
78
79
|
* Give it and the fetch does not happen, and this function answers every
|
|
79
|
-
* flag. console-frontend does this
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* read `features()` directly and never come through here.
|
|
80
|
+
* flag. console-frontend does this on every stage. It is also the only host
|
|
81
|
+
* in this repository that mounts this provider — the control and accounts
|
|
82
|
+
* frontends read their flags directly and never come through here.
|
|
83
83
|
*/
|
|
84
84
|
featureFlags?: {
|
|
85
85
|
isEnabled: (flagKey: string) => boolean;
|
|
@@ -8,6 +8,7 @@ import { ExternalNotificationsService, } from '@camunda/ccma-api';
|
|
|
8
8
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
9
9
|
import { useC4ConsoleRuntime } from './c4-console-runtime-context.js';
|
|
10
10
|
import { toApiConfig } from './to-api-config.js';
|
|
11
|
+
import { useIsQaUser } from './use-is-qa-user.js';
|
|
11
12
|
const NotificationsContext = createContext(undefined);
|
|
12
13
|
function sortNewestFirst(list) {
|
|
13
14
|
return [...list].sort((a, b) => b.timestamp - a.timestamp);
|
|
@@ -38,6 +39,7 @@ function mergeIncoming(list, incoming) {
|
|
|
38
39
|
*/
|
|
39
40
|
export const C4UserNotificationsProvider = ({ orgId, children, live = true, }) => {
|
|
40
41
|
const runtime = useC4ConsoleRuntime();
|
|
42
|
+
const isQaUser = useIsQaUser(runtime);
|
|
41
43
|
const [notifications, setNotifications] = useState([]);
|
|
42
44
|
const [isLoading, setIsLoading] = useState(true);
|
|
43
45
|
const [error, setError] = useState(undefined);
|
|
@@ -70,7 +72,9 @@ export const C4UserNotificationsProvider = ({ orgId, children, live = true, }) =
|
|
|
70
72
|
// Live SSE subscription, scoped to the current org. Closed on unmount and on
|
|
71
73
|
// org change (the c3 provider leaked this).
|
|
72
74
|
useEffect(() => {
|
|
73
|
-
|
|
75
|
+
// An automated QA run opens a new browser for each test, and no test reads
|
|
76
|
+
// a notification. The stream waits until the user is known to be no QA user.
|
|
77
|
+
if (!live || isQaUser !== false) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
76
80
|
let connection;
|
|
@@ -91,7 +95,7 @@ export const C4UserNotificationsProvider = ({ orgId, children, live = true, }) =
|
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
return () => connection?.close();
|
|
94
|
-
}, [live, runtime, orgId]);
|
|
98
|
+
}, [live, isQaUser, runtime, orgId]);
|
|
95
99
|
const persistState = useCallback((uuid, state) => {
|
|
96
100
|
void ExternalNotificationsService.setNotificationState({
|
|
97
101
|
config: toApiConfig(runtime),
|
|
@@ -4,7 +4,11 @@ export interface C4UserNotificationsProviderProps {
|
|
|
4
4
|
/** Organization whose feed is shown. Changing it re-fetches and re-subscribes. */
|
|
5
5
|
orgId: string;
|
|
6
6
|
children: React.ReactNode;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Set `false` to disable the live SSE subscription, for example in Storybook
|
|
9
|
+
* or in tests. Default `true`. The provider also opens no stream for a QA
|
|
10
|
+
* user (`useIsQaUser`).
|
|
11
|
+
*/
|
|
8
12
|
live?: boolean;
|
|
9
13
|
}
|
|
10
14
|
export interface C4UserNotificationsState {
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const HUB_MODELER_API_NAMING_FLAG = "console.hubModelerApiNaming";
|
|
2
2
|
/**
|
|
3
3
|
* Whether the Administration API surfaces use the Hub wording.
|
|
4
4
|
*
|
|
5
5
|
* The Hub rollout renames the Modeler scopes: the scope group in the
|
|
6
6
|
* create-client modal reads "Hub API" and the scope columns read "Hub Scopes".
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
9
|
-
* only on prod, until Hub is public.
|
|
7
|
+
* The flag `console.hubModelerApiNaming` holds the Hub wording. The flag table
|
|
8
|
+
* of each stage holds its value.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* An opt-in flag cannot do this: the runtime bridge gives a boolean, so c4
|
|
15
|
-
* cannot tell an unknown flag from a flag that the host turned off.
|
|
10
|
+
* A host that does not know the flag reads it as off (see `useC4FeatureFlag`),
|
|
11
|
+
* and gets the old wording: "Web Modeler API" and "Modeler Scopes". So does a
|
|
12
|
+
* tree with no runtime provider, and the first render before the flags arrive.
|
|
16
13
|
*
|
|
17
14
|
* Only the text changes. The scope values that go to the API (`GetModel`,
|
|
18
15
|
* `CreateModel`, ...) are the same for every host and every stage.
|
|
19
16
|
*
|
|
20
17
|
* Each renamed i18n key has a `Hub` sibling, for example
|
|
21
18
|
* `apiclients:create.fields.scopes.modeler.label` and `…modeler.labelHub`.
|
|
22
|
-
* When
|
|
23
|
-
*
|
|
19
|
+
* When every stage has the Hub wording, delete this hook, the Modeler variant
|
|
20
|
+
* of each key, and the `hubNaming` branch at every call site.
|
|
24
21
|
*/
|
|
25
22
|
export declare const useHubApiNaming: () => boolean;
|
|
@@ -4,28 +4,25 @@
|
|
|
4
4
|
* You may not use this file except in compliance with the commercial license.
|
|
5
5
|
*/
|
|
6
6
|
import { useC4FeatureFlag } from './c4-console-runtime-context.js';
|
|
7
|
-
export const
|
|
7
|
+
export const HUB_MODELER_API_NAMING_FLAG = 'console.hubModelerApiNaming';
|
|
8
8
|
/**
|
|
9
9
|
* Whether the Administration API surfaces use the Hub wording.
|
|
10
10
|
*
|
|
11
11
|
* The Hub rollout renames the Modeler scopes: the scope group in the
|
|
12
12
|
* create-client modal reads "Hub API" and the scope columns read "Hub Scopes".
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
* only on prod, until Hub is public.
|
|
13
|
+
* The flag `console.hubModelerApiNaming` holds the Hub wording. The flag table
|
|
14
|
+
* of each stage holds its value.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* An opt-in flag cannot do this: the runtime bridge gives a boolean, so c4
|
|
21
|
-
* cannot tell an unknown flag from a flag that the host turned off.
|
|
16
|
+
* A host that does not know the flag reads it as off (see `useC4FeatureFlag`),
|
|
17
|
+
* and gets the old wording: "Web Modeler API" and "Modeler Scopes". So does a
|
|
18
|
+
* tree with no runtime provider, and the first render before the flags arrive.
|
|
22
19
|
*
|
|
23
20
|
* Only the text changes. The scope values that go to the API (`GetModel`,
|
|
24
21
|
* `CreateModel`, ...) are the same for every host and every stage.
|
|
25
22
|
*
|
|
26
23
|
* Each renamed i18n key has a `Hub` sibling, for example
|
|
27
24
|
* `apiclients:create.fields.scopes.modeler.label` and `…modeler.labelHub`.
|
|
28
|
-
* When
|
|
29
|
-
*
|
|
25
|
+
* When every stage has the Hub wording, delete this hook, the Modeler variant
|
|
26
|
+
* of each key, and the `hubNaming` branch at every call site.
|
|
30
27
|
*/
|
|
31
|
-
export const useHubApiNaming = () =>
|
|
28
|
+
export const useHubApiNaming = () => useC4FeatureFlag(HUB_MODELER_API_NAMING_FLAG);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { C4ConsoleRuntimeConfig } from './c4-console-runtime.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tells whether the user is a user of an automated QA run. The live streams
|
|
4
|
+
* use it: a QA run opens a new browser for each test, and no test reads them.
|
|
5
|
+
*
|
|
6
|
+
* The email of `config.user` answers at once. A host that gives no `user`
|
|
7
|
+
* (Hub) gets the answer from the email in the `https://camunda.com/meta` claim
|
|
8
|
+
* of the access token. The token is read on the client without verification,
|
|
9
|
+
* which is enough for a hint: the backends check the same claim and answer 204
|
|
10
|
+
* to a QA user.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` until the token is read. A caller that must not open a
|
|
13
|
+
* stream for a QA user waits for `false`. A token that cannot be read gives
|
|
14
|
+
* `false`.
|
|
15
|
+
*
|
|
16
|
+
* The answer belongs to the session that it classified: the stage, the user id
|
|
17
|
+
* and the org id. When one of them changes, the hook returns `undefined` until
|
|
18
|
+
* the token of the new session is read. A host that gives no `user` and keeps
|
|
19
|
+
* one org id signals no change of session, thus it keeps the first answer. Give
|
|
20
|
+
* `config.user` for a host with more than one session in a page (see section 4a
|
|
21
|
+
* of `docs/runtime.md`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function useIsQaUser(runtime: C4ConsoleRuntimeConfig): boolean | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
|
|
3
|
+
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
4
|
+
* You may not use this file except in compliance with the commercial license.
|
|
5
|
+
*/
|
|
6
|
+
import { CAMUNDA_CLAIMS_NAMESPACE, isQaUserEmail, } from '@camunda/ccma-shared-types';
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { decodeAccessTokenPayload } from './decode-access-token.js';
|
|
9
|
+
/**
|
|
10
|
+
* Tells whether the user is a user of an automated QA run. The live streams
|
|
11
|
+
* use it: a QA run opens a new browser for each test, and no test reads them.
|
|
12
|
+
*
|
|
13
|
+
* The email of `config.user` answers at once. A host that gives no `user`
|
|
14
|
+
* (Hub) gets the answer from the email in the `https://camunda.com/meta` claim
|
|
15
|
+
* of the access token. The token is read on the client without verification,
|
|
16
|
+
* which is enough for a hint: the backends check the same claim and answer 204
|
|
17
|
+
* to a QA user.
|
|
18
|
+
*
|
|
19
|
+
* Returns `undefined` until the token is read. A caller that must not open a
|
|
20
|
+
* stream for a QA user waits for `false`. A token that cannot be read gives
|
|
21
|
+
* `false`.
|
|
22
|
+
*
|
|
23
|
+
* The answer belongs to the session that it classified: the stage, the user id
|
|
24
|
+
* and the org id. When one of them changes, the hook returns `undefined` until
|
|
25
|
+
* the token of the new session is read. A host that gives no `user` and keeps
|
|
26
|
+
* one org id signals no change of session, thus it keeps the first answer. Give
|
|
27
|
+
* `config.user` for a host with more than one session in a page (see section 4a
|
|
28
|
+
* of `docs/runtime.md`).
|
|
29
|
+
*/
|
|
30
|
+
export function useIsQaUser(runtime) {
|
|
31
|
+
const email = runtime.user?.email;
|
|
32
|
+
// The host usually gives `config` as an object literal, and the runtime value
|
|
33
|
+
// changes when the flags arrive. The effect below depends on primitives
|
|
34
|
+
// alone, or it reads the token again on each of those changes.
|
|
35
|
+
const runtimeRef = useRef(runtime);
|
|
36
|
+
runtimeRef.current = runtime;
|
|
37
|
+
const sessionKey = [runtime.stage, runtime.user?.sub, runtime.orgId].join('|');
|
|
38
|
+
const [fromToken, setFromToken] = useState(undefined);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (email) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let cancelled = false;
|
|
44
|
+
runtimeRef.current.auth
|
|
45
|
+
.getAccessToken()
|
|
46
|
+
.then((token) => {
|
|
47
|
+
const meta = decodeAccessTokenPayload(token ?? '')?.[CAMUNDA_CLAIMS_NAMESPACE];
|
|
48
|
+
return isQaUserEmail(meta?.email);
|
|
49
|
+
})
|
|
50
|
+
.catch(() => false)
|
|
51
|
+
.then((isQa) => {
|
|
52
|
+
if (!cancelled) {
|
|
53
|
+
setFromToken({ sessionKey, isQa });
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
cancelled = true;
|
|
58
|
+
};
|
|
59
|
+
}, [email, sessionKey]);
|
|
60
|
+
if (email) {
|
|
61
|
+
return isQaUserEmail(email);
|
|
62
|
+
}
|
|
63
|
+
return fromToken?.sessionKey === sessionKey ? fromToken.isQa : undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { C3ClusterTagProps } from '@camunda/design-system/carbon-compat';
|
|
2
|
+
import type { JSX } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The ds branch of the `ClusterTag` stage chip. It has the API of the
|
|
5
|
+
* carbon-compat `C3ClusterTag` and the look of the environment tags in Hub.
|
|
6
|
+
*
|
|
7
|
+
* It supports the `stage` form only. Like the carbon-compat adapter, it shows
|
|
8
|
+
* nothing for the `clusterUuid` form, because it cannot read the c3 profile
|
|
9
|
+
* store. An unknown stage shows its raw value in `neutral`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function C4ClusterTag(props: C3ClusterTagProps): JSX.Element | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
|
|
4
|
+
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
5
|
+
* You may not use this file except in compliance with the commercial license.
|
|
6
|
+
*/
|
|
7
|
+
import { Badge } from '@camunda/design-system';
|
|
8
|
+
/**
|
|
9
|
+
* The badge variant of each stage. It is the color scheme of the environment
|
|
10
|
+
* tags in Hub (`getTagVariant` in camunda-hub), so that a cluster tag in
|
|
11
|
+
* Console and an environment tag in Hub look the same. It is not the scheme of
|
|
12
|
+
* the carbon-compat `C3ClusterTag`, which shows `dev` as `success`. The DS has
|
|
13
|
+
* no purple variant, thus `stage` is `warning`.
|
|
14
|
+
*/
|
|
15
|
+
const STAGE_VARIANT = {
|
|
16
|
+
prod: 'danger',
|
|
17
|
+
stage: 'warning',
|
|
18
|
+
test: 'info',
|
|
19
|
+
dev: 'neutral',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The ds branch of the `ClusterTag` stage chip. It has the API of the
|
|
23
|
+
* carbon-compat `C3ClusterTag` and the look of the environment tags in Hub.
|
|
24
|
+
*
|
|
25
|
+
* It supports the `stage` form only. Like the carbon-compat adapter, it shows
|
|
26
|
+
* nothing for the `clusterUuid` form, because it cannot read the c3 profile
|
|
27
|
+
* store. An unknown stage shows its raw value in `neutral`.
|
|
28
|
+
*/
|
|
29
|
+
export function C4ClusterTag(props) {
|
|
30
|
+
const stage = 'stage' in props ? props.stage : undefined;
|
|
31
|
+
if (!stage) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (props.conditionalRendering && !props.conditionalRendering(stage)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const variant = props.subtle ? 'neutral' : (STAGE_VARIANT[stage] ?? 'neutral');
|
|
38
|
+
return (_jsx(Badge, { variant: variant, className: `font-normal ${props.className ?? ''}`.trim(), children: stage }));
|
|
39
|
+
}
|
package/lib/esm/ui/index.js
CHANGED
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
* `switchable(...)`, then point the consuming component's import at this module.
|
|
38
38
|
*/
|
|
39
39
|
import { C3ClusterTag as CarbonClusterTag } from '@camunda/camunda-composite-components';
|
|
40
|
-
import { BreadcrumbSkeleton as DsBreadcrumbSkeleton, Button as DsButton, Checkbox as DsCheckbox,
|
|
40
|
+
import { BreadcrumbSkeleton as DsBreadcrumbSkeleton, Button as DsButton, Checkbox as DsCheckbox, CodeSnippet as DsCodeSnippet, ComposedModal as DsComposedModal, Dropdown as DsDropdown, FilterableMultiSelect as DsFilterableMultiSelect, Form as DsForm, FormGroup as DsFormGroup, IconButton as DsIconButton, Link as DsLink, ListItem as DsListItem, Loading as DsLoading, ModalBody as DsModalBody, ModalFooter as DsModalFooter, ModalHeader as DsModalHeader, MultiSelect as DsMultiSelect, OverflowMenu as DsOverflowMenu, OverflowMenuItem as DsOverflowMenuItem, ProgressBar as DsProgressBar, Search as DsSearch, SkeletonPlaceholder as DsSkeletonPlaceholder, SkeletonText as DsSkeletonText, Stack as DsStack, TabsSkeleton as DsTabsSkeleton, Tag as DsTag, TextArea as DsTextArea, TextInput as DsTextInput, Tile as DsTile, Toggle as DsToggle, Tooltip as DsTooltip, UnorderedList as DsUnorderedList, } from '@camunda/design-system/carbon-compat';
|
|
41
41
|
import { BreadcrumbSkeleton as CarbonBreadcrumbSkeleton, Button as CarbonButton, Checkbox as CarbonCheckbox, CodeSnippet as CarbonCodeSnippet, ComposedModal as CarbonComposedModal, DefinitionTooltip as CarbonDefinitionTooltip, Dropdown as CarbonDropdown, FilterableMultiSelect as CarbonFilterableMultiSelect, Form as CarbonForm, FormGroup as CarbonFormGroup, IconButton as CarbonIconButton, Link as CarbonLink, ListItem as CarbonListItem, Loading as CarbonLoading, Modal as CarbonModal, ModalBody as CarbonModalBody, ModalFooter as CarbonModalFooter, ModalHeader as CarbonModalHeader, MultiSelect as CarbonMultiSelect, OverflowMenu as CarbonOverflowMenu, OverflowMenuItem as CarbonOverflowMenuItem, PasswordInput as CarbonPasswordInput, ProgressBar as CarbonProgressBar, Search as CarbonSearch, SkeletonPlaceholder as CarbonSkeletonPlaceholder, SkeletonText as CarbonSkeletonText, Stack as CarbonStack, TabsSkeleton as CarbonTabsSkeleton, Tag as CarbonTag, TextArea as CarbonTextArea, TextInput as CarbonTextInput, Tile as CarbonTile, Toggle as CarbonToggle, Tooltip as CarbonTooltip, UnorderedList as CarbonUnorderedList, } from '@carbon/react';
|
|
42
42
|
import { createElement, Fragment, } from 'react';
|
|
43
43
|
import { useC4DesignSystem } from '../runtime/c4-console-runtime-context.js';
|
|
44
|
+
import { C4ClusterTag } from './c4-cluster-tag.js';
|
|
44
45
|
import { C4DefinitionTooltip } from './c4-definition-tooltip.js';
|
|
45
46
|
import { C4ModalDialog } from './c4-modal-dialog.js';
|
|
46
47
|
import { C4PasswordInput } from './c4-password-input.js';
|
|
@@ -49,12 +50,12 @@ export const Button = switchable(CarbonButton, DsButton);
|
|
|
49
50
|
export const Checkbox = switchable(CarbonCheckbox, DsCheckbox);
|
|
50
51
|
export const CodeSnippet = switchable(CarbonCodeSnippet, DsCodeSnippet);
|
|
51
52
|
// The c3 stage chip. c3 is public and renders the Carbon `Tag` itself, thus the
|
|
52
|
-
// ds branch is
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
export const ClusterTag = switchable(CarbonClusterTag,
|
|
53
|
+
// ds branch is `C4ClusterTag` (see ./c4-cluster-tag). It renders the DS `Badge`
|
|
54
|
+
// with the colors of the environment tags in Hub (dev/test/stage/prod →
|
|
55
|
+
// neutral/info/warning/danger). It supports the `stage` form alone and shows
|
|
56
|
+
// nothing for `clusterUuid`, because it cannot read the c3 profile store. Look
|
|
57
|
+
// the stage up at the call site before you pass it.
|
|
58
|
+
export const ClusterTag = switchable(CarbonClusterTag, C4ClusterTag);
|
|
58
59
|
// carbon-compat ships no definition-tooltip adapter, so the ds branch is the DS
|
|
59
60
|
// component directly (see ./c4-definition-tooltip). Unlike Carbon's, it renders
|
|
60
61
|
// the definition through a portal, so an ancestor that hides overflow does not
|
|
@@ -14,7 +14,6 @@ import { isDeveloperBlockedFromClusterCreate, useC4ConsoleAuthz, } from '../../r
|
|
|
14
14
|
import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
|
|
15
15
|
import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
|
|
16
16
|
import { CLUSTER_CREATION_BLOCKED_FLAG } from '../../runtime/cluster-creation-blocked.js';
|
|
17
|
-
import { CLUSTER_DUPLICATION_FLAG } from '../../runtime/cluster-duplication.js';
|
|
18
17
|
import { toApiConfig } from '../../runtime/to-api-config.js';
|
|
19
18
|
import { Modal, Stack, TextInput } from '../../ui/index.js';
|
|
20
19
|
import { safeTranslate } from '../../utils/safe-translate.js';
|
|
@@ -288,7 +287,6 @@ function isUnsupportedGenerationStarted(isUnsupportedStarting) {
|
|
|
288
287
|
}
|
|
289
288
|
export const C4ClusterDetailsApp = observer((props) => {
|
|
290
289
|
const runtime = useC4ConsoleRuntime();
|
|
291
|
-
const clusterDuplicationEnabled = useC4FeatureFlag(CLUSTER_DUPLICATION_FLAG);
|
|
292
290
|
const clusterCreationBlocked = useC4FeatureFlag(CLUSTER_CREATION_BLOCKED_FLAG);
|
|
293
291
|
const data = useC4ConsoleData();
|
|
294
292
|
const t = runtime.i18n?.t;
|
|
@@ -1034,7 +1032,6 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1034
1032
|
orgRoles: authz.orgRoles,
|
|
1035
1033
|
});
|
|
1036
1034
|
const canDuplicate = Boolean(authz.visibilities.clusters?.canCreate) &&
|
|
1037
|
-
clusterDuplicationEnabled &&
|
|
1038
1035
|
!clusterCreationBlocked &&
|
|
1039
1036
|
!developerBlockedFromClusterCreate &&
|
|
1040
1037
|
cluster?.isFailoverSource !== true;
|
|
@@ -4,14 +4,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
5
5
|
* You may not use this file except in compliance with the commercial license.
|
|
6
6
|
*/
|
|
7
|
-
import { C3ClusterTag } from '@camunda/camunda-composite-components';
|
|
8
7
|
import { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, } from '@camunda/design-system';
|
|
9
8
|
import { WarningAltFilled } from '@carbon/react/icons/index.esm.js';
|
|
10
9
|
import { TriangleAlert } from 'lucide-react';
|
|
11
10
|
import { ClusterStatusElement } from '../../components/c4-cluster-overview/applications.js';
|
|
12
11
|
import { C4PageTemplate } from '../../components/c4-page-template/c4-page-template.js';
|
|
13
12
|
import { useC4ConsoleRuntime, useC4DesignSystem, } from '../../runtime/c4-console-runtime-context.js';
|
|
14
|
-
import { BreadcrumbSkeleton, Link, SkeletonText, Stack, TabsSkeleton, Tooltip, } from '../../ui/index.js';
|
|
13
|
+
import { BreadcrumbSkeleton, ClusterTag, Link, SkeletonText, Stack, TabsSkeleton, Tooltip, } from '../../ui/index.js';
|
|
15
14
|
import { safeTranslate } from '../../utils/safe-translate.js';
|
|
16
15
|
const breadCrumbWrapperStyles = {
|
|
17
16
|
minHeight: '40px',
|
|
@@ -21,7 +20,7 @@ const breadCrumbWrapperStyles = {
|
|
|
21
20
|
alignItems: 'center',
|
|
22
21
|
};
|
|
23
22
|
// `ClusterStatusElement` and a plain version string carry no chrome of their own — unlike
|
|
24
|
-
// `
|
|
23
|
+
// `ClusterTag`'s phase badge, which is already a filled pill. Wrapping them in an explicit
|
|
25
24
|
// bordered/filled pill (rather than the design system's own "subtle" badge tokens, too close to the
|
|
26
25
|
// page background to read as a pill here) keeps all three header facts visually consistent.
|
|
27
26
|
//
|
|
@@ -209,7 +208,7 @@ const clusterHeaderBadges = ({ phaseTag, healthStatus, versionLabel, }) => {
|
|
|
209
208
|
if (!phaseTag && !healthStatus && !versionLabel) {
|
|
210
209
|
return undefined;
|
|
211
210
|
}
|
|
212
|
-
return (_jsxs(Stack, { orientation: 'horizontal', gap: 3, children: [phaseTag && _jsx(
|
|
211
|
+
return (_jsxs(Stack, { orientation: 'horizontal', gap: 3, children: [phaseTag && _jsx(ClusterTag, { stage: phaseTag }), healthStatus && (_jsx("span", { style: headerBadgeStyle, children: _jsx(ClusterStatusElement, { status: healthStatus }) })), versionLabel && _jsx("span", { style: headerBadgeStyle, children: versionLabel })] }));
|
|
213
212
|
};
|
|
214
213
|
export const C4ClusterDetailsPage = ({ loading, clusterName, isDevelopmentPlan, phaseTag, healthStatus, versionLabel, urls, onNavigateToClusters, menu, banner, secondaryReplicationNotReady, onGoToEncryptionTab, tabs, padding = 'default', }) => {
|
|
215
214
|
const runtime = useC4ConsoleRuntime();
|
|
@@ -44,7 +44,7 @@ export interface C4ClusterDetailsPageProps {
|
|
|
44
44
|
menu?: {
|
|
45
45
|
canRename: boolean;
|
|
46
46
|
canDelete: boolean;
|
|
47
|
-
/** Gated by the
|
|
47
|
+
/** Gated by the create permission: a duplicate makes a cluster. */
|
|
48
48
|
canDuplicate?: boolean;
|
|
49
49
|
onRename?: () => void;
|
|
50
50
|
onDelete?: () => void;
|
|
@@ -308,11 +308,6 @@ const C4ClusterDetailsHotBackupsTabImpl = (props) => {
|
|
|
308
308
|
versionToCompareTo: HOT_BACKUP_MIN_VERSION,
|
|
309
309
|
})
|
|
310
310
|
: false;
|
|
311
|
-
// Same-cluster restore is currently dev-only. Until the operator side ships
|
|
312
|
-
// the Restore CRD on int/prod, the backend POST /restore endpoint returns 501
|
|
313
|
-
// — gate the entire UI surface on this flag so the action never reaches users
|
|
314
|
-
// who can't actually use it.
|
|
315
|
-
const isBackupRestoreEnabled = runtime.featureFlags?.isEnabled?.('console.backupRestore') ?? false;
|
|
316
311
|
const backupItems = hotBackups.map((backup) => ({
|
|
317
312
|
id: backup.uuid,
|
|
318
313
|
uuid: backup.uuid,
|
|
@@ -328,9 +323,7 @@ const C4ClusterDetailsHotBackupsTabImpl = (props) => {
|
|
|
328
323
|
// generationUuid label. Without the uuid the backend rejects (legacy
|
|
329
324
|
// contract); for `In progress` / `Failed` rows the data isn't a valid
|
|
330
325
|
// restore source even if a uuid was set early.
|
|
331
|
-
canRestore:
|
|
332
|
-
backup.status === BackupStatus.COMPLETE &&
|
|
333
|
-
Boolean(backup.generationUuid),
|
|
326
|
+
canRestore: backup.status === BackupStatus.COMPLETE && Boolean(backup.generationUuid),
|
|
334
327
|
zeebeStatus: String(backup.zeebeStatus),
|
|
335
328
|
operateStatus: String(backup.operateStatus),
|
|
336
329
|
tasklistStatus: String(backup.tasklistStatus),
|
|
@@ -416,14 +409,9 @@ const C4ClusterDetailsHotBackupsTabImpl = (props) => {
|
|
|
416
409
|
// Create + Restore conflict with an in-flight restore (cluster is
|
|
417
410
|
// unavailable for new snapshots, and only one restore may run at a
|
|
418
411
|
// time); Delete stays available — see 2135-same-cluster-restore.md.
|
|
419
|
-
// Restore is additionally feature-flagged off until the operator
|
|
420
|
-
// ships its side; per-row `canRestore` repeats this gate but the
|
|
421
|
-
// top-level flag short-circuits the whole action.
|
|
422
412
|
canCreate: canMutateCluster && !cluster?.restoreInProgress,
|
|
423
413
|
canDelete: canMutateCluster,
|
|
424
|
-
canRestore:
|
|
425
|
-
canMutateCluster &&
|
|
426
|
-
!cluster?.restoreInProgress,
|
|
414
|
+
canRestore: canMutateCluster && !cluster?.restoreInProgress,
|
|
427
415
|
}, onCreateBackup: () => {
|
|
428
416
|
if (!isHotBackupEnabled)
|
|
429
417
|
return;
|