vault/ui/app/components/clients/running-total.ts
Vault Automation 2b469deeca
UI: Update client count overview table and add filtering (#8663) (#9057)
* rename query params to match keys from api response

* move type guard check to util

* update color scheme

* remove passing selected namespace to export activity data request

* remove namespace and mount filter toolbar

* update response, sort by client count number

* remove default page size for testing

* implement table and filters in overview tab

* remove old query params

* cleanup unused args

* revert page header changes

* update mirage, remove month from utils

* update client count utils

* one more color!

* reset table to page 1;

* workaround to force Hds::Pagination::Numbered to update when currentPage changes

* add empty state test for no attribution

* delete unused methods

* add test for new utils

* add changelog

* rename changelog

---------

Co-authored-by: claire bontempo <cbontempo@hashicorp.com>
2025-09-02 13:43:02 -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 type { ByMonthNewClients, TotalClients } from 'core/utils/client-count-utils';
interface Args {
isSecretsSyncActivated: boolean;
byMonthNewClients: ByMonthNewClients[];
isHistoricalMonth: boolean;
isCurrentMonth: boolean;
runningTotals: TotalClients;
}
export default class RunningTotal extends Component<Args> {
@tracked showStacked = false;
get chartContainerText() {
const { isSecretsSyncActivated } = this.args;
return `The total clients in the specified date range, displayed per month. This includes entity, non-entity${
isSecretsSyncActivated ? ', 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.args.isSecretsSyncActivated ? [{ key: 'secret_syncs', label: 'secret sync clients' }] : []),
{ key: 'acme_clients', label: 'acme clients' },
];
}
return [{ key: 'new_clients', label: 'new clients' }];
}
}