@camunda/ccma-saas-frontend 0.37.1 → 0.38.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.
@@ -91,7 +91,8 @@
91
91
  "secondary": "Cancel"
92
92
  },
93
93
  "loadingText": "Deleting...",
94
- "description": "Are you sure you want to delete the alert",
94
+ "description": "Are you sure you want to delete the alert for \"{{target}}\"?",
95
+ "descriptionNoTarget": "Are you sure you want to delete the alert?",
95
96
  "error": {
96
97
  "generic": "We're having trouble deleting the alert"
97
98
  }
@@ -61,6 +61,7 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
61
61
  const fetchOrgOwner = useCallback((orgId, options) => store.fetchOrgOwner(orgId, options), [store]);
62
62
  const fetchEarlyAccessFeatures = useCallback((orgId, options) => store.fetchEarlyAccessFeatures(orgId, options), [store]);
63
63
  const fetchClusterCapacity = useCallback((orgId, clusterIds, options) => store.fetchClusterCapacity(orgId, clusterIds, options), [store]);
64
+ const readClusterCapacity = useCallback((params, options) => store.readClusterCapacity(params, options), [store]);
64
65
  const fetchMyOrgs = useCallback((options) => store.fetchMyOrgs(options), [store]);
65
66
  const fetchWebappClusters = useCallback((orgId, options) => store.fetchWebappClusters(orgId, options), [store]);
66
67
  const fetchUpgradableGenerations = useCallback((fromGenerationUuid, clusterId, options) => store.fetchUpgradableGenerations(fromGenerationUuid, clusterId, options), [store]);
@@ -237,6 +238,7 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
237
238
  fetchAudits,
238
239
  fetchClients,
239
240
  fetchClusterCapacity,
241
+ readClusterCapacity,
240
242
  fetchMyOrgs,
241
243
  fetchWebappClusters,
242
244
  fetchUpgradableGenerations,
@@ -279,6 +281,7 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
279
281
  fetchAudits,
280
282
  fetchClients,
281
283
  fetchClusterCapacity,
284
+ readClusterCapacity,
282
285
  fetchMyOrgs,
283
286
  fetchWebappClusters,
284
287
  fetchUpgradableGenerations,
@@ -1,4 +1,5 @@
1
- import type { ConsoleClusterDto, ExternalClusterDto, ExternalOrganizationDto, SseEntity, UpgradableGenerationsDto } from '@camunda/ccma-shared-types';
1
+ import type { GetClusterCapacityRequest } from '@camunda/ccma-api';
2
+ import type { ConsoleClusterDto, ExternalClusterDto, ExternalOrganizationDto, HdpPrometheusDataCapacityDataPoint, SseEntity, UpgradableGenerationsDto } from '@camunda/ccma-shared-types';
2
3
  /**
3
4
  * Shared data cache state for C4 console widgets
4
5
  *
@@ -61,6 +62,10 @@ export interface C4ConsoleDataState {
61
62
  fetchClusterCapacity: (orgId: string, clusterIds: string[], options?: {
62
63
  force?: boolean;
63
64
  }) => Promise<void>;
65
+ /** One HDP capacity read per distinct body, shared for a short time. */
66
+ readClusterCapacity: (params: GetClusterCapacityRequest['params'], options?: {
67
+ force?: boolean;
68
+ }) => Promise<HdpPrometheusDataCapacityDataPoint[]>;
64
69
  fetchMyOrgs: (options?: {
65
70
  force?: boolean;
66
71
  }) => Promise<void>;
@@ -1,4 +1,5 @@
1
- import { type ConsoleClusterDto, type ExternalClusterDto, type ExternalOrganizationDto, SseEntity, type UpgradableGenerationsDto } from '@camunda/ccma-shared-types';
1
+ import { type GetClusterCapacityRequest } from '@camunda/ccma-api';
2
+ import { type ConsoleClusterDto, type ExternalClusterDto, type ExternalOrganizationDto, type HdpPrometheusDataCapacityDataPoint, SseEntity, type UpgradableGenerationsDto } from '@camunda/ccma-shared-types';
2
3
  import { type SnapshotIn } from 'mobx-state-tree';
3
4
  import type { C4ConsoleRuntimeConfig } from './c4-console-runtime.types.js';
4
5
  export declare const ConsoleDataStore: import("mobx-state-tree").IModelType<{
@@ -100,6 +101,10 @@ export declare const ConsoleDataStore: import("mobx-state-tree").IModelType<{
100
101
  */
101
102
  clustersGeneration: number;
102
103
  clusterCapacityLastRefreshMs: Map<string, number>;
104
+ capacityReads: Map<string, {
105
+ at: number;
106
+ promise: Promise<HdpPrometheusDataCapacityDataPoint[]>;
107
+ }>;
103
108
  } & {
104
109
  getClusters(orgId: string): ConsoleClusterDto[] | undefined;
105
110
  getOrgInfo(orgId: string): unknown | undefined;
@@ -177,6 +182,16 @@ export declare const ConsoleDataStore: import("mobx-state-tree").IModelType<{
177
182
  fetchClients: (orgId: string, options?: {
178
183
  force?: boolean;
179
184
  } | undefined) => Promise<void>;
185
+ } & {
186
+ /**
187
+ * One HDP capacity request per distinct body. Callers that send the
188
+ * same body share the answer for a short time.
189
+ * `force` reads again. A failed read is not kept.
190
+ */
191
+ readClusterCapacity(params: GetClusterCapacityRequest["params"], options?: {
192
+ force?: boolean;
193
+ }): Promise<HdpPrometheusDataCapacityDataPoint[]>;
194
+ } & {
180
195
  fetchClusterCapacity: (orgId: string, clusterIds: string[], options?: {
181
196
  force?: boolean;
182
197
  } | undefined) => Promise<void>;
@@ -79,6 +79,13 @@ function mergePreservingNestedData(previous, next) {
79
79
  }
80
80
  return merged;
81
81
  }
82
+ const CAPACITY_READ_TTL_MS = 30_000;
83
+ function dropCapacityReads(reads, orgId) {
84
+ for (const key of reads.keys()) {
85
+ if (key.startsWith(`${orgId}|`))
86
+ reads.delete(key);
87
+ }
88
+ }
82
89
  /**
83
90
  * MobX State Tree store for shared C4 console data
84
91
  *
@@ -138,6 +145,7 @@ export const ConsoleDataStore = types
138
145
  cliApiOn: false,
139
146
  clustersGeneration: 0,
140
147
  clusterCapacityLastRefreshMs: new Map(),
148
+ capacityReads: new Map(),
141
149
  }))
142
150
  .views((self) => ({
143
151
  getClusters(orgId) {
@@ -264,6 +272,7 @@ export const ConsoleDataStore = types
264
272
  },
265
273
  invalidateClusterCapacity(orgId) {
266
274
  self.clusterCapacity.delete(orgId);
275
+ dropCapacityReads(self.capacityReads, orgId);
267
276
  },
268
277
  invalidateMembers(orgId) {
269
278
  self.members.delete(orgId);
@@ -289,6 +298,7 @@ export const ConsoleDataStore = types
289
298
  self.audits.delete(orgId);
290
299
  self.clients.delete(orgId);
291
300
  self.clusterCapacity.delete(orgId);
301
+ dropCapacityReads(self.capacityReads, orgId);
292
302
  self.webappClusters.delete(orgId);
293
303
  },
294
304
  bumpSseEntityVersion(orgId, entity, clusterId) {
@@ -820,6 +830,49 @@ export const ConsoleDataStore = types
820
830
  });
821
831
  }
822
832
  }),
833
+ }))
834
+ .actions((self) => ({
835
+ /**
836
+ * One HDP capacity request per distinct body. Callers that send the
837
+ * same body share the answer for a short time.
838
+ * `force` reads again. A failed read is not kept.
839
+ */
840
+ readClusterCapacity(params, options) {
841
+ if (!self.runtime) {
842
+ return Promise.reject(new Error('Runtime config not set'));
843
+ }
844
+ const key = `${params.orgId}|${JSON.stringify(params)}`;
845
+ const hit = self.capacityReads.get(key);
846
+ if (!options?.force &&
847
+ hit &&
848
+ Date.now() - hit.at < CAPACITY_READ_TTL_MS) {
849
+ return hit.promise;
850
+ }
851
+ const promise = HdpService.getClusterCapacity({
852
+ params,
853
+ config: toApiConfig(self.runtime),
854
+ });
855
+ const now = Date.now();
856
+ for (const [k, v] of self.capacityReads) {
857
+ if (now - v.at >= CAPACITY_READ_TTL_MS)
858
+ self.capacityReads.delete(k);
859
+ }
860
+ // A pending read stays shareable (at is Infinity).
861
+ // The TTL starts when it settles.
862
+ const entry = { at: Infinity, promise };
863
+ self.capacityReads.set(key, entry);
864
+ promise.then(() => {
865
+ if (self.capacityReads.get(key) === entry)
866
+ entry.at = Date.now();
867
+ }, () => {
868
+ if (self.capacityReads.get(key) === entry) {
869
+ self.capacityReads.delete(key);
870
+ }
871
+ });
872
+ return promise;
873
+ },
874
+ }))
875
+ .actions((self) => ({
823
876
  fetchClusterCapacity: flow(function* (orgId, clusterIds, options) {
824
877
  if (!self.runtime) {
825
878
  throw new Error('Runtime config not set');
@@ -837,21 +890,13 @@ export const ConsoleDataStore = types
837
890
  }
838
891
  self.inFlightClusterCapacity.add(orgId);
839
892
  try {
840
- const apiConfig = toApiConfig(self.runtime);
841
893
  const loadMap = new Map();
842
894
  // Fetch capacity for all clusters in a single batched request.
843
895
  // The HDP `latest` operation accepts the full `clusterIds` array and
844
896
  // returns one data point per cluster, each tagged with its `clusterId`
845
897
  // (see accounts-ng getLatestCapacity). This replaces the previous
846
898
  // per-cluster serial loop, which issued one HTTP round-trip per cluster.
847
- const latest = yield HdpService.getClusterCapacity({
848
- params: {
849
- orgId,
850
- clusterIds,
851
- operation: 'latest',
852
- },
853
- config: apiConfig,
854
- });
899
+ const latest = yield self.readClusterCapacity({ orgId, clusterIds, operation: 'latest' }, { force: options?.force });
855
900
  const points = Array.isArray(latest) ? latest : [];
856
901
  for (const point of points) {
857
902
  const clusterId = point?.clusterId;
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
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 { AuditLoggerService, GenerationService, HdpService, HttpError, SaaSJobsService, } from '@camunda/ccma-api';
7
+ import { AuditLoggerService, GenerationService, HttpError, SaaSJobsService, } from '@camunda/ccma-api';
8
8
  import { AUDIT_LOG_TAB_MIN_VERSION, CLUSTER_STATISTICS_CONFIG_MIN_VERSION, checkVersion, deriveEncryptionKeyStatus, deriveEncryptionStatus, deriveSecondaryStorageStatus, needsKeyOwnerAction, SalesPlanType, SseEntity, VersionCheckOperator, } from '@camunda/ccma-shared-types';
9
9
  import { observer } from 'mobx-react-lite';
10
10
  import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
@@ -487,37 +487,28 @@ export const C4ClusterDetailsApp = observer((props) => {
487
487
  // that still carries the old externalMetadata before the PATCH was applied).
488
488
  const skipNextSseMergeRef = useRef(false);
489
489
  const clusterLoadLoadedRef = useRef(false);
490
- const reloadClusterLoad = useCallback(async () => {
490
+ const reloadClusterLoad = useCallback(async (options) => {
491
491
  if (!canSeeClusterLoad) {
492
492
  return;
493
493
  }
494
494
  setClusterLoadLoading(true);
495
495
  try {
496
496
  const [perDay, last24h, latest] = await Promise.all([
497
- HdpService.getClusterCapacity({
498
- config: apiConfig,
499
- params: {
500
- orgId: props.orgId,
501
- clusterId: props.clusterId,
502
- operation: 'per-day',
503
- },
504
- }),
505
- HdpService.getClusterCapacity({
506
- config: apiConfig,
507
- params: {
508
- orgId: props.orgId,
509
- clusterId: props.clusterId,
510
- operation: '24h',
511
- },
512
- }),
513
- HdpService.getClusterCapacity({
514
- config: apiConfig,
515
- params: {
516
- orgId: props.orgId,
517
- clusterIds: [props.clusterId],
518
- operation: 'latest',
519
- },
520
- }),
497
+ data.readClusterCapacity({
498
+ orgId: props.orgId,
499
+ clusterId: props.clusterId,
500
+ operation: 'per-day',
501
+ }, options),
502
+ data.readClusterCapacity({
503
+ orgId: props.orgId,
504
+ clusterId: props.clusterId,
505
+ operation: '24h',
506
+ }, options),
507
+ data.readClusterCapacity({
508
+ orgId: props.orgId,
509
+ clusterIds: [props.clusterId],
510
+ operation: 'latest',
511
+ }, options),
521
512
  ]);
522
513
  const updatedPerDay = ensureClusterLoadPerDay(perDay);
523
514
  const updated24h = ensureClusterLoad24h(last24h);
@@ -535,7 +526,14 @@ export const C4ClusterDetailsApp = observer((props) => {
535
526
  clusterLoadLoadedRef.current = true;
536
527
  setClusterLoadLoading(false);
537
528
  }
538
- }, [apiConfig, canSeeClusterLoad, props.clusterId, props.orgId]);
529
+ }, [
530
+ data.readClusterCapacity,
531
+ canSeeClusterLoad,
532
+ props.clusterId,
533
+ props.orgId,
534
+ ]);
535
+ // The refresh button reads again. The initial loads share one read.
536
+ const forceReloadClusterLoad = useCallback(() => reloadClusterLoad({ force: true }), [reloadClusterLoad]);
539
537
  useEffect(() => {
540
538
  if (!canSeeClusterLoad)
541
539
  return;
@@ -1242,7 +1240,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1242
1240
  }
1243
1241
  return _jsx(_Fragment, {});
1244
1242
  }
1245
- return (_jsx(C4ClusterDetailsOverviewTab, { cluster: cluster, clusterError: clusterError, creationParameters: creationParameters, clustersOfOrg: clustersOfOrg, clusterPlanTypeReservations: clusterPlanTypeReservations, clusterLoadLatest: clusterLoadLatest, clusterLoadPerDay: clusterLoadPerDay, clusterLoad24h: clusterLoad24h, clusterLoadLoading: clusterLoadLoading, canSeeClusterLoad: canSeeClusterLoad, canEditCluster: Boolean(authz.visibilities.clusters?.canEdit), canWakeCluster: Boolean(authz.visibilities.clusters?.canWake), canSleepCluster: Boolean(authz.visibilities.clusters?.canSleep), canManageUsers: canManageUsers, canViewConnectorsLink: Boolean(orgPermissions?.cluster.connectors.read), hasIdentityIntegration: hasIdentityIntegration, orgId: props.orgId, clusterId: props.clusterId, jobDashboardEnabled: true, upgradeDocsUrls: urls.docs.upgrade, statisticsConfig: statisticsConfig, apiConfig: apiConfig, t: t ?? ((key) => key), onReloadCluster: reloadCluster, onReloadClusterLoad: reloadClusterLoad, onNavigate: props.onNavigate, ignoreGracePeriod: ignoreGracePeriod, upgradeGate: upgradeGate, clusterLoadDocsUrl: urls.docs.clusterLoad, restoreInProgress: cluster?.restoreInProgress, overviewSection: props.overviewSection, sectionVariant: props.sectionVariant }));
1243
+ return (_jsx(C4ClusterDetailsOverviewTab, { cluster: cluster, clusterError: clusterError, creationParameters: creationParameters, clustersOfOrg: clustersOfOrg, clusterPlanTypeReservations: clusterPlanTypeReservations, clusterLoadLatest: clusterLoadLatest, clusterLoadPerDay: clusterLoadPerDay, clusterLoad24h: clusterLoad24h, clusterLoadLoading: clusterLoadLoading, canSeeClusterLoad: canSeeClusterLoad, canEditCluster: Boolean(authz.visibilities.clusters?.canEdit), canWakeCluster: Boolean(authz.visibilities.clusters?.canWake), canSleepCluster: Boolean(authz.visibilities.clusters?.canSleep), canManageUsers: canManageUsers, canViewConnectorsLink: Boolean(orgPermissions?.cluster.connectors.read), hasIdentityIntegration: hasIdentityIntegration, orgId: props.orgId, clusterId: props.clusterId, jobDashboardEnabled: true, upgradeDocsUrls: urls.docs.upgrade, statisticsConfig: statisticsConfig, apiConfig: apiConfig, t: t ?? ((key) => key), onReloadCluster: reloadCluster, onReloadClusterLoad: forceReloadClusterLoad, onNavigate: props.onNavigate, ignoreGracePeriod: ignoreGracePeriod, upgradeGate: upgradeGate, clusterLoadDocsUrl: urls.docs.clusterLoad, restoreInProgress: cluster?.restoreInProgress, overviewSection: props.overviewSection, sectionVariant: props.sectionVariant }));
1246
1244
  }, [
1247
1245
  apiConfig,
1248
1246
  authz.visibilities.clusters?.canEdit,
@@ -1271,7 +1269,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1271
1269
  props.sectionVariant,
1272
1270
  urls,
1273
1271
  reloadCluster,
1274
- reloadClusterLoad,
1272
+ forceReloadClusterLoad,
1275
1273
  t,
1276
1274
  ]);
1277
1275
  // API clients and Alerts are managed via the console API and don't touch
@@ -47,6 +47,9 @@ export const C4ClusterDetailsAlertsTab = (props) => {
47
47
  const [alertUrlInvalidText, setAlertUrlInvalidText] = useState('');
48
48
  const [alertHmacInvalid, setAlertHmacInvalid] = useState(false);
49
49
  const [alertHmacInvalidText, setAlertHmacInvalidText] = useState('');
50
+ // Kept in state, not read from props.alerts on each render: the host reloads
51
+ // the alerts before the dialog closes, and the text must not change then.
52
+ const [deleteAlertTarget, setDeleteAlertTarget] = useState('');
50
53
  const alertEmailDestination = props.userEmail?.includes('@')
51
54
  ? ` (to ${props.userEmail})`
52
55
  : '';
@@ -121,6 +124,7 @@ export const C4ClusterDetailsAlertsTab = (props) => {
121
124
  }, onDeleteAlert: (alertId) => {
122
125
  trackEvent('clusterOverviewAlerts:deleteModal:open', 'Open Delete Alerts Modal', { alertId });
123
126
  setSelectedAlertId(alertId);
127
+ setDeleteAlertTarget(props.alerts.find((a) => a.id === alertId)?.userIdOrWebhook ?? '');
124
128
  setAlertMutationError('');
125
129
  setDeleteAlertOpen(true);
126
130
  }, onNoAlertsDocsClick: () => {
@@ -242,5 +246,7 @@ export const C4ClusterDetailsAlertsTab = (props) => {
242
246
  setAlertMutationBusy(false);
243
247
  }
244
248
  })();
245
- }, children: _jsxs(Stack, { gap: 6, children: [alertMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: safeTranslate(props.t, 'alerts:delete.error.generic', "We're having trouble deleting the alert"), subtitle: alertMutationError, lowContrast: true, hideCloseButton: true })), _jsx("p", { children: safeTranslate(props.t, 'alerts:delete.description', 'Are you sure you want to delete the alert') })] }) })] }));
249
+ }, children: _jsxs(Stack, { gap: 6, children: [alertMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: safeTranslate(props.t, 'alerts:delete.error.generic', "We're having trouble deleting the alert"), subtitle: alertMutationError, lowContrast: true, hideCloseButton: true })), _jsx("p", { style: { overflowWrap: 'anywhere' }, children: deleteAlertTarget
250
+ ? safeTranslate(props.t, 'alerts:delete.description', `Are you sure you want to delete the alert for "${deleteAlertTarget}"?`, { target: deleteAlertTarget })
251
+ : safeTranslate(props.t, 'alerts:delete.descriptionNoTarget', 'Are you sure you want to delete the alert?') })] }) })] }));
246
252
  };
@@ -249,10 +249,12 @@ export const C4ClusterDetailsSettingsTab = (props) => {
249
249
  setIsUpdatingLowLatency(false);
250
250
  }
251
251
  }, [props, clusterApi, runtime.telemetry]);
252
+ // Unset means on: the cluster runs Swagger until it is switched off.
253
+ const isSwaggerEnabled = props.cluster?.externalMetadata?.swagger ?? true;
252
254
  const toggleSwagger = useCallback(async () => {
253
255
  if (!props.cluster)
254
256
  return;
255
- const nextState = !props.cluster.externalMetadata?.swagger;
257
+ const nextState = !isSwaggerEnabled;
256
258
  setIsUpdatingSwagger(true);
257
259
  try {
258
260
  await clusterApi.updateCluster({
@@ -275,7 +277,7 @@ export const C4ClusterDetailsSettingsTab = (props) => {
275
277
  finally {
276
278
  setIsUpdatingSwagger(false);
277
279
  }
278
- }, [props, clusterApi, runtime.telemetry]);
280
+ }, [props, clusterApi, runtime.telemetry, isSwaggerEnabled]);
279
281
  const updateSecretsFilterMode = useCallback(async (mode) => {
280
282
  if (!props.cluster)
281
283
  return;
@@ -1041,7 +1043,7 @@ export const C4ClusterDetailsSettingsTab = (props) => {
1041
1043
  },
1042
1044
  ...(isSwaggerToggleVisible && {
1043
1045
  swaggerToggle: {
1044
- enabled: props.cluster.externalMetadata?.swagger ?? true,
1046
+ enabled: isSwaggerEnabled,
1045
1047
  description: (_jsxs(_Fragment, { children: [safeTranslate(props.t, 'clusterdetails:settings.swagger.description', 'The Orchestration Cluster REST API is documented using the'), ' ', _jsx(Link, { href: 'https://github.com/camunda/camunda/blob/main/zeebe/gateway-protocol/src/main/proto/rest-api.yaml', target: '_blank', children: safeTranslate(props.t, 'clusterdetails:settings.swagger.spec', 'OpenAPI specification') }), safeTranslate(props.t, 'clusterdetails:settings.swagger.description2', '. When enabled, it is accessible via Swagger UI.'), _jsx("br", {}), _jsx("br", {}), (() => {
1046
1048
  const swaggerUrl = buildClusterSwaggerUrl({
1047
1049
  cluster: props.cluster,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/ccma-saas-frontend",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
4
4
  "description": "Camunda Composite Components",
5
5
  "bugs": {
6
6
  "url": "https://github.com/camunda/camunda-cloud-management-apps/issues"