@camunda/ccma-saas-frontend 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/components/c4-charts-dashboard/elements/bar-chart.js +2 -2
- package/lib/esm/components/c4-cluster-client-credentials/c4-cluster-client-credentials.js +1 -1
- package/lib/esm/components/c4-cluster-client-credentials-identity/c4-cluster-client-credentials-identity.js +1 -1
- package/lib/esm/components/c4-cluster-details-encryption/c4-cluster-details-encryption.d.ts +1 -1
- package/lib/esm/components/c4-cluster-details-encryption/c4-cluster-details-encryption.js +24 -1
- package/lib/esm/components/c4-cluster-details-encryption/c4-cluster-details-encryption.types.d.ts +14 -1
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.d.ts +1 -1
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.js +24 -9
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.types.d.ts +6 -0
- package/lib/esm/components/c4-cluster-overview/cluster-details.d.ts +2 -0
- package/lib/esm/components/c4-cluster-overview/cluster-details.js +10 -1
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.d.ts +1 -1
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.js +4 -2
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.mocks.js +1 -1
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.types.d.ts +4 -0
- package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider-modal.js +15 -5
- package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider.d.ts +12 -1
- package/lib/esm/components/c4-cluster-settings/elements/external-identity-provider.js +9 -3
- package/lib/esm/components/c4-cluster-settings/elements/session-settings.d.ts +13 -0
- package/lib/esm/components/c4-cluster-settings/elements/session-settings.js +69 -0
- package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.js +19 -1
- package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.mocks.js +2 -1
- package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.types.d.ts +1 -0
- package/lib/esm/components/c4-create-console-api-client-modal/c4-create-console-api-client-modal.js +12 -0
- package/lib/esm/components/c4-create-ip-whitelist-modal/c4-create-ip-whitelist-modal.js +7 -2
- package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.d.ts +1 -1
- package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.js +3 -3
- package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.types.d.ts +7 -0
- package/lib/esm/components/c4-invite-user-to-organization-modal/c4-invite-user-to-organization-modal.js +15 -8
- package/lib/esm/components/c4-invite-user-to-organization-modal/c4-invite-user-to-organization-modal.types.d.ts +1 -0
- package/lib/esm/components/c4-navigation/c4-navigation.js +17 -9
- package/lib/esm/components/c4-structured-list/c4-structured-list.js +15 -1
- package/lib/esm/components/c4-usage-history/elements/usage-history-charts.d.ts +7 -1
- package/lib/esm/components/c4-usage-history/elements/usage-history-charts.js +2 -2
- package/lib/esm/components/shared-charts/ds-line-chart.js +2 -2
- package/lib/esm/components/shared-charts/recharts-tokens.d.ts +24 -9
- package/lib/esm/components/shared-charts/recharts-tokens.js +40 -13
- package/lib/esm/i18n/en/entities/orgroles.json +26 -0
- package/lib/esm/i18n/en/modals/apiclients.json +4 -1
- package/lib/esm/i18n/en/modals/backups.json +2 -0
- package/lib/esm/i18n/en/pages/clusterdetails.json +3 -2
- package/lib/esm/i18n/en/pages/clusters.json +4 -1
- package/lib/esm/i18n/en/pages/orgmanagement.json +9 -1
- package/lib/esm/runtime/nav/use-webapp-nav-data.d.ts +18 -0
- package/lib/esm/runtime/nav/use-webapp-nav-data.js +39 -15
- package/lib/esm/utils/http-error-message.d.ts +14 -0
- package/lib/esm/utils/http-error-message.js +35 -0
- package/lib/esm/utils/role-labels.d.ts +25 -7
- package/lib/esm/utils/role-labels.js +94 -13
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.d.ts +3 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +159 -34
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.types.d.ts +3 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-page.js +18 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-page.types.d.ts +5 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-alerts-tab.d.ts +1 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-encryption-tab.d.ts +2 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-encryption-tab.js +16 -3
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.d.ts +19 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +108 -58
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.d.ts +1 -1
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.js +15 -3
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +3 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +109 -26
- package/lib/esm/widgets/clusters/c4-clusters-page.js +18 -1
- package/lib/esm/widgets/clusters/c4-clusters-page.types.d.ts +4 -0
- package/lib/esm/widgets/management/c4-management-app.d.ts +1 -1
- package/lib/esm/widgets/management/c4-management-app.js +404 -98
- package/lib/esm/widgets/management/c4-management-app.types.d.ts +2 -0
- package/lib/esm/widgets/management/tabs/c4-management-api-tab.js +21 -0
- package/lib/esm/widgets/management/tabs/c4-management-usage-tab.d.ts +30 -1
- package/lib/esm/widgets/management/tabs/c4-management-usage-tab.js +34 -14
- package/lib/esm/widgets/management/tabs/c4-management-users-tab.d.ts +2 -1
- package/lib/esm/widgets/management/tabs/c4-management-users-tab.js +46 -17
- package/lib/esm/widgets/user-details/c4-user-details-page.d.ts +1 -1
- package/lib/esm/widgets/user-details/c4-user-details-page.js +22 -8
- package/lib/esm/widgets/user-details/c4-user-details-page.types.d.ts +2 -0
- package/package.json +11 -11
|
@@ -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 { checkVersion, getDisplayedSalesPlan, getRevisitedSalesPlanName, OrganizationRole, SseEntity, 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, 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,7 +20,8 @@ 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 {
|
|
23
|
+
import { clientErrorMessage } from '../../utils/http-error-message.js';
|
|
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';
|
|
26
27
|
import { managementTab } from './management-tabs.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"
|
|
@@ -493,28 +509,11 @@ function toDate(value) {
|
|
|
493
509
|
}
|
|
494
510
|
return undefined;
|
|
495
511
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (next.getDate() !== originalDay) {
|
|
502
|
-
next.setDate(0);
|
|
503
|
-
}
|
|
504
|
-
return next;
|
|
505
|
-
}
|
|
506
|
-
// HDP value metrics are bucketed per UTC day (a BigQuery DATE column, so every
|
|
507
|
-
// row's ts is UTC midnight), whereas the enterprise period bounds keep the
|
|
508
|
-
// wall-clock time of enterpriseStartDate. Comparing the two directly would drop
|
|
509
|
-
// the term's first day whenever the plan was created after midnight, so both
|
|
510
|
-
// bounds are collapsed to the UTC day they fall on before comparing.
|
|
511
|
-
function toUtcDayStartMs(date) {
|
|
512
|
-
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
513
|
-
}
|
|
514
|
-
function diffInMonthsSimple(start, end) {
|
|
515
|
-
return ((end.getFullYear() - start.getFullYear()) * 12 +
|
|
516
|
-
(end.getMonth() - start.getMonth()));
|
|
517
|
-
}
|
|
512
|
+
// Contract-period arithmetic (month-end clamping, current-period resolution,
|
|
513
|
+
// the UTC-day normalisation that keeps a term's first day from being dropped
|
|
514
|
+
// when the plan was created after midnight) lives in `@camunda/ccma-shared-types`
|
|
515
|
+
// so this tab, control-frontend and accounts-frontend cannot disagree about
|
|
516
|
+
// which days a figure covers. See `enterpriseTerm.utils.ts`.
|
|
518
517
|
function formatDate(date) {
|
|
519
518
|
try {
|
|
520
519
|
return Intl.DateTimeFormat('en-GB', {
|
|
@@ -531,6 +530,30 @@ function formatDate(date) {
|
|
|
531
530
|
function getNumber(value, fallback = 0) {
|
|
532
531
|
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
533
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
|
+
}
|
|
534
557
|
function themeNameToClassName(theme) {
|
|
535
558
|
switch (theme) {
|
|
536
559
|
case 'dark':
|
|
@@ -539,7 +562,7 @@ function themeNameToClassName(theme) {
|
|
|
539
562
|
return 'g10';
|
|
540
563
|
}
|
|
541
564
|
}
|
|
542
|
-
export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onNavigate, legacyTabs, userPersonaRole, isLicensingModel2025: isLicensingModel2025Prop, tenantsValueMetricEnabled = false, hdpValueMetricsFor2025Enabled = false, urls, onNeedsReload, }) => {
|
|
565
|
+
export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onNavigate, legacyTabs, userPersonaRole, isLicensingModel2025: isLicensingModel2025Prop, tenantsValueMetricEnabled = false, hdpValueMetricsFor2025Enabled = false, permissionsReworkEnabled = false, urls, onNeedsReload, }) => {
|
|
543
566
|
const runtime = useC4ConsoleRuntime();
|
|
544
567
|
const designSystem = useC4DesignSystem();
|
|
545
568
|
const data = useC4ConsoleData();
|
|
@@ -734,6 +757,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
734
757
|
const [leaveOrganizationOpen, setLeaveOrganizationOpen] = useState(false);
|
|
735
758
|
const [deleteOrganizationOpen, setDeleteOrganizationOpen] = useState(false);
|
|
736
759
|
const [deleteOrganizationError, setDeleteOrganizationError] = useState(false);
|
|
760
|
+
const [deleteOrganizationErrorMessage, setDeleteOrganizationErrorMessage] = useState(undefined);
|
|
737
761
|
const [isExtendModalOpen, setIsExtendModalOpen] = useState(false);
|
|
738
762
|
const { submit: submitExtendTrial, isSubmitting: isExtendSubmitting, error: extendError, } = useExtendTrial(orgId, {
|
|
739
763
|
onSuccess: () => {
|
|
@@ -947,12 +971,41 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
947
971
|
const [usageClusters, setUsageClusters] = useState([]);
|
|
948
972
|
const [usageMetricsMonthly, setUsageMetricsMonthly] = useState([]);
|
|
949
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);
|
|
950
990
|
const [billingLoading, setBillingLoading] = useState(false);
|
|
951
991
|
const [billingError, setBillingError] = useState(undefined);
|
|
952
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);
|
|
953
1004
|
const [billingMetricsMonthly, setBillingMetricsMonthly] = useState([]);
|
|
954
1005
|
const [billingUsageAlerts, setBillingUsageAlerts] = useState([]);
|
|
955
|
-
|
|
1006
|
+
// Raw daily points rather than a pre-reduced peak: the peak has to be taken
|
|
1007
|
+
// over the current contract period, which isn't known at fetch time.
|
|
1008
|
+
const [billingTenantUsage, setBillingTenantUsage] = useState([]);
|
|
956
1009
|
const [billingHdpUsageMetrics, setBillingHdpUsageMetrics] = useState([]);
|
|
957
1010
|
const [apiClients, setApiClients] = useState([]);
|
|
958
1011
|
const [apiClientsLoading, setApiClientsLoading] = useState(false);
|
|
@@ -1080,48 +1133,158 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1080
1133
|
activeTabId,
|
|
1081
1134
|
refreshEarlyAccessFeatures,
|
|
1082
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]);
|
|
1083
1160
|
const loadUsage = useCallback(async () => {
|
|
1084
1161
|
setUsageLoading(true);
|
|
1162
|
+
setUsageError(undefined);
|
|
1085
1163
|
try {
|
|
1086
1164
|
await data.fetchClusters(orgId, { force: true });
|
|
1087
1165
|
const clusters = data.clusters[orgId]?.error
|
|
1088
1166
|
? []
|
|
1089
1167
|
: (data.getClusters(orgId) ?? []);
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
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
|
+
}),
|
|
1105
1209
|
]);
|
|
1106
1210
|
const normalizedClusters = (clusters ?? []).filter((item) => Boolean(item) && typeof item === 'object');
|
|
1107
1211
|
setUsageClusters(normalizedClusters);
|
|
1108
|
-
setUsageMetricsMonthly(
|
|
1109
|
-
|
|
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
|
+
}
|
|
1110
1237
|
}
|
|
1111
|
-
catch {
|
|
1238
|
+
catch (error) {
|
|
1112
1239
|
setUsageClusters([]);
|
|
1113
1240
|
setUsageMetricsMonthly([]);
|
|
1114
1241
|
setUsageMetricsPerDay([]);
|
|
1242
|
+
setUsageHdpMetrics([]);
|
|
1243
|
+
setUsageTenantUsage([]);
|
|
1244
|
+
setUsageTenantPerCluster([]);
|
|
1245
|
+
setUsageError(usageErrorMessage([error]));
|
|
1115
1246
|
}
|
|
1116
1247
|
finally {
|
|
1117
1248
|
setUsageLoading(false);
|
|
1118
1249
|
}
|
|
1119
|
-
}, [apiConfig, orgId]);
|
|
1120
|
-
const isLicensingModel2025 = useMemo(() => isLicensingModel2025Prop ??
|
|
1121
|
-
getNestedValue(org, ['metadata', 'licensingModel']) === '2025', [isLicensingModel2025Prop, org]);
|
|
1250
|
+
}, [apiConfig, orgId, usageFromHdp, usageTenantsEnabled, usageErrorMessage]);
|
|
1122
1251
|
const loadBilling = useCallback(async () => {
|
|
1252
|
+
const loadId = billingLoadIdRef.current + 1;
|
|
1253
|
+
billingLoadIdRef.current = loadId;
|
|
1123
1254
|
setBillingLoading(true);
|
|
1124
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
|
+
});
|
|
1125
1288
|
try {
|
|
1126
1289
|
await data.fetchClusters(orgId, { force: true });
|
|
1127
1290
|
const clusters = data.clusters[orgId]?.error
|
|
@@ -1142,7 +1305,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1142
1305
|
tenantsValueMetricEnabled && isLicensingModel2025
|
|
1143
1306
|
? HdpService.getTenantUsage({
|
|
1144
1307
|
config: apiConfig,
|
|
1145
|
-
params: { orgId, days:
|
|
1308
|
+
params: { orgId, days: MAX_TENANT_USAGE_DAYS },
|
|
1146
1309
|
})
|
|
1147
1310
|
: Promise.resolve([]),
|
|
1148
1311
|
hdpValueMetricsFor2025Enabled && isLicensingModel2025
|
|
@@ -1157,16 +1320,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1157
1320
|
const alerts = alertsResult.status === 'fulfilled' ? alertsResult.value : undefined;
|
|
1158
1321
|
const loadErrors = [monthlyResult, alertsResult, hdpUsageResult].filter((result) => result.status === 'rejected');
|
|
1159
1322
|
const tenantUsage = tenantsResult.status === 'fulfilled' ? tenantsResult.value : [];
|
|
1160
|
-
const tenantPeak = tenantUsage.length > 0
|
|
1161
|
-
? Math.max(...tenantUsage.map((point) => point.value))
|
|
1162
|
-
: 0;
|
|
1163
1323
|
const hdpUsageMetrics = hdpUsageResult.status === 'fulfilled'
|
|
1164
1324
|
? (hdpUsageResult.value?.valueMetrics?.valueMetrics ?? [])
|
|
1165
1325
|
: [];
|
|
1166
1326
|
setBillingClusters(normalizedClusters);
|
|
1167
1327
|
setBillingMetricsMonthly(monthly ?? []);
|
|
1168
1328
|
setBillingUsageAlerts(alerts?.usageAlerts ?? []);
|
|
1169
|
-
|
|
1329
|
+
setBillingTenantUsage(tenantUsage);
|
|
1170
1330
|
setBillingHdpUsageMetrics(hdpUsageMetrics);
|
|
1171
1331
|
if (loadErrors.length > 0) {
|
|
1172
1332
|
const firstError = loadErrors[0]?.reason;
|
|
@@ -1176,10 +1336,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1176
1336
|
}
|
|
1177
1337
|
}
|
|
1178
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.
|
|
1179
1342
|
setBillingClusters([]);
|
|
1180
1343
|
setBillingMetricsMonthly([]);
|
|
1181
1344
|
setBillingUsageAlerts([]);
|
|
1182
|
-
|
|
1345
|
+
setBillingTenantUsage([]);
|
|
1183
1346
|
setBillingHdpUsageMetrics([]);
|
|
1184
1347
|
setBillingError(error instanceof Error ? error.message : 'Could not load billing');
|
|
1185
1348
|
}
|
|
@@ -1241,7 +1404,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1241
1404
|
// the correct reference point for period labels.
|
|
1242
1405
|
const inferredStartDate = startCandidates
|
|
1243
1406
|
.filter((c) => typeof c.monthsSinceStart === 'number')
|
|
1244
|
-
.map((c) =>
|
|
1407
|
+
.map((c) => addMonthsClamped(c.startDate, -c.monthsSinceStart))
|
|
1245
1408
|
.sort((a, b) => a.getTime() - b.getTime())[0];
|
|
1246
1409
|
const orgEnterpriseStartBilling = toDate(getNestedValue(org, ['organizationToSalesPlan', 'enterpriseStartDate']));
|
|
1247
1410
|
const orgTrialStartBilling = toDate(getNestedValue(org, ['organizationToSalesPlan', 'trialPlanStartDate']));
|
|
@@ -1258,20 +1421,10 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1258
1421
|
const durationInMonths = typeof durationInMonthsRaw === 'number' && durationInMonthsRaw > 0
|
|
1259
1422
|
? durationInMonthsRaw
|
|
1260
1423
|
: 12;
|
|
1261
|
-
const monthsDiff = Math.abs(diffInMonthsSimple(startDate, now));
|
|
1262
|
-
const completedPeriods = Math.floor(monthsDiff / durationInMonths);
|
|
1263
|
-
const periodStart = addMonthsSafe(startDate, completedPeriods * durationInMonths);
|
|
1264
|
-
const periodEnd = new Date(addMonthsSafe(periodStart, durationInMonths).getTime() - DAY_MS);
|
|
1265
|
-
const startMonth = completedPeriods * durationInMonths;
|
|
1266
|
-
const endMonth = startMonth + (durationInMonths - 1);
|
|
1267
1424
|
return {
|
|
1268
1425
|
startDate,
|
|
1269
1426
|
durationInMonths,
|
|
1270
|
-
|
|
1271
|
-
periodEnd,
|
|
1272
|
-
startMonth,
|
|
1273
|
-
endMonth,
|
|
1274
|
-
nextRenewal: addMonthsSafe(periodStart, durationInMonths),
|
|
1427
|
+
...getCurrentEnterpriseTerm({ startDate, durationInMonths, now }),
|
|
1275
1428
|
};
|
|
1276
1429
|
}, [billingMetricsMonthly, org]);
|
|
1277
1430
|
const billingIncludedMetrics = useMemo(() => {
|
|
@@ -1288,9 +1441,16 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1288
1441
|
};
|
|
1289
1442
|
}, [org]);
|
|
1290
1443
|
const billingCurrentMetrics = useMemo(() => {
|
|
1444
|
+
const periodStartDayMs = toUtcDayStartMs(billingEnterprisePeriod.periodStart);
|
|
1445
|
+
const periodEndDayMs = toUtcDayStartMs(billingEnterprisePeriod.periodEnd);
|
|
1446
|
+
// Peak tenants *inside the current contract period*, matching the window
|
|
1447
|
+
// the PI/DI/TU totals below use. Reducing over the whole fetched history
|
|
1448
|
+
// instead would let a previous term's peak be billed against this term's
|
|
1449
|
+
// included quota. Tenants is a gauge, so the peak is taken over the daily
|
|
1450
|
+
// org totals rather than summed. Shared with the two internal tools so all
|
|
1451
|
+
// three surfaces report the same number for the same org.
|
|
1452
|
+
const tenantPeak = peakWithinTerm(billingTenantUsage, billingEnterprisePeriod);
|
|
1291
1453
|
if (hdpValueMetricsFor2025Enabled && isLicensingModel2025) {
|
|
1292
|
-
const periodStartDayMs = toUtcDayStartMs(billingEnterprisePeriod.periodStart);
|
|
1293
|
-
const periodEndDayMs = toUtcDayStartMs(billingEnterprisePeriod.periodEnd);
|
|
1294
1454
|
return billingHdpUsageMetrics
|
|
1295
1455
|
.filter((entry) => entry.date.ts >= periodStartDayMs &&
|
|
1296
1456
|
entry.date.ts <= periodEndDayMs)
|
|
@@ -1303,7 +1463,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1303
1463
|
processInstances: 0,
|
|
1304
1464
|
decisionInstances: 0,
|
|
1305
1465
|
taskUsers: 0,
|
|
1306
|
-
tenants:
|
|
1466
|
+
tenants: tenantPeak,
|
|
1307
1467
|
});
|
|
1308
1468
|
}
|
|
1309
1469
|
const relevant = billingMetricsMonthly.filter((entry) => {
|
|
@@ -1321,7 +1481,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1321
1481
|
processInstances: 0,
|
|
1322
1482
|
decisionInstances: 0,
|
|
1323
1483
|
taskUsers: 0,
|
|
1324
|
-
tenants:
|
|
1484
|
+
tenants: tenantPeak,
|
|
1325
1485
|
});
|
|
1326
1486
|
}, [
|
|
1327
1487
|
billingEnterprisePeriod.endMonth,
|
|
@@ -1329,7 +1489,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1329
1489
|
billingEnterprisePeriod.periodStart,
|
|
1330
1490
|
billingEnterprisePeriod.periodEnd,
|
|
1331
1491
|
billingMetricsMonthly,
|
|
1332
|
-
|
|
1492
|
+
billingTenantUsage,
|
|
1333
1493
|
billingHdpUsageMetrics,
|
|
1334
1494
|
hdpValueMetricsFor2025Enabled,
|
|
1335
1495
|
isLicensingModel2025,
|
|
@@ -1360,7 +1520,10 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1360
1520
|
return Object.keys(reservedMap)
|
|
1361
1521
|
.map((clusterPlanTypeId) => {
|
|
1362
1522
|
const reserved = getNumber(reservedMap[clusterPlanTypeId]);
|
|
1363
|
-
|
|
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);
|
|
1364
1527
|
const matchingClusters = billingClusters.filter((cluster) => {
|
|
1365
1528
|
const planTypeObj = getRecord(cluster, 'planType');
|
|
1366
1529
|
return planTypeObj?.uuid === clusterPlanTypeId;
|
|
@@ -1379,7 +1542,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1379
1542
|
};
|
|
1380
1543
|
})
|
|
1381
1544
|
.filter((row) => row.reserved > 0);
|
|
1382
|
-
}, [billingClusters, org]);
|
|
1545
|
+
}, [billingClusterPlanTypeNames, billingClusters, org]);
|
|
1383
1546
|
const billingTabProps = useMemo(() => {
|
|
1384
1547
|
return {
|
|
1385
1548
|
billingIsEnterprise,
|
|
@@ -1453,10 +1616,38 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1453
1616
|
}
|
|
1454
1617
|
return map;
|
|
1455
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]);
|
|
1456
1647
|
const usageCharts = useMemo(() => {
|
|
1457
1648
|
const orgName = typeof org?.name === 'string' ? org.name : orgId;
|
|
1458
1649
|
const theme = themeNameToClassName(c3Profile.resolvedTheme);
|
|
1459
|
-
const sorted =
|
|
1650
|
+
const sorted = usagePerDayEntries
|
|
1460
1651
|
.slice()
|
|
1461
1652
|
.map((entry) => {
|
|
1462
1653
|
const startDate = toDate(entry.startDate);
|
|
@@ -1529,6 +1720,24 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1529
1720
|
axes: { titleBottom, titleLeft },
|
|
1530
1721
|
dataPoints: tuCapped,
|
|
1531
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,
|
|
1532
1741
|
};
|
|
1533
1742
|
}, [
|
|
1534
1743
|
c3Profile.resolvedTheme,
|
|
@@ -1537,11 +1746,85 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1537
1746
|
org?.name,
|
|
1538
1747
|
orgId,
|
|
1539
1748
|
t,
|
|
1540
|
-
|
|
1749
|
+
usagePerDayEntries,
|
|
1750
|
+
usageTenantsEnabled,
|
|
1751
|
+
usageTenantUsage,
|
|
1541
1752
|
]);
|
|
1542
1753
|
const usageHistory = useMemo(() => {
|
|
1543
|
-
const metrics =
|
|
1754
|
+
const metrics = usageMonthlyEntries;
|
|
1544
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
|
+
};
|
|
1545
1828
|
const startCandidates = (metrics ?? [])
|
|
1546
1829
|
.map((m) => {
|
|
1547
1830
|
const startDate = toDate(m.startDate);
|
|
@@ -1562,7 +1845,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1562
1845
|
// the correct reference point for period labels.
|
|
1563
1846
|
const inferredStartDate = startCandidates
|
|
1564
1847
|
.filter((c) => typeof c.monthsSinceStart === 'number')
|
|
1565
|
-
.map((c) =>
|
|
1848
|
+
.map((c) => addMonthsClamped(c.startDate, -c.monthsSinceStart))
|
|
1566
1849
|
.sort((a, b) => a.getTime() - b.getTime())[0];
|
|
1567
1850
|
const orgEnterpriseStart = toDate(getNestedValue(org, ['organizationToSalesPlan', 'enterpriseStartDate']));
|
|
1568
1851
|
const orgTrialStart = toDate(getNestedValue(org, ['organizationToSalesPlan', 'trialPlanStartDate']));
|
|
@@ -1573,13 +1856,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1573
1856
|
inferredStartDate ??
|
|
1574
1857
|
now;
|
|
1575
1858
|
const durationInMonths = usageGroupBy === 'month' ? 1 : 12;
|
|
1576
|
-
const monthsDiff =
|
|
1859
|
+
const monthsDiff = diffInWholeMonths(startDate, now);
|
|
1577
1860
|
const iterationsRaw = usageGroupBy === 'month' ? monthsDiff : Math.floor(monthsDiff / 12);
|
|
1578
1861
|
const iterations = Math.max(0, Math.abs(iterationsRaw));
|
|
1579
1862
|
const periods = [];
|
|
1580
1863
|
for (let i = 0; i <= iterations; i++) {
|
|
1581
|
-
const periodStart =
|
|
1582
|
-
const periodEnd = new Date(
|
|
1864
|
+
const periodStart = addMonthsClamped(startDate, i * durationInMonths);
|
|
1865
|
+
const periodEnd = new Date(addMonthsClamped(periodStart, durationInMonths).getTime() - DAY_MS);
|
|
1583
1866
|
periods.push({ start: periodStart, end: periodEnd });
|
|
1584
1867
|
}
|
|
1585
1868
|
// If monthly metrics are missing, build the full period list and aggregate from per-day metrics.
|
|
@@ -1594,10 +1877,18 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1594
1877
|
generalUsers: 0,
|
|
1595
1878
|
perCluster: new Map(),
|
|
1596
1879
|
}));
|
|
1597
|
-
|
|
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 ?? [])
|
|
1598
1889
|
.map((entry) => {
|
|
1599
1890
|
const date = toDate(entry.startDate);
|
|
1600
|
-
const timestamp = date
|
|
1891
|
+
const timestamp = date ? toUtcDayStartMs(date) : undefined;
|
|
1601
1892
|
return {
|
|
1602
1893
|
entry,
|
|
1603
1894
|
date,
|
|
@@ -1609,14 +1900,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1609
1900
|
let periodIndex = 0;
|
|
1610
1901
|
for (const item of perDaySorted) {
|
|
1611
1902
|
while (periodIndex < periods.length &&
|
|
1612
|
-
item.timestamp >
|
|
1903
|
+
item.timestamp > periodBounds[periodIndex].end) {
|
|
1613
1904
|
periodIndex += 1;
|
|
1614
1905
|
}
|
|
1615
1906
|
if (periodIndex >= periods.length) {
|
|
1616
1907
|
break;
|
|
1617
1908
|
}
|
|
1618
|
-
|
|
1619
|
-
if (item.timestamp < currentPeriod.start.getTime()) {
|
|
1909
|
+
if (item.timestamp < periodBounds[periodIndex].start) {
|
|
1620
1910
|
continue;
|
|
1621
1911
|
}
|
|
1622
1912
|
const target = aggregated[periodIndex];
|
|
@@ -1642,15 +1932,13 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1642
1932
|
.slice()
|
|
1643
1933
|
.sort((a, b) => b.iteration - a.iteration)
|
|
1644
1934
|
.map((entry, index) => {
|
|
1645
|
-
const perCluster = Array.from(entry.perCluster.entries())
|
|
1646
|
-
.map(([clusterId, clusterValues]) => ({
|
|
1935
|
+
const perCluster = withTenantsPerCluster(Array.from(entry.perCluster.entries()).map(([clusterId, clusterValues]) => ({
|
|
1647
1936
|
clusterId,
|
|
1648
1937
|
clusterName: clusterValues.clusterName,
|
|
1649
1938
|
processInstances: clusterValues.processInstances,
|
|
1650
1939
|
decisionInstances: clusterValues.decisionInstances,
|
|
1651
1940
|
taskUsers: clusterValues.taskUsers,
|
|
1652
|
-
}))
|
|
1653
|
-
.sort((a, b) => b.processInstances - a.processInstances);
|
|
1941
|
+
})), tenantsPerClusterForPeriod(entry.start, entry.end)).sort((a, b) => b.processInstances - a.processInstances);
|
|
1654
1942
|
return {
|
|
1655
1943
|
id: String(entry.iteration),
|
|
1656
1944
|
originalIndex: index,
|
|
@@ -1658,6 +1946,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1658
1946
|
decisionInstances: entry.decisionInstances,
|
|
1659
1947
|
taskUsers: entry.taskUsers,
|
|
1660
1948
|
generalUsers: entry.generalUsers,
|
|
1949
|
+
tenants: tenantsForPeriod(entry.start, entry.end),
|
|
1661
1950
|
period: `${formatDate(entry.start)} - ${formatDate(entry.end)}`,
|
|
1662
1951
|
perCluster,
|
|
1663
1952
|
};
|
|
@@ -1666,8 +1955,8 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1666
1955
|
const iterations2 = iterations;
|
|
1667
1956
|
const aggregated = [];
|
|
1668
1957
|
for (let i = 0; i <= iterations2; i++) {
|
|
1669
|
-
const periodStart =
|
|
1670
|
-
const periodEnd = new Date(
|
|
1958
|
+
const periodStart = addMonthsClamped(startDate, i * durationInMonths);
|
|
1959
|
+
const periodEnd = new Date(addMonthsClamped(periodStart, durationInMonths).getTime() - DAY_MS);
|
|
1671
1960
|
const currentStartMonth = i * durationInMonths;
|
|
1672
1961
|
const currentEndMonth = i * durationInMonths + (durationInMonths - 1);
|
|
1673
1962
|
const perCluster = [];
|
|
@@ -1729,16 +2018,20 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
1729
2018
|
decisionInstances: entry.decisionInstances,
|
|
1730
2019
|
taskUsers: entry.taskUsers,
|
|
1731
2020
|
generalUsers: entry.generalUsers,
|
|
2021
|
+
tenants: tenantsForPeriod(entry.start, entry.end),
|
|
1732
2022
|
period: `${formatDate(entry.start)} - ${formatDate(entry.end)}`,
|
|
1733
|
-
perCluster: entry.perCluster,
|
|
2023
|
+
perCluster: withTenantsPerCluster(entry.perCluster, tenantsPerClusterForPeriod(entry.start, entry.end)),
|
|
1734
2024
|
};
|
|
1735
2025
|
});
|
|
1736
2026
|
}, [
|
|
1737
2027
|
clusterIdToName,
|
|
1738
2028
|
org,
|
|
1739
2029
|
usageGroupBy,
|
|
1740
|
-
|
|
1741
|
-
|
|
2030
|
+
usageMonthlyEntries,
|
|
2031
|
+
usagePerDayEntries,
|
|
2032
|
+
usageTenantsEnabled,
|
|
2033
|
+
usageTenantUsage,
|
|
2034
|
+
usageTenantPerCluster,
|
|
1742
2035
|
]);
|
|
1743
2036
|
const canReadActivity = useMemo(() => getNestedBoolean(org, ['permissions', 'org', 'activity', 'read']), [org]);
|
|
1744
2037
|
const loadAudits = useCallback(async (opts) => {
|
|
@@ -2610,13 +2903,16 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
2610
2903
|
const more = [];
|
|
2611
2904
|
if (mayUpdateGeneralVisible) {
|
|
2612
2905
|
primary.push(OrganizationRole.MODELER, OrganizationRole.ANALYST);
|
|
2906
|
+
if (permissionsReworkEnabled) {
|
|
2907
|
+
primary.push(OrganizationRole.OPERATIONS_ENGINEER);
|
|
2908
|
+
}
|
|
2613
2909
|
}
|
|
2614
2910
|
if (mayUpdateAdminVisible) {
|
|
2615
2911
|
primary.push(OrganizationRole.ADMIN);
|
|
2616
2912
|
}
|
|
2617
2913
|
// Candidate set only; the users tab filters it per member.
|
|
2618
2914
|
if (mayUpdateGeneralVisible) {
|
|
2619
|
-
more.push(...
|
|
2915
|
+
more.push(...legacySectionRoles(permissionsReworkEnabled));
|
|
2620
2916
|
}
|
|
2621
2917
|
more.push(OrganizationRole.MEMBER);
|
|
2622
2918
|
return { primary, more };
|
|
@@ -2693,7 +2989,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
2693
2989
|
id: 'users',
|
|
2694
2990
|
label: getTabLabel(legacyTabs, 'users', tabTitle('users')),
|
|
2695
2991
|
visible: canReadMembers,
|
|
2696
|
-
component: (_jsx(C4ManagementUsersTab, { orgId: orgId, members: members, loading: membersLoading, mayManageUsersActions: mayManageUsersActions, mayInviteUsers: Boolean(mayInviteMembers || mayInviteAdmins), showLegacyClusterRoles: showLegacyClusterRoles, inviteModal: {
|
|
2992
|
+
component: (_jsx(C4ManagementUsersTab, { orgId: orgId, members: members, loading: membersLoading, mayManageUsersActions: mayManageUsersActions, mayInviteUsers: Boolean(mayInviteMembers || mayInviteAdmins), showLegacyClusterRoles: showLegacyClusterRoles, permissionsReworkEnabled: permissionsReworkEnabled, inviteModal: {
|
|
2697
2993
|
showAdminRole: Boolean(mayInviteAdmins),
|
|
2698
2994
|
learnMoreUrl: identityAuthorizationsDocsUrl,
|
|
2699
2995
|
}, changeRolesModal: {
|
|
@@ -2812,7 +3108,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
2812
3108
|
visible: usageVisible,
|
|
2813
3109
|
component: (_jsx(C4ManagementUsageTab, { loading: usageLoading, groupBy: usageGroupBy, onGroupByChange: (next) => {
|
|
2814
3110
|
setUsageGroupBy(next);
|
|
2815
|
-
}, perClusterAvailable: true, history: usageHistory, charts: usageCharts, isLicensingModel2025: isLicensingModel2025, text: {
|
|
3111
|
+
}, perClusterAvailable: true, history: usageHistory, charts: usageCharts, isLicensingModel2025: isLicensingModel2025, showTenants: usageTenantsEnabled, error: usageError, text: {
|
|
2816
3112
|
tableTabTitle: safeTranslate(t, 'orgmanagement:tabs.billing.billingHistory.table.tabTitle', 'Table'),
|
|
2817
3113
|
chartsTabTitle: safeTranslate(t, 'orgmanagement:tabs.billing.billingHistory.charts.tabTitle', 'Charts'),
|
|
2818
3114
|
headers: {
|
|
@@ -2820,6 +3116,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
2820
3116
|
processInstances: safeTranslate(t, 'orgmanagement:tabs.usage.processInstances', 'Process instances'),
|
|
2821
3117
|
decisionInstances: safeTranslate(t, 'orgmanagement:tabs.usage.decisionInstances', 'Decision instances'),
|
|
2822
3118
|
taskUsers: safeTranslate(t, 'orgmanagement:tabs.usage.taskUsers', 'Task users'),
|
|
3119
|
+
tenants: safeTranslate(t, 'orgmanagement:tabs.usage.tenants', 'Tenants'),
|
|
2823
3120
|
},
|
|
2824
3121
|
groupBy: {
|
|
2825
3122
|
heading: safeTranslate(t, 'orgmanagement:tabs.usage.history.groupBySelect.heading', 'Group by'),
|
|
@@ -2831,6 +3128,7 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
2831
3128
|
processInstances: safeTranslate(t, 'orgmanagement:tabs.usage.processInstances', 'Process instances'),
|
|
2832
3129
|
decisionInstances: safeTranslate(t, 'orgmanagement:tabs.usage.decisionInstances', 'Decision instances'),
|
|
2833
3130
|
taskUsers: safeTranslate(t, 'orgmanagement:tabs.usage.taskUsers', 'Task users'),
|
|
3131
|
+
tenants: safeTranslate(t, 'orgmanagement:tabs.usage.tenants', 'Tenants'),
|
|
2834
3132
|
},
|
|
2835
3133
|
} })),
|
|
2836
3134
|
initializeTab: () => {
|
|
@@ -3080,12 +3378,14 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
3080
3378
|
finally {
|
|
3081
3379
|
setSettingsLoading(false);
|
|
3082
3380
|
}
|
|
3083
|
-
} }), _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: () => {
|
|
3084
3382
|
setDeleteOrganizationOpen(false);
|
|
3085
3383
|
setDeleteOrganizationError(false);
|
|
3384
|
+
setDeleteOrganizationErrorMessage(undefined);
|
|
3086
3385
|
}, onRequestSubmit: async () => {
|
|
3087
3386
|
setSettingsLoading(true);
|
|
3088
3387
|
setDeleteOrganizationError(false);
|
|
3388
|
+
setDeleteOrganizationErrorMessage(undefined);
|
|
3089
3389
|
try {
|
|
3090
3390
|
await OrgsService.deleteOrganization({
|
|
3091
3391
|
config: apiConfig,
|
|
@@ -3096,6 +3396,12 @@ export const C4ManagementApp = observer(({ orgId, desiredTabId, onTabChange, onN
|
|
|
3096
3396
|
}
|
|
3097
3397
|
catch (error) {
|
|
3098
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));
|
|
3099
3405
|
runtime.telemetry?.captureException?.(error, {
|
|
3100
3406
|
eventName: 'orgSettings:deleteOrg:error',
|
|
3101
3407
|
message: 'Error while deleting organization',
|