vault/ui/app/components/clients/running-total.ts
Vault Automation db994695e0
Backport UI: Reorganize client components into ce/main (#8826)
* UI: Reorganize client components (#8742)

* remove complex logic from running totals component

* move byMonthNewClients getter to overview

* organization: remove unused @versionHistory, update tests

* rename namespaceLabels getter

* refactor filter-toolbar to manage drodown Sets

* add search bar to filter toolbar

* make export request

* finish adding search logic to dropdown

* rename route method

* move typescript declarations because all of the client ones are in client-count-utils

* add error template for failed export request

* update tests

* stub activity export adapter method instead of trying to mock readable stream

* lint

---------

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

48 lines
1.5 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' },
...(this.flags.secretsSyncIsActivated ? [{ key: 'secret_syncs', label: 'secret sync clients' }] : []),
{ key: 'acme_clients', label: 'acme clients' },
];
}
return [{ key: 'new_clients', label: 'new clients' }];
}
}