@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
@@ -6,8 +6,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
6
6
  */
7
7
  import { C4GroupsList, C4IdentityContextProvider } from '@camunda/c4-identity';
8
8
  import { useC3Profile } from '@camunda/camunda-composite-components';
9
- import { AuditLoggerService, ConsoleApiClientsService, ConsoleValueMetricsService, EarlyAccessFeaturesService, HdpService, HttpError, OrganizationMembersService, OrgsService, UsageAlertsService, } from '@camunda/ccma-api';
10
- import { addMonthsClamped, checkVersion, diffInWholeMonths, getCurrentEnterpriseTerm, getDisplayedSalesPlan, getRevisitedSalesPlanName, OrganizationRole, peakWithinTerm, SseEntity, toUtcDayStartMs, VersionCheckOperator, } from '@camunda/ccma-shared-types';
9
+ import { AuditLoggerService, ConsoleApiClientsService, ConsoleClusterParametersService, ConsoleValueMetricsService, EarlyAccessFeaturesService, HdpService, HttpError, OrganizationMembersService, OrgsService, UsageAlertsService, } from '@camunda/ccma-api';
10
+ import { addMonthsClamped, checkVersion, diffInWholeMonths, getCurrentEnterpriseTerm, getDisplayedSalesPlan, getRevisitedSalesPlanName, IDENTITY_MANAGEMENT_MIN_VERSION, NEW_CLUSTER_ROLES_MIN_VERSION, OrganizationRole, peakWithinTerm, SseEntity, toUtcDayStartMs, VersionCheckOperator, } from '@camunda/ccma-shared-types';
11
11
  import { observer } from 'mobx-react-lite';
12
12
  import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
13
13
  import { C4AiUsage } from '../../components/c4-ai-usage/c4-ai-usage.js';
@@ -20,6 +20,7 @@ import { useC4ConsoleRuntime, useC4DesignSystem, } from '../../runtime/c4-consol
20
20
  import { toApiConfig } from '../../runtime/to-api-config.js';
21
21
  import { toIdentityApiBaseUrl } from '../../runtime/to-identity-api-base-url.js';
22
22
  import { Link, Stack } from '../../ui/index.js';
23
+ import { clientErrorMessage } from '../../utils/http-error-message.js';
23
24
  import { legacySectionRoles } from '../../utils/role-labels.js';
24
25
  import { useExtendTrial } from '../use-extend-trial.js';
25
26
  import { C4ManagementPage } from './c4-management-page.js';
@@ -126,6 +127,21 @@ function safeTranslate(t, key, fallback, options) {
126
127
  // for the "Other" series and a safety margin so every series gets its own colour
127
128
  // (the ds-mode palette is extended to match — see `recharts-tokens.ts`).
128
129
  const TOP_N_CHART_CLUSTERS = 12;
130
+ // Widest tenant-usage window accounts-backend serves (it clamps `days` to 366).
131
+ //
132
+ // Both tabs ask for all of it, on purpose:
133
+ // - the usage tab's table reaches back to the org's first period, so anything
134
+ // narrower just means more periods with no reading (rendered as "-", not 0);
135
+ // - the billing tab peaks over the *current contract term*, which is 365 or
136
+ // 366 days for the usual 12-month contract. It used to ask for 360, so once
137
+ // an org was past day 360 of its term the term's opening days fell outside
138
+ // the fetched window and a peak that happened there was under-reported —
139
+ // while the usage tab, on the wider window, still showed it.
140
+ //
141
+ // Sharing the constant is what keeps the two tabs reporting the same number.
142
+ // Widening is safe in both directions: `peakWithinTerm` clips to the term, so
143
+ // extra days outside it are fetched but never counted.
144
+ const MAX_TENANT_USAGE_DAYS = 366;
129
145
  /**
130
146
  * Reduces flat `{ group, date, value }` chart points to the top-N groups by
131
147
  * total value, summing the remaining groups per date into a single "Other"
@@ -514,6 +530,30 @@ function formatDate(date) {
514
530
  function getNumber(value, fallback = 0) {
515
531
  return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
516
532
  }
533
+ /**
534
+ * Flattens the cluster creation parameters into a `uuid -> name` lookup for
535
+ * cluster plan types. `clusterPlanTypes` holds the plan types the org has
536
+ * reservations for and `clusterPlanTypesFromSalesPlan` the ones its sales plan
537
+ * allows; both are merged so a reservation is named regardless of which list it
538
+ * shows up in.
539
+ */
540
+ function toClusterPlanTypeNames(parameters) {
541
+ const names = {};
542
+ for (const planType of [
543
+ ...(parameters.clusterPlanTypesFromSalesPlan ?? []),
544
+ ...(parameters.clusterPlanTypes ?? []),
545
+ ]) {
546
+ const uuid = planType?.uuid;
547
+ const name = planType?.name;
548
+ if (typeof uuid === 'string' &&
549
+ uuid.length > 0 &&
550
+ typeof name === 'string' &&
551
+ name.length > 0) {
552
+ names[uuid] = name;
553
+ }
554
+ }
555
+ return names;
556
+ }
517
557
  function themeNameToClassName(theme) {
518
558
  switch (theme) {
519
559
  case 'dark':
@@ -717,6 +757,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
717
757
  const [leaveOrganizationOpen, setLeaveOrganizationOpen] = useState(false);
718
758
  const [deleteOrganizationOpen, setDeleteOrganizationOpen] = useState(false);
719
759
  const [deleteOrganizationError, setDeleteOrganizationError] = useState(false);
760
+ const [deleteOrganizationErrorMessage, setDeleteOrganizationErrorMessage] = useState(undefined);
720
761
  const [isExtendModalOpen, setIsExtendModalOpen] = useState(false);
721
762
  const { submit: submitExtendTrial, isSubmitting: isExtendSubmitting, error: extendError, } = useExtendTrial(orgId, {
722
763
  onSuccess: () => {
@@ -930,9 +971,36 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
930
971
  const [usageClusters, setUsageClusters] = useState([]);
931
972
  const [usageMetricsMonthly, setUsageMetricsMonthly] = useState([]);
932
973
  const [usageMetricsPerDay, setUsageMetricsPerDay] = useState([]);
974
+ // HDP-sourced usage for the usage tab: daily per-cluster PI/DI/TU, plus the
975
+ // daily org-wide active-tenant gauge. The billing tab makes the same two
976
+ // reads over the same window (`MAX_TENANT_USAGE_DAYS`) and reduces them with
977
+ // the same helpers, so the figure both tabs show for a given period matches.
978
+ const [usageHdpMetrics, setUsageHdpMetrics] = useState([]);
979
+ const [usageTenantUsage, setUsageTenantUsage] = useState([]);
980
+ // Per-cluster half of the same read, for the table's expanded rows. The org
981
+ // totals above are not derivable from it (a peak is not additive across
982
+ // days), so the backend returns both from one query.
983
+ const [usageTenantPerCluster, setUsageTenantPerCluster] = useState([]);
984
+ // Why the tab has no data, when it has none. Every read behind this tab is
985
+ // permissioned on `org.billing.read` while the tab itself is shown for
986
+ // `org.usage.read` (a MEMBER has the latter and not the former), so "empty"
987
+ // is a state real users land in — and an empty table plus a column of "-"
988
+ // reads as "this org used nothing", which is not what happened.
989
+ const [usageError, setUsageError] = useState(undefined);
933
990
  const [billingLoading, setBillingLoading] = useState(false);
934
991
  const [billingError, setBillingError] = useState(undefined);
935
992
  const [billingClusters, setBillingClusters] = useState([]);
993
+ // Cluster plan type uuid -> display name. Reservations exist for plan types
994
+ // the org has never created a cluster on, so the names cannot be derived
995
+ // from the cluster list alone. Loaded out of band (see `loadBilling`), so
996
+ // this state is owned exclusively by that detached request — nothing else
997
+ // writes it, which is what keeps a late response from fighting the main
998
+ // load's error path.
999
+ const [billingClusterPlanTypeNames, setBillingClusterPlanTypeNames] = useState({});
1000
+ // Bumped on every `loadBilling` so the detached plan type name request can
1001
+ // tell whether its response still belongs to the newest load. `loadBilling`
1002
+ // re-runs after every usage-alert mutation, so overlapping loads are real.
1003
+ const billingLoadIdRef = useRef(0);
936
1004
  const [billingMetricsMonthly, setBillingMetricsMonthly] = useState([]);
937
1005
  const [billingUsageAlerts, setBillingUsageAlerts] = useState([]);
938
1006
  // Raw daily points rather than a pre-reduced peak: the peak has to be taken
@@ -1025,7 +1093,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1025
1093
  possiblyVersionOrDockerPath,
1026
1094
  trueForSnapshot: true,
1027
1095
  operator: VersionCheckOperator.GreaterThanOrEqual,
1028
- versionToCompareTo: '8.8.0-alpha5',
1096
+ versionToCompareTo: IDENTITY_MANAGEMENT_MIN_VERSION,
1029
1097
  });
1030
1098
  });
1031
1099
  setHasAtLeastOneIdentityIntegrationCluster(hasEnabledIdentityIntegration);
@@ -1065,48 +1133,158 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1065
1133
  activeTabId,
1066
1134
  refreshEarlyAccessFeatures,
1067
1135
  ]);
1136
+ const isLicensingModel2025 = useMemo(() => isLicensingModel2025Prop ??
1137
+ getNestedValue(org, ['metadata', 'licensingModel']) === '2025', [isLicensingModel2025Prop, org]);
1138
+ // Same two gates the billing tab applies, so a 2025 org reads the same
1139
+ // numbers from the same source on both tabs: PI/DI/TU from HDP instead of
1140
+ // the console-scraped metrics, and the org-scoped tenant gauge.
1141
+ const usageFromHdp = hdpValueMetricsFor2025Enabled && isLicensingModel2025;
1142
+ const usageTenantsEnabled = tenantsValueMetricEnabled && isLicensingModel2025;
1143
+ /**
1144
+ * Why the usage reads failed, in words a reader can act on.
1145
+ *
1146
+ * 403 gets its own message because it is the one failure that is not a
1147
+ * malfunction: the tab is shown to anyone with `org.usage.read`, while every
1148
+ * endpoint behind it (console's value metrics and HDP's usage metrics and
1149
+ * tenant usage alike) requires `org.billing.read`. An org MEMBER has the
1150
+ * first and not the second, so they reach a tab whose data they cannot read
1151
+ * — and "nothing here" is the wrong thing to tell them.
1152
+ */
1153
+ const usageErrorMessage = useCallback((reasons) => {
1154
+ const forbidden = reasons.some((reason) => reason instanceof HttpError && reason.status === 403);
1155
+ if (forbidden) {
1156
+ return safeTranslate(t, 'orgmanagement:tabs.usage.errors.forbidden', 'You do not have permission to view usage data for this organization. An organization owner or admin can see it.');
1157
+ }
1158
+ return safeTranslate(t, 'orgmanagement:tabs.usage.errors.default', 'Usage data could not be loaded. Try again in a moment.');
1159
+ }, [t]);
1068
1160
  const loadUsage = useCallback(async () => {
1069
1161
  setUsageLoading(true);
1162
+ setUsageError(undefined);
1070
1163
  try {
1071
1164
  await data.fetchClusters(orgId, { force: true });
1072
1165
  const clusters = data.clusters[orgId]?.error
1073
1166
  ? []
1074
1167
  : (data.getClusters(orgId) ?? []);
1075
- const [monthly, perDay] = await Promise.all([
1076
- ConsoleValueMetricsService.getValueMetrics({
1077
- config: apiConfig,
1078
- params: {
1079
- orgId,
1080
- days: 0,
1081
- },
1082
- }),
1083
- ConsoleValueMetricsService.getValueMetricsPerDays({
1084
- config: apiConfig,
1085
- params: {
1086
- orgId,
1087
- days: 360,
1088
- },
1089
- }),
1168
+ // Settled rather than all: the tenant gauge and the PI/DI/TU history are
1169
+ // independent reads, and one of them failing must not blank the other.
1170
+ const [monthlyResult, perDayResult, hdpUsageResult, tenantsResult] = await Promise.allSettled([
1171
+ usageFromHdp
1172
+ ? Promise.resolve([])
1173
+ : ConsoleValueMetricsService.getValueMetrics({
1174
+ config: apiConfig,
1175
+ params: {
1176
+ orgId,
1177
+ days: 0,
1178
+ },
1179
+ }),
1180
+ usageFromHdp
1181
+ ? Promise.resolve([])
1182
+ : ConsoleValueMetricsService.getValueMetricsPerDays({
1183
+ config: apiConfig,
1184
+ params: {
1185
+ orgId,
1186
+ days: 360,
1187
+ },
1188
+ }),
1189
+ // No date bounds: the table goes back to the org's first period, and
1190
+ // the endpoint returns the org's whole history when unbounded.
1191
+ usageFromHdp
1192
+ ? HdpService.getUsageMetrics({
1193
+ config: apiConfig,
1194
+ params: { orgId },
1195
+ })
1196
+ : Promise.resolve(undefined),
1197
+ // Per-cluster variant: the usage table breaks each period down by
1198
+ // cluster, and this returns the org totals for the period column in
1199
+ // the same response — one HDP read for both halves.
1200
+ usageTenantsEnabled
1201
+ ? HdpService.getTenantUsagePerCluster({
1202
+ config: apiConfig,
1203
+ params: { orgId, days: MAX_TENANT_USAGE_DAYS },
1204
+ })
1205
+ : Promise.resolve({
1206
+ orgTotals: [],
1207
+ perCluster: [],
1208
+ }),
1090
1209
  ]);
1091
1210
  const normalizedClusters = (clusters ?? []).filter((item) => Boolean(item) && typeof item === 'object');
1092
1211
  setUsageClusters(normalizedClusters);
1093
- setUsageMetricsMonthly(monthly ?? []);
1094
- setUsageMetricsPerDay(perDay ?? []);
1212
+ setUsageMetricsMonthly(monthlyResult.status === 'fulfilled'
1213
+ ? (monthlyResult.value ?? [])
1214
+ : []);
1215
+ setUsageMetricsPerDay(perDayResult.status === 'fulfilled' ? (perDayResult.value ?? []) : []);
1216
+ setUsageHdpMetrics(hdpUsageResult.status === 'fulfilled'
1217
+ ? (hdpUsageResult.value?.valueMetrics?.valueMetrics ?? [])
1218
+ : []);
1219
+ setUsageTenantUsage(tenantsResult.status === 'fulfilled'
1220
+ ? (tenantsResult.value?.orgTotals ?? [])
1221
+ : []);
1222
+ setUsageTenantPerCluster(tenantsResult.status === 'fulfilled'
1223
+ ? (tenantsResult.value?.perCluster ?? [])
1224
+ : []);
1225
+ // A rejected read leaves its half of the tab empty, which on its own is
1226
+ // indistinguishable from "this org used nothing" — the table renders no
1227
+ // rows and the tenants column renders "-". Say which it is.
1228
+ const failures = [
1229
+ monthlyResult,
1230
+ perDayResult,
1231
+ hdpUsageResult,
1232
+ tenantsResult,
1233
+ ].filter((result) => result.status === 'rejected');
1234
+ if (failures.length > 0) {
1235
+ setUsageError(usageErrorMessage(failures.map((f) => f.reason)));
1236
+ }
1095
1237
  }
1096
- catch {
1238
+ catch (error) {
1097
1239
  setUsageClusters([]);
1098
1240
  setUsageMetricsMonthly([]);
1099
1241
  setUsageMetricsPerDay([]);
1242
+ setUsageHdpMetrics([]);
1243
+ setUsageTenantUsage([]);
1244
+ setUsageTenantPerCluster([]);
1245
+ setUsageError(usageErrorMessage([error]));
1100
1246
  }
1101
1247
  finally {
1102
1248
  setUsageLoading(false);
1103
1249
  }
1104
- }, [apiConfig, orgId]);
1105
- const isLicensingModel2025 = useMemo(() => isLicensingModel2025Prop ??
1106
- getNestedValue(org, ['metadata', 'licensingModel']) === '2025', [isLicensingModel2025Prop, org]);
1250
+ }, [apiConfig, orgId, usageFromHdp, usageTenantsEnabled, usageErrorMessage]);
1107
1251
  const loadBilling = useCallback(async () => {
1252
+ const loadId = billingLoadIdRef.current + 1;
1253
+ billingLoadIdRef.current = loadId;
1108
1254
  setBillingLoading(true);
1109
1255
  setBillingError(undefined);
1256
+ // Names for the reserved cluster plan types. The response's
1257
+ // `clusterPlanTypes` is exactly the set of plan types the org has
1258
+ // reservations for, so this resolves every reservation row — not just the
1259
+ // ones that happen to have a cluster on them.
1260
+ //
1261
+ // Started first but deliberately NOT awaited with the rest: it only fills
1262
+ // the `Type` column of the reservations table, so a slow (or hung)
1263
+ // parameters request must never hold `billingLoading` — and with it every
1264
+ // billing figure on the page — hostage. Because it is in flight before the
1265
+ // cluster fetch even starts, it normally lands well before the numbers do
1266
+ // and the table never renders a placeholder name.
1267
+ void ConsoleClusterParametersService.getCreationParameters({
1268
+ config: apiConfig,
1269
+ params: { orgId },
1270
+ })
1271
+ .then((parameters) => {
1272
+ if (billingLoadIdRef.current !== loadId) {
1273
+ // A newer load has taken over; its own request owns the names.
1274
+ return;
1275
+ }
1276
+ setBillingClusterPlanTypeNames(toClusterPlanTypeNames(parameters));
1277
+ })
1278
+ .catch(() => {
1279
+ if (billingLoadIdRef.current !== loadId) {
1280
+ return;
1281
+ }
1282
+ // Not surfaced as a billing error: the names are supplementary, and a
1283
+ // user who may read billing but not cluster parameters should still
1284
+ // get the reservation numbers. Names fall back to the ones embedded
1285
+ // in the cluster list, then to a placeholder.
1286
+ setBillingClusterPlanTypeNames({});
1287
+ });
1110
1288
  try {
1111
1289
  await data.fetchClusters(orgId, { force: true });
1112
1290
  const clusters = data.clusters[orgId]?.error
@@ -1127,7 +1305,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1127
1305
  tenantsValueMetricEnabled && isLicensingModel2025
1128
1306
  ? HdpService.getTenantUsage({
1129
1307
  config: apiConfig,
1130
- params: { orgId, days: 360 },
1308
+ params: { orgId, days: MAX_TENANT_USAGE_DAYS },
1131
1309
  })
1132
1310
  : Promise.resolve([]),
1133
1311
  hdpValueMetricsFor2025Enabled && isLicensingModel2025
@@ -1158,6 +1336,9 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1158
1336
  }
1159
1337
  }
1160
1338
  catch (error) {
1339
+ // `billingClusterPlanTypeNames` is intentionally left alone here: its
1340
+ // request is detached and may still be in flight, and it is keyed by
1341
+ // plan type uuid, so a stale entry can only ever name a row correctly.
1161
1342
  setBillingClusters([]);
1162
1343
  setBillingMetricsMonthly([]);
1163
1344
  setBillingUsageAlerts([]);
@@ -1339,7 +1520,10 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1339
1520
  return Object.keys(reservedMap)
1340
1521
  .map((clusterPlanTypeId) => {
1341
1522
  const reserved = getNumber(reservedMap[clusterPlanTypeId]);
1342
- const planTypeName = clusterPlanTypeNames.get(clusterPlanTypeId);
1523
+ // The plan type registry is authoritative; the names embedded in the
1524
+ // cluster list are only a fallback for when it could not be loaded.
1525
+ const planTypeName = billingClusterPlanTypeNames[clusterPlanTypeId] ??
1526
+ clusterPlanTypeNames.get(clusterPlanTypeId);
1343
1527
  const matchingClusters = billingClusters.filter((cluster) => {
1344
1528
  const planTypeObj = getRecord(cluster, 'planType');
1345
1529
  return planTypeObj?.uuid === clusterPlanTypeId;
@@ -1358,7 +1542,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1358
1542
  };
1359
1543
  })
1360
1544
  .filter((row) => row.reserved > 0);
1361
- }, [billingClusters, org]);
1545
+ }, [billingClusterPlanTypeNames, billingClusters, org]);
1362
1546
  const billingTabProps = useMemo(() => {
1363
1547
  return {
1364
1548
  billingIsEnterprise,
@@ -1432,10 +1616,38 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1432
1616
  }
1433
1617
  return map;
1434
1618
  }, [usageClusters]);
1619
+ /**
1620
+ * The per-day usage series the usage tab derives its table and charts from.
1621
+ *
1622
+ * On the HDP path the flat `{clusterId, date, pi, di, tu}` rows are mapped
1623
+ * onto the same `ClusterUsageMetricsData` shape the console-scraped per-day
1624
+ * metrics use, so the period aggregation below stays one code path for both
1625
+ * sources. `generalUsers` has no HDP counterpart (it is a seat count, not a
1626
+ * usage metric) and the usage table has no column for it either.
1627
+ */
1628
+ const usagePerDayEntries = useMemo(() => {
1629
+ if (!usageFromHdp) {
1630
+ return usageMetricsPerDay;
1631
+ }
1632
+ return usageHdpMetrics.map((entry) => ({
1633
+ orgId,
1634
+ clusterId: entry.clusterId,
1635
+ startDate: new Date(entry.date.ts),
1636
+ processInstances: entry.pi,
1637
+ decisionInstances: entry.di,
1638
+ taskUsers: entry.tu,
1639
+ }));
1640
+ }, [orgId, usageFromHdp, usageHdpMetrics, usageMetricsPerDay]);
1641
+ /**
1642
+ * Monthly (already period-bucketed) metrics, which only the console source
1643
+ * has. Empty on the HDP path so the aggregation falls through to the daily
1644
+ * series above rather than mixing two sources in one table.
1645
+ */
1646
+ const usageMonthlyEntries = useMemo(() => (usageFromHdp ? [] : usageMetricsMonthly), [usageFromHdp, usageMetricsMonthly]);
1435
1647
  const usageCharts = useMemo(() => {
1436
1648
  const orgName = typeof org?.name === 'string' ? org.name : orgId;
1437
1649
  const theme = themeNameToClassName(c3Profile.resolvedTheme);
1438
- const sorted = usageMetricsPerDay
1650
+ const sorted = usagePerDayEntries
1439
1651
  .slice()
1440
1652
  .map((entry) => {
1441
1653
  const startDate = toDate(entry.startDate);
@@ -1508,6 +1720,24 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1508
1720
  axes: { titleBottom, titleLeft },
1509
1721
  dataPoints: tuCapped,
1510
1722
  },
1723
+ // Tenants is reported for the org, not per cluster, so it is a single
1724
+ // series (no top-N capping) and is keyed on the org rather than on a
1725
+ // cluster name.
1726
+ tenants: usageTenantsEnabled
1727
+ ? {
1728
+ title: safeTranslate(t, 'orgmanagement:tabs.usage.tenants', 'Tenants'),
1729
+ theme,
1730
+ axes: { titleBottom, titleLeft },
1731
+ dataPoints: usageTenantUsage
1732
+ .slice()
1733
+ .sort((a, b) => b.ts - a.ts)
1734
+ .map((point) => ({
1735
+ group: orgName,
1736
+ date: new Date(point.ts).toISOString().substring(0, 10),
1737
+ value: point.value,
1738
+ })),
1739
+ }
1740
+ : undefined,
1511
1741
  };
1512
1742
  }, [
1513
1743
  c3Profile.resolvedTheme,
@@ -1516,11 +1746,85 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1516
1746
  org?.name,
1517
1747
  orgId,
1518
1748
  t,
1519
- usageMetricsPerDay,
1749
+ usagePerDayEntries,
1750
+ usageTenantsEnabled,
1751
+ usageTenantUsage,
1520
1752
  ]);
1521
1753
  const usageHistory = useMemo(() => {
1522
- const metrics = usageMetricsMonthly;
1754
+ const metrics = usageMonthlyEntries;
1523
1755
  const now = new Date();
1756
+ /**
1757
+ * Peak active tenants inside a period, or `undefined` when HDP holds no
1758
+ * reading for it. A gauge is peaked, never summed — and only over the
1759
+ * period's own days, or an older period's high-water mark leaks into a
1760
+ * newer one. `peakWithinTerm` is the same helper the billing tab uses, so
1761
+ * the current period's figure matches across the two tabs.
1762
+ */
1763
+ const tenantsForPeriod = (periodStart, periodEnd) => {
1764
+ if (!usageTenantsEnabled) {
1765
+ return undefined;
1766
+ }
1767
+ const from = toUtcDayStartMs(periodStart);
1768
+ const to = toUtcDayStartMs(periodEnd);
1769
+ const hasReading = usageTenantUsage.some((point) => point.ts >= from && point.ts <= to);
1770
+ return hasReading
1771
+ ? peakWithinTerm(usageTenantUsage, { periodStart, periodEnd })
1772
+ : undefined;
1773
+ };
1774
+ /**
1775
+ * The same peak per cluster, keyed by cluster id, for a period's expanded
1776
+ * rows. Each cluster is peaked over its own readings, so the rows do not
1777
+ * add up to the period's org figure — two clusters can peak on different
1778
+ * days, and the org's peak is the highest *daily sum*, not the sum of the
1779
+ * highs. Clusters HDP has no reading for in the period are absent from
1780
+ * the map and render as "-", exactly like the org column.
1781
+ */
1782
+ const tenantsPerClusterForPeriod = (periodStart, periodEnd) => {
1783
+ const peaks = new Map();
1784
+ if (!usageTenantsEnabled) {
1785
+ return peaks;
1786
+ }
1787
+ const from = toUtcDayStartMs(periodStart);
1788
+ const to = toUtcDayStartMs(periodEnd);
1789
+ for (const point of usageTenantPerCluster) {
1790
+ if (point.ts < from || point.ts > to) {
1791
+ continue;
1792
+ }
1793
+ const current = peaks.get(point.clusterId);
1794
+ if (current === undefined || point.value > current) {
1795
+ peaks.set(point.clusterId, point.value);
1796
+ }
1797
+ }
1798
+ return peaks;
1799
+ };
1800
+ /**
1801
+ * Attach each cluster's tenant peak to that period's per-cluster rows.
1802
+ *
1803
+ * A cluster can have tenants in a period without a single PI/DI/TU row
1804
+ * (nothing ran on it, but tenants were configured), and those clusters
1805
+ * are missing from the usage-derived rows entirely — so they are added
1806
+ * at zero usage rather than dropped, which would hide real tenants.
1807
+ */
1808
+ const withTenantsPerCluster = (rows, peaks) => {
1809
+ const merged = rows.map((row) => ({
1810
+ ...row,
1811
+ tenants: peaks.get(row.clusterId),
1812
+ }));
1813
+ for (const [clusterId, tenants] of peaks) {
1814
+ if (merged.some((row) => row.clusterId === clusterId)) {
1815
+ continue;
1816
+ }
1817
+ merged.push({
1818
+ clusterId,
1819
+ clusterName: clusterIdToName.get(clusterId) ?? clusterId,
1820
+ processInstances: 0,
1821
+ decisionInstances: 0,
1822
+ taskUsers: 0,
1823
+ tenants,
1824
+ });
1825
+ }
1826
+ return merged;
1827
+ };
1524
1828
  const startCandidates = (metrics ?? [])
1525
1829
  .map((m) => {
1526
1830
  const startDate = toDate(m.startDate);
@@ -1573,10 +1877,18 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1573
1877
  generalUsers: 0,
1574
1878
  perCluster: new Map(),
1575
1879
  }));
1576
- const perDaySorted = (usageMetricsPerDay ?? [])
1880
+ // Period bounds as UTC day buckets, which is what a daily usage row is:
1881
+ // a contract bound keeps the wall-clock time the plan was created at, so
1882
+ // comparing raw timestamps drops the period's first day whenever that
1883
+ // was after midnight — and the dropped row lands in no period at all.
1884
+ const periodBounds = periods.map((p) => ({
1885
+ start: toUtcDayStartMs(p.start),
1886
+ end: toUtcDayStartMs(p.end),
1887
+ }));
1888
+ const perDaySorted = (usagePerDayEntries ?? [])
1577
1889
  .map((entry) => {
1578
1890
  const date = toDate(entry.startDate);
1579
- const timestamp = date?.getTime();
1891
+ const timestamp = date ? toUtcDayStartMs(date) : undefined;
1580
1892
  return {
1581
1893
  entry,
1582
1894
  date,
@@ -1588,14 +1900,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1588
1900
  let periodIndex = 0;
1589
1901
  for (const item of perDaySorted) {
1590
1902
  while (periodIndex < periods.length &&
1591
- item.timestamp > periods[periodIndex].end.getTime()) {
1903
+ item.timestamp > periodBounds[periodIndex].end) {
1592
1904
  periodIndex += 1;
1593
1905
  }
1594
1906
  if (periodIndex >= periods.length) {
1595
1907
  break;
1596
1908
  }
1597
- const currentPeriod = periods[periodIndex];
1598
- if (item.timestamp < currentPeriod.start.getTime()) {
1909
+ if (item.timestamp < periodBounds[periodIndex].start) {
1599
1910
  continue;
1600
1911
  }
1601
1912
  const target = aggregated[periodIndex];
@@ -1621,15 +1932,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1621
1932
  .slice()
1622
1933
  .sort((a, b) => b.iteration - a.iteration)
1623
1934
  .map((entry, index) => {
1624
- const perCluster = Array.from(entry.perCluster.entries())
1625
- .map(([clusterId, clusterValues]) => ({
1935
+ const perCluster = withTenantsPerCluster(Array.from(entry.perCluster.entries()).map(([clusterId, clusterValues]) => ({
1626
1936
  clusterId,
1627
1937
  clusterName: clusterValues.clusterName,
1628
1938
  processInstances: clusterValues.processInstances,
1629
1939
  decisionInstances: clusterValues.decisionInstances,
1630
1940
  taskUsers: clusterValues.taskUsers,
1631
- }))
1632
- .sort((a, b) => b.processInstances - a.processInstances);
1941
+ })), tenantsPerClusterForPeriod(entry.start, entry.end)).sort((a, b) => b.processInstances - a.processInstances);
1633
1942
  return {
1634
1943
  id: String(entry.iteration),
1635
1944
  originalIndex: index,
@@ -1637,6 +1946,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1637
1946
  decisionInstances: entry.decisionInstances,
1638
1947
  taskUsers: entry.taskUsers,
1639
1948
  generalUsers: entry.generalUsers,
1949
+ tenants: tenantsForPeriod(entry.start, entry.end),
1640
1950
  period: `${formatDate(entry.start)} - ${formatDate(entry.end)}`,
1641
1951
  perCluster,
1642
1952
  };
@@ -1708,16 +2018,20 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
1708
2018
  decisionInstances: entry.decisionInstances,
1709
2019
  taskUsers: entry.taskUsers,
1710
2020
  generalUsers: entry.generalUsers,
2021
+ tenants: tenantsForPeriod(entry.start, entry.end),
1711
2022
  period: `${formatDate(entry.start)} - ${formatDate(entry.end)}`,
1712
- perCluster: entry.perCluster,
2023
+ perCluster: withTenantsPerCluster(entry.perCluster, tenantsPerClusterForPeriod(entry.start, entry.end)),
1713
2024
  };
1714
2025
  });
1715
2026
  }, [
1716
2027
  clusterIdToName,
1717
2028
  org,
1718
2029
  usageGroupBy,
1719
- usageMetricsMonthly,
1720
- usageMetricsPerDay,
2030
+ usageMonthlyEntries,
2031
+ usagePerDayEntries,
2032
+ usageTenantsEnabled,
2033
+ usageTenantUsage,
2034
+ usageTenantPerCluster,
1721
2035
  ]);
1722
2036
  const canReadActivity = useMemo(() => getNestedBoolean(org, ['permissions', 'org', 'activity', 'read']), [org]);
1723
2037
  const loadAudits = useCallback(async (opts) => {
@@ -2559,7 +2873,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
2559
2873
  possiblyVersionOrDockerPath: zeebe,
2560
2874
  trueForSnapshot: true,
2561
2875
  operator: VersionCheckOperator.GreaterThanOrEqual,
2562
- versionToCompareTo: '8.8.0-alpha4',
2876
+ versionToCompareTo: NEW_CLUSTER_ROLES_MIN_VERSION,
2563
2877
  });
2564
2878
  });
2565
2879
  })();
@@ -2794,7 +3108,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
2794
3108
  visible: usageVisible,
2795
3109
  component: (_jsx(C4ManagementUsageTab, { loading: usageLoading, groupBy: usageGroupBy, onGroupByChange: (next) => {
2796
3110
  setUsageGroupBy(next);
2797
- }, perClusterAvailable: true, history: usageHistory, charts: usageCharts, isLicensingModel2025: isLicensingModel2025, text: {
3111
+ }, perClusterAvailable: true, history: usageHistory, charts: usageCharts, isLicensingModel2025: isLicensingModel2025, showTenants: usageTenantsEnabled, error: usageError, text: {
2798
3112
  tableTabTitle: safeTranslate(t, 'orgmanagement:tabs.billing.billingHistory.table.tabTitle', 'Table'),
2799
3113
  chartsTabTitle: safeTranslate(t, 'orgmanagement:tabs.billing.billingHistory.charts.tabTitle', 'Charts'),
2800
3114
  headers: {
@@ -2802,6 +3116,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
2802
3116
  processInstances: safeTranslate(t, 'orgmanagement:tabs.usage.processInstances', 'Process instances'),
2803
3117
  decisionInstances: safeTranslate(t, 'orgmanagement:tabs.usage.decisionInstances', 'Decision instances'),
2804
3118
  taskUsers: safeTranslate(t, 'orgmanagement:tabs.usage.taskUsers', 'Task users'),
3119
+ tenants: safeTranslate(t, 'orgmanagement:tabs.usage.tenants', 'Tenants'),
2805
3120
  },
2806
3121
  groupBy: {
2807
3122
  heading: safeTranslate(t, 'orgmanagement:tabs.usage.history.groupBySelect.heading', 'Group by'),
@@ -2813,6 +3128,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
2813
3128
  processInstances: safeTranslate(t, 'orgmanagement:tabs.usage.processInstances', 'Process instances'),
2814
3129
  decisionInstances: safeTranslate(t, 'orgmanagement:tabs.usage.decisionInstances', 'Decision instances'),
2815
3130
  taskUsers: safeTranslate(t, 'orgmanagement:tabs.usage.taskUsers', 'Task users'),
3131
+ tenants: safeTranslate(t, 'orgmanagement:tabs.usage.tenants', 'Tenants'),
2816
3132
  },
2817
3133
  } })),
2818
3134
  initializeTab: () => {
@@ -3062,12 +3378,14 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
3062
3378
  finally {
3063
3379
  setSettingsLoading(false);
3064
3380
  }
3065
- } }), _jsx(C4DeleteOrganizationModal, { t: t, open: deleteOrganizationOpen, loading: settingsLoading, error: deleteOrganizationError, organizationName: typeof org?.name === 'string' ? org.name : '', onRequestClose: () => {
3381
+ } }), _jsx(C4DeleteOrganizationModal, { t: t, open: deleteOrganizationOpen, loading: settingsLoading, error: deleteOrganizationError, errorMessage: deleteOrganizationErrorMessage, organizationName: typeof org?.name === 'string' ? org.name : '', onRequestClose: () => {
3066
3382
  setDeleteOrganizationOpen(false);
3067
3383
  setDeleteOrganizationError(false);
3384
+ setDeleteOrganizationErrorMessage(undefined);
3068
3385
  }, onRequestSubmit: async () => {
3069
3386
  setSettingsLoading(true);
3070
3387
  setDeleteOrganizationError(false);
3388
+ setDeleteOrganizationErrorMessage(undefined);
3071
3389
  try {
3072
3390
  await OrgsService.deleteOrganization({
3073
3391
  config: apiConfig,
@@ -3078,6 +3396,12 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
3078
3396
  }
3079
3397
  catch (error) {
3080
3398
  setDeleteOrganizationError(true);
3399
+ // The delete has preconditions beyond the ones this UI can
3400
+ // check (the org must not be the user's only org, and no SSO
3401
+ // connection may still name it as its default org). Show the
3402
+ // backend's own 4xx reason — "please try again" is wrong advice
3403
+ // for every one of them.
3404
+ setDeleteOrganizationErrorMessage(clientErrorMessage(error));
3081
3405
  runtime.telemetry?.captureException?.(error, {
3082
3406
  eventName: 'orgSettings:deleteOrg:error',
3083
3407
  message: 'Error while deleting organization',