vault/ui/app/components/clients/running-total.ts
Vault Automation ea46b31d25
UI: Fix chart legend order (#8827) (#8856)
* fix chart legend order and make sync clients last

* reimplement using idx in chart legend

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
Co-authored-by: claire bontempo <cbontempo@hashicorp.com>
2025-09-02 16:43:21 -07:00

49 lines
1.6 KiB
TypeScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { service } from '@ember/service';
import type { ByMonthNewClients, TotalClients } from 'core/utils/client-count-utils';
import type FlagsService from 'vault/services/flags';
interface Args {
byMonthNewClients: ByMonthNewClients[];
runningTotals: TotalClients;
}
export default class RunningTotal extends Component<Args> {
@service declare readonly flags: FlagsService;
@tracked showStacked = false;
get chartContainerText() {
return `The total clients in the specified date range, displayed per month. This includes entity, non-entity${
this.flags.secretsSyncIsActivated ? ', ACME and secrets sync clients' : ' and ACME clients'
}. The total client count number is an important consideration for Vault billing.`;
}
get runningTotalData() {
return this.args.byMonthNewClients.map((monthly) => ({
...monthly,
new_clients: monthly.clients,
}));
}
get chartLegend() {
if (this.showStacked) {
return [
{ key: 'entity_clients', label: 'Entity clients' },
{ key: 'non_entity_clients', label: 'Non-entity clients' },
{ key: 'acme_clients', label: 'ACME clients' },
// MUST BE LAST because conditionally renders and legend color mapping for stacked bars will be off otherwise
...(this.flags.secretsSyncIsActivated ? [{ key: 'secret_syncs', label: 'Secret sync clients' }] : []),
];
}
return [{ key: 'new_clients', label: 'New clients' }];
}
}