@camunda/ccma-saas-frontend 0.20.5 → 0.21.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/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +68 -2
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.types.d.ts +8 -0
- package/lib/esm/widgets/cluster-details/cluster-details-tab-url.d.ts +22 -0
- package/lib/esm/widgets/cluster-details/cluster-details-tab-url.js +59 -0
- package/package.json +1 -1
package/lib/esm/index.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ export { C4ClusterDetailsApp } from './widgets/cluster-details/c4-cluster-detail
|
|
|
215
215
|
export type { C4ClusterDetailsAppProps, C4ClusterDetailsNavigateEvent, C4ClusterDetailsTabId, } from './widgets/cluster-details/c4-cluster-details-app.types.js';
|
|
216
216
|
export { C4ClusterDetailsPage } from './widgets/cluster-details/c4-cluster-details-page.js';
|
|
217
217
|
export type { C4ClusterDetailsPageBanner, C4ClusterDetailsPageProps, C4ClusterDetailsTab, } from './widgets/cluster-details/c4-cluster-details-page.types.js';
|
|
218
|
+
export { parseClusterDetailsTabId } from './widgets/cluster-details/cluster-details-tab-url.js';
|
|
218
219
|
export { CLUSTER_DETAILS_TABS, type ClusterDetailsTabDescriptor, clusterDetailsTab, } from './widgets/cluster-details/cluster-details-tabs.js';
|
|
219
220
|
export { C4ClustersPage } from './widgets/clusters/c4-clusters-page.js';
|
|
220
221
|
export type { C4ClustersNavigateEvent, C4ClustersPageProps, C4ClustersPageTranslations, } from './widgets/clusters/c4-clusters-page.types.js';
|
package/lib/esm/index.js
CHANGED
|
@@ -123,6 +123,7 @@ export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils
|
|
|
123
123
|
export { C4ClusterClientDetailsApp } from './widgets/cluster-client-details/c4-cluster-client-details-app.js';
|
|
124
124
|
export { C4ClusterDetailsApp } from './widgets/cluster-details/c4-cluster-details-app.js';
|
|
125
125
|
export { C4ClusterDetailsPage } from './widgets/cluster-details/c4-cluster-details-page.js';
|
|
126
|
+
export { parseClusterDetailsTabId } from './widgets/cluster-details/cluster-details-tab-url.js';
|
|
126
127
|
export { CLUSTER_DETAILS_TABS, clusterDetailsTab, } from './widgets/cluster-details/cluster-details-tabs.js';
|
|
127
128
|
export { C4ClustersPage } from './widgets/clusters/c4-clusters-page.js';
|
|
128
129
|
export { C4ConnectorManagementExecutableDetailsPage } from './widgets/connector-management/c4-connector-management-executable-details-page.js';
|
|
@@ -21,6 +21,7 @@ import { clusterHealthOverride } from '../cluster-health-override.js';
|
|
|
21
21
|
import { useClusterApiClients } from '../environment/use-cluster-api-clients.js';
|
|
22
22
|
import { useClusterVersionFlags } from '../environment/use-cluster-version-flags.js';
|
|
23
23
|
import { C4ClusterDetailsPage } from './c4-cluster-details-page.js';
|
|
24
|
+
import { readClusterDetailsTabFromUrl, writeClusterDetailsTabToUrl, } from './cluster-details-tab-url.js';
|
|
24
25
|
import { clusterDetailsTab } from './cluster-details-tabs.js';
|
|
25
26
|
import { getClusterRegionCode } from './cluster-region-code.js';
|
|
26
27
|
import { C4ClusterDetailsActivityTab } from './tabs/c4-cluster-details-activity-tab.js';
|
|
@@ -350,7 +351,16 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
350
351
|
const [clusterLoad24h, setClusterLoad24h] = useState([]);
|
|
351
352
|
const [clusterLoadLoading, setClusterLoadLoading] = useState(false);
|
|
352
353
|
const [statisticsConfig, setStatisticsConfig] = useState(undefined);
|
|
353
|
-
|
|
354
|
+
// Order: `desiredTabId` from the host, then `?tab=` in the URL, then the
|
|
355
|
+
// default. The URL is read once. A host that gives no `desiredTabId` (for
|
|
356
|
+
// example Hub) gets its tab back after a reload. A host that has its own
|
|
357
|
+
// tab routes opts out with `syncTabToUrl={false}`.
|
|
358
|
+
const syncTabToUrl = props.syncTabToUrl !== false && !props.desiredTabId;
|
|
359
|
+
const [initialUrlTabId] = useState(() => syncTabToUrl ? readClusterDetailsTabFromUrl() : undefined);
|
|
360
|
+
// Set when the URL tab is not a tab of this cluster (for example a hidden
|
|
361
|
+
// tab). Then the normal default applies, including the failover rule.
|
|
362
|
+
const [urlTabDropped, setUrlTabDropped] = useState(false);
|
|
363
|
+
const [activeTabId, setActiveTabId] = useState(props.desiredTabId ?? initialUrlTabId ?? 'overview');
|
|
354
364
|
useEffect(() => {
|
|
355
365
|
if (props.desiredTabId) {
|
|
356
366
|
setActiveTabId(props.desiredTabId);
|
|
@@ -1343,13 +1353,38 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1343
1353
|
useEffect(() => {
|
|
1344
1354
|
if (props.desiredTabId)
|
|
1345
1355
|
return;
|
|
1356
|
+
// A URL tab beats the failover default, except `overview`: it is the
|
|
1357
|
+
// default too, and a stale `?tab=overview` from an earlier click must not
|
|
1358
|
+
// switch the Encryption default off on every reload.
|
|
1359
|
+
if (initialUrlTabId && initialUrlTabId !== 'overview' && !urlTabDropped) {
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1346
1362
|
if (appliedFailoverEncryptionDefaultRef.current)
|
|
1347
1363
|
return;
|
|
1348
1364
|
if (!needsFailoverEncryptionAction)
|
|
1349
1365
|
return;
|
|
1350
1366
|
appliedFailoverEncryptionDefaultRef.current = true;
|
|
1351
1367
|
setActiveTabId('encryption');
|
|
1352
|
-
}, [
|
|
1368
|
+
}, [
|
|
1369
|
+
props.desiredTabId,
|
|
1370
|
+
initialUrlTabId,
|
|
1371
|
+
urlTabDropped,
|
|
1372
|
+
needsFailoverEncryptionAction,
|
|
1373
|
+
]);
|
|
1374
|
+
// A host with `syncTabToUrl={false}` (Console) can go from a route with a
|
|
1375
|
+
// tab to a route with no valid tab. `desiredTabId` is then `undefined`, and
|
|
1376
|
+
// the tab must go back to the normal default, as on a first visit.
|
|
1377
|
+
const previousDesiredTabIdRef = useRef(props.desiredTabId);
|
|
1378
|
+
useEffect(() => {
|
|
1379
|
+
const previous = previousDesiredTabIdRef.current;
|
|
1380
|
+
previousDesiredTabIdRef.current = props.desiredTabId;
|
|
1381
|
+
if (props.desiredTabId || !previous || props.syncTabToUrl !== false) {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
setActiveTabId(needsFailoverEncryptionAction ? 'encryption' : 'overview');
|
|
1385
|
+
// Only a change of `desiredTabId` runs this. The other values are read
|
|
1386
|
+
// at that time.
|
|
1387
|
+
}, [props.desiredTabId]);
|
|
1353
1388
|
const encryptionComponent = (_jsx(C4ClusterDetailsEncryptionTab, { cluster: cluster, orgId: props.orgId, clusterId: props.clusterId, apiConfig: apiConfig, translate: t ?? ((key) => key), activeTabId: activeTabId, onReloadCluster: reloadCluster, restoreInProgress: cluster?.restoreInProgress, isFailoverTarget: isFailoverTarget, secondaryReplicationNotReady: secondaryReplicationNotReady, docsUrls: {
|
|
1354
1389
|
encryption: urls.docs.encryption,
|
|
1355
1390
|
encryptionCli: urls.docs.encryptionCli,
|
|
@@ -1503,6 +1538,35 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1503
1538
|
cluster?.generation?.versions?.zeebe,
|
|
1504
1539
|
t,
|
|
1505
1540
|
]);
|
|
1541
|
+
// The org request is done, with a result or with an error. After an error
|
|
1542
|
+
// `orgInfo` stays `undefined`, so `orgInfo` alone cannot tell "not yet" from
|
|
1543
|
+
// "failed".
|
|
1544
|
+
const orgInfoRequest = data.orgInfo?.[props.orgId];
|
|
1545
|
+
const isOrgInfoSettled = Boolean(orgInfoRequest && !orgInfoRequest.isLoading);
|
|
1546
|
+
// Check the URL tab against the tabs of this cluster once the data that
|
|
1547
|
+
// decides tab visibility has loaded.
|
|
1548
|
+
useEffect(() => {
|
|
1549
|
+
if (!initialUrlTabId || urlTabDropped)
|
|
1550
|
+
return;
|
|
1551
|
+
if (authz.isLoading ||
|
|
1552
|
+
isClusterLoading ||
|
|
1553
|
+
isCreationParametersLoading ||
|
|
1554
|
+
!isOrgInfoSettled) {
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
if (tabs.some((tab) => tab.id === initialUrlTabId))
|
|
1558
|
+
return;
|
|
1559
|
+
setUrlTabDropped(true);
|
|
1560
|
+
setActiveTabId((current) => current === initialUrlTabId ? 'overview' : current);
|
|
1561
|
+
}, [
|
|
1562
|
+
initialUrlTabId,
|
|
1563
|
+
urlTabDropped,
|
|
1564
|
+
authz.isLoading,
|
|
1565
|
+
isClusterLoading,
|
|
1566
|
+
isCreationParametersLoading,
|
|
1567
|
+
isOrgInfoSettled,
|
|
1568
|
+
tabs,
|
|
1569
|
+
]);
|
|
1506
1570
|
useEffect(() => {
|
|
1507
1571
|
// Only fall back once we have confirmed that the cluster doesn't
|
|
1508
1572
|
// support PrivateLink. Both the cluster fetch and the
|
|
@@ -1554,6 +1618,8 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1554
1618
|
clusterId: props.clusterId,
|
|
1555
1619
|
tabId: next,
|
|
1556
1620
|
});
|
|
1621
|
+
if (syncTabToUrl)
|
|
1622
|
+
writeClusterDetailsTabToUrl(next);
|
|
1557
1623
|
};
|
|
1558
1624
|
return (_jsxs(_Fragment, { children: [_jsx(C4ClusterDetailsPage, { loading: isClusterLoading || authz.isLoading, padding: props.padding, clusterName: cluster?.name, phaseTag: headerPhaseTag, healthStatus: headerHealthStatus, versionLabel: headerVersionLabel, regionCode: headerRegionCode, isDevelopmentPlan: cluster?.planType?.development, urls: { clusters: urls.clusters }, onNavigateToClusters: () => props.onNavigate?.({ kind: 'clusters', orgId: props.orgId }), menu: {
|
|
1559
1625
|
canRename,
|
|
@@ -43,6 +43,14 @@ export interface C4ClusterDetailsAppProps {
|
|
|
43
43
|
clusterId: string;
|
|
44
44
|
desiredTabId?: C4ClusterDetailsTabId;
|
|
45
45
|
onNavigate?: (event: C4ClusterDetailsNavigateEvent) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Keep the active tab in the `?tab=` search param of the browser URL
|
|
48
|
+
* (`history.replaceState`) and read it back on load. Defaults to `true`, so a
|
|
49
|
+
* host with no tab routes gets the tab back after a reload. Set `false` if
|
|
50
|
+
* the host owns the URL or uses `?tab=` itself. It has no effect when
|
|
51
|
+
* `desiredTabId` is set: then the host controls the tab.
|
|
52
|
+
*/
|
|
53
|
+
syncTabToUrl?: boolean;
|
|
46
54
|
urls: C4ClusterDetailsUrls;
|
|
47
55
|
/**
|
|
48
56
|
* Side/top/bottom padding around the page. Defaults to `'default'`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { C4ClusterDetailsTabId } from './c4-cluster-details-app.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Search param that holds the active tab. The name is the same one that the
|
|
4
|
+
* Console route uses (`?tab=`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const CLUSTER_DETAILS_TAB_PARAM = "tab";
|
|
7
|
+
/**
|
|
8
|
+
* Turn a raw `tab` value into a tab id. Return `undefined` if the value is
|
|
9
|
+
* not a known tab.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseClusterDetailsTabId(value: string | null | undefined): C4ClusterDetailsTabId | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Read the tab from `window.location.search`. Return `undefined` if there is
|
|
14
|
+
* no window, no `tab` param, or an unknown value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readClusterDetailsTabFromUrl(): C4ClusterDetailsTabId | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Write the tab to the current URL with `history.replaceState`. This keeps
|
|
19
|
+
* the other search params, the hash and `history.state`, so a host router does
|
|
20
|
+
* not see a new entry. It never adds a history entry.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeClusterDetailsTabToUrl(tabId: C4ClusterDetailsTabId): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { CLUSTER_DETAILS_TABS } from './cluster-details-tabs.js';
|
|
7
|
+
/**
|
|
8
|
+
* Search param that holds the active tab. The name is the same one that the
|
|
9
|
+
* Console route uses (`?tab=`).
|
|
10
|
+
*/
|
|
11
|
+
export const CLUSTER_DETAILS_TAB_PARAM = 'tab';
|
|
12
|
+
// Console used the old name `secureConnectivity` for this tab in its URLs.
|
|
13
|
+
const TAB_ALIASES = {
|
|
14
|
+
secureConnectivity: 'privateNetworking',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Turn a raw `tab` value into a tab id. Return `undefined` if the value is
|
|
18
|
+
* not a known tab.
|
|
19
|
+
*/
|
|
20
|
+
export function parseClusterDetailsTabId(value) {
|
|
21
|
+
if (!value)
|
|
22
|
+
return undefined;
|
|
23
|
+
const aliased = TAB_ALIASES[value] ?? value;
|
|
24
|
+
return CLUSTER_DETAILS_TABS.find((tab) => tab.id === aliased)?.id;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read the tab from `window.location.search`. Return `undefined` if there is
|
|
28
|
+
* no window, no `tab` param, or an unknown value.
|
|
29
|
+
*/
|
|
30
|
+
export function readClusterDetailsTabFromUrl() {
|
|
31
|
+
try {
|
|
32
|
+
if (typeof window === 'undefined')
|
|
33
|
+
return undefined;
|
|
34
|
+
const value = new URLSearchParams(window.location.search).get(CLUSTER_DETAILS_TAB_PARAM);
|
|
35
|
+
return parseClusterDetailsTabId(value);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Write the tab to the current URL with `history.replaceState`. This keeps
|
|
43
|
+
* the other search params, the hash and `history.state`, so a host router does
|
|
44
|
+
* not see a new entry. It never adds a history entry.
|
|
45
|
+
*/
|
|
46
|
+
export function writeClusterDetailsTabToUrl(tabId) {
|
|
47
|
+
try {
|
|
48
|
+
if (typeof window === 'undefined')
|
|
49
|
+
return;
|
|
50
|
+
const url = new URL(window.location.href);
|
|
51
|
+
if (url.searchParams.get(CLUSTER_DETAILS_TAB_PARAM) === tabId)
|
|
52
|
+
return;
|
|
53
|
+
url.searchParams.set(CLUSTER_DETAILS_TAB_PARAM, tabId);
|
|
54
|
+
window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// The URL is only a hint for a reload. If it fails, the tab still works.
|
|
58
|
+
}
|
|
59
|
+
}
|