@camunda/ccma-saas-frontend 0.6.0 → 0.7.1

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 (78) hide show
  1. package/lib/esm/components/c4-billing-page/elements/value-metric.js +2 -4
  2. package/lib/esm/components/c4-charts-dashboard/elements/bar-chart.js +24 -10
  3. package/lib/esm/components/c4-cluster-details-secure-connectivity/c4-cluster-details-secure-connectivity.js +6 -2
  4. package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.d.ts +1 -1
  5. package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.js +4 -2
  6. package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.mocks.js +1 -1
  7. package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.types.d.ts +4 -0
  8. package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider-modal.js +17 -7
  9. package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider.d.ts +12 -1
  10. package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider.js +9 -3
  11. package/lib/esm/components/c4-cluster-settings/elements/session-settings.d.ts +13 -0
  12. package/lib/esm/components/c4-cluster-settings/elements/session-settings.js +69 -0
  13. package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.js +21 -3
  14. package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.mocks.js +2 -1
  15. package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.types.d.ts +1 -0
  16. package/lib/esm/components/c4-create-cluster/c4-create-cluster.js +4 -4
  17. package/lib/esm/components/c4-create-cluster-api-client-modal/c4-create-cluster-api-client-modal.js +1 -2
  18. package/lib/esm/components/c4-create-connector-secret-modal/c4-create-connector-secret-modal.js +2 -2
  19. package/lib/esm/components/c4-create-console-api-client-modal/c4-create-console-api-client-modal.js +13 -2
  20. package/lib/esm/components/c4-create-ip-whitelist-modal/c4-create-ip-whitelist-modal.js +8 -4
  21. package/lib/esm/components/c4-create-trial-organization-modal/c4-create-trial-organization-modal.js +1 -2
  22. package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.d.ts +1 -1
  23. package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.js +3 -3
  24. package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.types.d.ts +7 -0
  25. package/lib/esm/components/c4-help-center/c4-help-center.js +3 -1
  26. package/lib/esm/components/c4-info-tooltip/c4-info-tooltip.js +1 -1
  27. package/lib/esm/components/c4-management-api/c4-management-api.js +8 -3
  28. package/lib/esm/components/c4-navigation/c4-navigation.js +17 -9
  29. package/lib/esm/components/c4-sm-dashboard/health-status.js +1 -1
  30. package/lib/esm/components/c4-usage-history/elements/usage-history-charts.d.ts +8 -2
  31. package/lib/esm/components/c4-usage-history/elements/usage-history-charts.js +2 -2
  32. package/lib/esm/components/c4-usage-metrics-per-cluster/c4-usage-metrics-per-cluster.js +3 -1
  33. package/lib/esm/components/shared-charts/ds-line-chart.js +25 -11
  34. package/lib/esm/components/shared-charts/recharts-tokens.d.ts +16 -0
  35. package/lib/esm/components/shared-charts/recharts-tokens.js +31 -0
  36. package/lib/esm/i18n/en/entities/orgroles.json +2 -2
  37. package/lib/esm/i18n/en/modals/apiclients.json +4 -1
  38. package/lib/esm/i18n/en/pages/clusterdetails.json +2 -2
  39. package/lib/esm/i18n/en/pages/orgmanagement.json +9 -1
  40. package/lib/esm/runtime/build-cluster-swagger-url.js +2 -2
  41. package/lib/esm/runtime/nav/camunda-apps.js +2 -2
  42. package/lib/esm/ui/c4-definition-tooltip.d.ts +15 -0
  43. package/lib/esm/ui/c4-definition-tooltip.js +43 -0
  44. package/lib/esm/ui/index.d.ts +6 -0
  45. package/lib/esm/ui/index.js +20 -3
  46. package/lib/esm/utils/http-error-message.d.ts +14 -0
  47. package/lib/esm/utils/http-error-message.js +35 -0
  48. package/lib/esm/utils/role-labels.js +5 -4
  49. package/lib/esm/widgets/cluster-client-details/c4-cluster-client-details-app.js +5 -5
  50. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.d.ts +3 -0
  51. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +153 -37
  52. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.types.d.ts +3 -0
  53. package/lib/esm/widgets/cluster-details/c4-cluster-details-page.js +51 -16
  54. package/lib/esm/widgets/cluster-details/c4-cluster-details-page.types.d.ts +5 -0
  55. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-alerts-tab.d.ts +1 -0
  56. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-alerts-tab.js +2 -2
  57. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-clients-tab.js +3 -4
  58. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.js +2 -2
  59. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-encryption-tab.js +1 -1
  60. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +2 -2
  61. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.d.ts +1 -1
  62. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.js +16 -5
  63. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +16 -16
  64. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +115 -28
  65. package/lib/esm/widgets/connector-management/c4-connector-management-executable-details-page.js +2 -1
  66. package/lib/esm/widgets/connector-management/c4-connector-management-executables-table-page.js +2 -1
  67. package/lib/esm/widgets/connector-management/c4-connector-management-outbound-details-page.js +2 -1
  68. package/lib/esm/widgets/connector-management/c4-connector-management-page.js +2 -1
  69. package/lib/esm/widgets/dashboard/c4-dashboard-app.js +177 -17
  70. package/lib/esm/widgets/dashboard/c4-dashboard-app.types.d.ts +15 -2
  71. package/lib/esm/widgets/group-details/c4-group-details-page.js +2 -2
  72. package/lib/esm/widgets/management/c4-management-app.js +369 -45
  73. package/lib/esm/widgets/management/tabs/c4-management-api-tab.js +22 -7
  74. package/lib/esm/widgets/management/tabs/c4-management-pricing-tab.js +1 -2
  75. package/lib/esm/widgets/management/tabs/c4-management-usage-tab.d.ts +30 -1
  76. package/lib/esm/widgets/management/tabs/c4-management-usage-tab.js +41 -15
  77. package/lib/esm/widgets/user-details/c4-user-details-page.js +3 -3
  78. package/package.json +4 -4
@@ -1,14 +1,24 @@
1
1
  import { jsxs as _jsxs, 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 { ConsoleValueMetricsService, HdpService, } from '@camunda/ccma-api';
2
8
  import { observer } from 'mobx-react-lite';
3
- import { useCallback, useEffect, useMemo } from 'react';
9
+ import { useCallback, useEffect, useMemo, useState } from 'react';
4
10
  import { getClusterLoadConfig } from '../../components/c4-cluster-overview/c4-cluster-overview.js';
5
11
  import { C4ConsoleDashboard } from '../../components/c4-console-dashboard/c4-console-dashboard.js';
6
12
  import { C4OldDashboard } from '../../components/c4-old-dashboard/c4-old-dashboard.js';
7
13
  import { getC4DashboardUrls } from '../../externalUrls.const.js';
8
14
  import { hasAvailableClusterReservation, isDeveloperBlockedFromClusterCreate, useC4ConsoleAuthz, } from '../../runtime/c4-console-authz.js';
9
15
  import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
16
+ import { useC4ConsoleRuntime } from '../../runtime/c4-console-runtime-context.js';
17
+ import { toApiConfig } from '../../runtime/to-api-config.js';
10
18
  import { isClusterReconciliationPaused } from '../is-cluster-reconciliation-paused.js';
11
19
  const DAY = 24 * 60 * 60 * 1000;
20
+ // Same window the console frontend requests for these charts.
21
+ const USAGE_DAYS = 360;
12
22
  function safeTranslate(t, key, fallback, options) {
13
23
  try {
14
24
  const translated = t?.(key, options);
@@ -47,6 +57,54 @@ function formatDateTime(date) {
47
57
  }
48
58
  return date.toISOString();
49
59
  }
60
+ /** Clusters reach this widget in more than one shape, so try each id field. */
61
+ function getClusterId(cluster) {
62
+ if (typeof cluster !== 'object' || cluster === null) {
63
+ return undefined;
64
+ }
65
+ const fields = cluster;
66
+ for (const field of ['uuid', 'id', 'clusterId']) {
67
+ const value = fields[field];
68
+ if (typeof value === 'string' && value) {
69
+ return value;
70
+ }
71
+ }
72
+ return undefined;
73
+ }
74
+ /**
75
+ * Turns per-day usage rows into the chart series the dashboard renders.
76
+ *
77
+ * Rows are grouped by cluster, so `clusterNames` resolves the series name; a
78
+ * row with no cluster is org-wide and falls back to the organization name.
79
+ * An unknown cluster id stays as the id rather than being dropped — a deleted
80
+ * cluster still has usage in the window.
81
+ */
82
+ function toUsageChartPoints(entries, clusterNames, orgName) {
83
+ const pi = [];
84
+ const di = [];
85
+ let latestTimestamp = Number.NEGATIVE_INFINITY;
86
+ let latestTaskUsers = 0;
87
+ for (const entry of entries) {
88
+ const timestamp = new Date(entry.startDate).getTime();
89
+ if (Number.isNaN(timestamp)) {
90
+ continue;
91
+ }
92
+ const group = entry.clusterId
93
+ ? (clusterNames.get(entry.clusterId) ?? entry.clusterId)
94
+ : orgName;
95
+ const date = new Date(timestamp).toISOString().substring(0, 10);
96
+ pi.push({ date, group, value: entry.processInstances });
97
+ di.push({ date, group, value: entry.decisionInstances });
98
+ if (timestamp > latestTimestamp) {
99
+ latestTimestamp = timestamp;
100
+ latestTaskUsers = 0;
101
+ }
102
+ if (timestamp === latestTimestamp) {
103
+ latestTaskUsers += entry.taskUsers ?? 0;
104
+ }
105
+ }
106
+ return { pi, di, latestTaskUsers };
107
+ }
50
108
  /**
51
109
  * Dashboard widget - main application component
52
110
  *
@@ -57,9 +115,11 @@ function formatDateTime(date) {
57
115
  * - Quick links
58
116
  */
59
117
  export const C4DashboardApp = observer((props) => {
60
- const { orgId, t, onNavigate, urls, billing, theme = 'white' } = props;
118
+ const { orgId, t, onNavigate, urls, billing, hdpValueMetricsFor2025Enabled = false, isLicensingModel2025: isLicensingModel2025Prop, theme = 'white', } = props;
61
119
  const authz = useC4ConsoleAuthz({ orgId });
62
120
  const data = useC4ConsoleData();
121
+ const runtime = useC4ConsoleRuntime();
122
+ const apiConfig = useMemo(() => toApiConfig(runtime), [runtime]);
63
123
  const externalUrls = useMemo(() => getC4DashboardUrls({ orgId, overrides: urls }), [orgId, urls]);
64
124
  const { fetchClusters, fetchMembers, fetchAudits, fetchClients, fetchClusterCapacity, getClusters, } = data;
65
125
  const orgInfo = data.getOrgInfo(orgId);
@@ -75,18 +135,6 @@ export const C4DashboardApp = observer((props) => {
75
135
  useEffect(() => {
76
136
  if (!orgId)
77
137
  return;
78
- const getClusterId = (cluster) => {
79
- const uuid = cluster?.uuid;
80
- if (typeof uuid === 'string' && uuid)
81
- return uuid;
82
- const id = cluster?.id;
83
- if (typeof id === 'string' && id)
84
- return id;
85
- const clusterId = cluster?.clusterId;
86
- if (typeof clusterId === 'string' && clusterId)
87
- return clusterId;
88
- return undefined;
89
- };
90
138
  // Fetch clusters first; capacity depends on cluster IDs.
91
139
  // IMPORTANT: Do not gate capacity fetching behind members/audits.
92
140
  // Those endpoints can fail due to permissions; load should still work.
@@ -142,6 +190,118 @@ export const C4DashboardApp = observer((props) => {
142
190
  // Do not block dashboard rendering on this call.
143
191
  void data.fetchOrgInfo(orgId);
144
192
  }, [data.fetchOrgInfo, orgId]);
193
+ // Usage for the instance charts and the task users tile.
194
+ //
195
+ // The widget reads this itself so that every host shows the same charts.
196
+ // A host that already holds the data passes `billing` instead, and then no
197
+ // request is made — the console frontend keeps its own store as the source.
198
+ const hostProvidesBilling = billing !== undefined;
199
+ // Keep the org with the usage. `orgId` is a prop, and the hosts do not
200
+ // remount this widget when it changes, so the state of the previous org
201
+ // stays until the new read completes. Without the org here, the dashboard
202
+ // of one org shows the numbers of another for that time.
203
+ const [usage, setUsage] = useState();
204
+ const usagePerDay = usage?.orgId === orgId ? usage.entries : [];
205
+ const isLicensingModel2025 = isLicensingModel2025Prop ?? orgInfo?.metadata?.licensingModel === '2025';
206
+ // The same gate `C4ManagementApp` applies, so a 2025 org's dashboard and
207
+ // usage tab read the same numbers from the same source.
208
+ const usageFromHdp = hdpValueMetricsFor2025Enabled && isLicensingModel2025;
209
+ // The licensing model selects the usage source, and it comes from orgInfo,
210
+ // which is not loaded on the first render. Wait for it: without this gate a
211
+ // 2025 org reads the console source first, and then reads HDP again when
212
+ // orgInfo arrives. That is one request too many, and it shows the legacy
213
+ // numbers in between.
214
+ //
215
+ // `isLoading === false` is true only for a settled entry, so it says
216
+ // "settled" directly. `error`/`lastFetched` also work, but only because
217
+ // the data context maps the store's in-flight `null` to `undefined` — do
218
+ // not depend on that. A settled entry that holds an error keeps the
219
+ // console source, because no usage at all is worse.
220
+ const orgInfoState = data.orgInfo[orgId];
221
+ const licensingModelKnown = isLicensingModel2025Prop !== undefined ||
222
+ orgInfoState?.isLoading === false;
223
+ useEffect(() => {
224
+ if (!orgId || hostProvidesBilling || !licensingModelKnown) {
225
+ return;
226
+ }
227
+ let cancelled = false;
228
+ const load = async () => {
229
+ try {
230
+ const entries = usageFromHdp
231
+ ? (await HdpService.getUsageMetrics({
232
+ config: apiConfig,
233
+ params: { orgId, queryRange: `${USAGE_DAYS}-d` },
234
+ })).valueMetrics.valueMetrics.map((entry) => ({
235
+ orgId,
236
+ clusterId: entry.clusterId,
237
+ startDate: new Date(entry.date.ts),
238
+ processInstances: entry.pi,
239
+ decisionInstances: entry.di,
240
+ taskUsers: entry.tu,
241
+ }))
242
+ : await ConsoleValueMetricsService.getValueMetricsPerDays({
243
+ config: apiConfig,
244
+ params: { orgId, days: USAGE_DAYS },
245
+ });
246
+ if (!cancelled) {
247
+ setUsage({ orgId, entries: entries ?? [] });
248
+ }
249
+ }
250
+ catch {
251
+ // The charts render their empty state; the rest of the dashboard is
252
+ // unaffected by a failed usage read.
253
+ if (!cancelled) {
254
+ setUsage({ orgId, entries: [] });
255
+ }
256
+ }
257
+ };
258
+ void load();
259
+ return () => {
260
+ cancelled = true;
261
+ };
262
+ }, [
263
+ apiConfig,
264
+ hostProvidesBilling,
265
+ licensingModelKnown,
266
+ orgId,
267
+ usageFromHdp,
268
+ ]);
269
+ // Read during render (not inside the memo below) so that MobX keeps
270
+ // tracking it: a memo whose dependencies did not change returns its cached
271
+ // value without re-reading the observable, and the series would keep the
272
+ // cluster ids it resolved before the cluster names arrived.
273
+ const usageClusters = getClusters(orgId);
274
+ const fetchedBilling = useMemo(() => {
275
+ if (hostProvidesBilling) {
276
+ return undefined;
277
+ }
278
+ const clusterNames = new Map();
279
+ for (const cluster of usageClusters ?? []) {
280
+ const id = getClusterId(cluster);
281
+ if (id && typeof cluster?.name === 'string') {
282
+ clusterNames.set(id, cluster.name);
283
+ }
284
+ }
285
+ const { pi, di, latestTaskUsers } = toUsageChartPoints(usagePerDay, clusterNames, orgInfo?.name ?? orgId);
286
+ // Task users and decision instances are not part of the 2025 licensing
287
+ // model, so a 2025 org never shows them — the same rule the billing tab
288
+ // and the console frontend apply.
289
+ return {
290
+ taskUsersAmount: isLicensingModel2025 ? undefined : latestTaskUsers,
291
+ processInstancesChart: { dataPoints: pi },
292
+ decisionInstancesChart: isLicensingModel2025
293
+ ? undefined
294
+ : { dataPoints: di },
295
+ };
296
+ }, [
297
+ hostProvidesBilling,
298
+ isLicensingModel2025,
299
+ orgId,
300
+ orgInfo?.name,
301
+ usageClusters,
302
+ usagePerDay,
303
+ ]);
304
+ const effectiveBilling = billing ?? fetchedBilling;
145
305
  // Get data from context (reactive via MobX)
146
306
  const clustersCache = data.clusters[orgId];
147
307
  const membersCache = data.members[orgId];
@@ -357,14 +517,14 @@ export const C4DashboardApp = observer((props) => {
357
517
  }, displayFirstCTA: false }));
358
518
  }
359
519
  // Render dashboard component
360
- return (_jsx(C4ConsoleDashboard, { orgId: orgId, usersAmount: canViewUsers ? (shouldLoadMembers ? usersCount : 'N/A') : 'N/A', taskUsersAmount: billing?.taskUsersAmount || 0, clustersAmount: clusters.length, clientsAmount: clientsCount, clusters: clustersOverview, clusterLoadAvailable: clusterLoadAvailable, processInstancesChart: {
520
+ return (_jsx(C4ConsoleDashboard, { orgId: orgId, usersAmount: canViewUsers ? (shouldLoadMembers ? usersCount : 'N/A') : 'N/A', taskUsersAmount: effectiveBilling?.taskUsersAmount || 0, clustersAmount: clusters.length, clientsAmount: clientsCount, clusters: clustersOverview, clusterLoadAvailable: clusterLoadAvailable, processInstancesChart: {
361
521
  title: '',
362
522
  theme,
363
523
  axes: {
364
524
  titleBottom: 'Time period',
365
525
  titleLeft: 'Instances',
366
526
  },
367
- dataPoints: billing?.processInstancesChart?.dataPoints || [],
527
+ dataPoints: effectiveBilling?.processInstancesChart?.dataPoints || [],
368
528
  toolbar: { enabled: false },
369
529
  zoomBar: { enabled: false },
370
530
  }, decisionInstancesChart: {
@@ -374,7 +534,7 @@ export const C4DashboardApp = observer((props) => {
374
534
  titleBottom: 'Time period',
375
535
  titleLeft: 'Instances',
376
536
  },
377
- dataPoints: billing?.decisionInstancesChart?.dataPoints || [],
537
+ dataPoints: effectiveBilling?.decisionInstancesChart?.dataPoints || [],
378
538
  toolbar: { enabled: false },
379
539
  zoomBar: { enabled: false },
380
540
  }, activityEntries: activityEntries, alerts: [], quickLinks: quickLinks, permissions: {
@@ -17,8 +17,10 @@ export interface C4DashboardAppProps {
17
17
  */
18
18
  urls?: C4DashboardUrls;
19
19
  /**
20
- * Optional billing/metrics data
21
- * If not provided, the widget will use fallback values
20
+ * Usage data for the process/decision instance charts and the task users
21
+ * tile. Optional: when the host passes nothing, the widget reads the same
22
+ * numbers itself through the runtime. Pass it only to override that — the
23
+ * console frontend does, because it already holds the data in its own store.
22
24
  */
23
25
  billing?: {
24
26
  taskUsersAmount?: number;
@@ -37,6 +39,17 @@ export interface C4DashboardAppProps {
37
39
  }>;
38
40
  };
39
41
  };
42
+ /**
43
+ * Set when the host reads 2025-model usage from HDP. Mirrors the same prop on
44
+ * `C4ManagementApp`, so both surfaces read a 2025 org's numbers from one
45
+ * source. Only used when the host passes no `billing` prop.
46
+ */
47
+ hdpValueMetricsFor2025Enabled?: boolean;
48
+ /**
49
+ * Overrides the licensing model that the widget reads from the organization.
50
+ * Mirrors the same prop on `C4ManagementApp`.
51
+ */
52
+ isLicensingModel2025?: boolean;
40
53
  /**
41
54
  * Theme for charts (default: 'white')
42
55
  */
@@ -5,7 +5,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
7
  import { C4GroupsDetails, C4IdentityContextProvider, } from '@camunda/c4-identity';
8
- import { checkVersion, OrganizationRole, VersionCheckOperator, } from '@camunda/ccma-shared-types';
8
+ import { checkVersion, IDENTITY_MANAGEMENT_MIN_VERSION, OrganizationRole, VersionCheckOperator, } from '@camunda/ccma-shared-types';
9
9
  import { observer } from 'mobx-react-lite';
10
10
  import { useEffect, useMemo, useState } from 'react';
11
11
  import { C4PageTemplate } from '../../components/c4-page-template/c4-page-template.js';
@@ -101,7 +101,7 @@ export const C4GroupDetailsPage = observer(({ orgId, groupId, externalLinks, onN
101
101
  possiblyVersionOrDockerPath: zeebe,
102
102
  trueForSnapshot: true,
103
103
  operator: VersionCheckOperator.GreaterThanOrEqual,
104
- versionToCompareTo: '8.8.0-alpha5',
104
+ versionToCompareTo: IDENTITY_MANAGEMENT_MIN_VERSION,
105
105
  });
106
106
  });
107
107
  }, [clusters]);