mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-11 22:01:23 +01:00
* delete activity component, convert date-formatters to ts * add "month" filter to overview tab * add test coverage for date range dropdown * add month filtering to client-list * remove old comment * wire up clients to route filters for client-list * adds changelog * only link to client-list for enterprise versions * add refresh page link * render all tabs, add custom empty state for secret sycn clients * cleanup unused service imports * revert billing periods as first of the month * first round of test updates * update client count utils test * fix comment typo * organize tests Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
100 lines
3.5 KiB
TypeScript
100 lines
3.5 KiB
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { service } from '@ember/service';
|
|
import { action } from '@ember/object';
|
|
import { parseAPITimestamp } from 'core/utils/date-formatters';
|
|
import { filterVersionHistory } from 'core/utils/client-count-utils';
|
|
|
|
import type AdapterError from '@ember-data/adapter/error';
|
|
import type VersionService from 'vault/services/version';
|
|
import type ClientsActivityModel from 'vault/models/clients/activity';
|
|
import type ClientsConfigModel from 'vault/models/clients/config';
|
|
import type ClientsVersionHistoryModel from 'vault/models/clients/version-history';
|
|
|
|
interface Args {
|
|
activity: ClientsActivityModel;
|
|
activityError?: AdapterError;
|
|
config: ClientsConfigModel;
|
|
endTimestamp: string; // ISO format
|
|
onFilterChange: CallableFunction;
|
|
startTimestamp: string; // ISO format
|
|
versionHistory: ClientsVersionHistoryModel[];
|
|
}
|
|
|
|
export default class ClientsCountsPageComponent extends Component<Args> {
|
|
@service declare readonly version: VersionService;
|
|
|
|
get formattedStartDate() {
|
|
return this.args.startTimestamp ? parseAPITimestamp(this.args.startTimestamp, 'MMMM yyyy') : null;
|
|
}
|
|
|
|
get formattedEndDate() {
|
|
return this.args.endTimestamp ? parseAPITimestamp(this.args.endTimestamp, 'MMMM yyyy') : null;
|
|
}
|
|
|
|
get formattedBillingStartDate() {
|
|
return this.args.config.billingStartTimestamp.toISOString();
|
|
}
|
|
|
|
// passed into page-header for the export modal alert
|
|
get upgradesDuringActivity() {
|
|
const { versionHistory, activity } = this.args;
|
|
return filterVersionHistory(versionHistory, activity?.startTime, activity?.endTime);
|
|
}
|
|
|
|
get upgradeExplanations() {
|
|
if (this.upgradesDuringActivity.length) {
|
|
return this.upgradesDuringActivity.map((upgrade: ClientsVersionHistoryModel) => {
|
|
let explanation;
|
|
const date = parseAPITimestamp(upgrade.timestampInstalled, 'MMM d, yyyy');
|
|
const version = upgrade.version || '';
|
|
switch (true) {
|
|
case version.includes('1.9'):
|
|
explanation =
|
|
'- We introduced changes to non-entity token and local auth mount logic for client counting in 1.9.';
|
|
break;
|
|
case version.includes('1.10'):
|
|
explanation = '- We added monthly breakdowns and mount level attribution starting in 1.10.';
|
|
break;
|
|
case version.includes('1.17'):
|
|
explanation = '- We separated ACME clients from non-entity clients starting in 1.17.';
|
|
break;
|
|
default:
|
|
explanation = '';
|
|
break;
|
|
}
|
|
return `${version} (upgraded on ${date}) ${explanation}`;
|
|
});
|
|
}
|
|
return null;
|
|
}
|
|
|
|
get versionText() {
|
|
return this.version.isEnterprise
|
|
? {
|
|
title: 'No billing start date found',
|
|
message:
|
|
'In order to get the most from this data, please enter your billing period start month. This will ensure that the resulting data is accurate.',
|
|
}
|
|
: {
|
|
title: 'No start date found',
|
|
message:
|
|
'In order to get the most from this data, please enter a start month above. Vault will calculate new clients starting from that month.',
|
|
};
|
|
}
|
|
|
|
// the dashboard should show sync tab if the flag is on or there's data
|
|
get hasSecretsSyncClients(): boolean {
|
|
return this.args.activity?.total?.secret_syncs > 0;
|
|
}
|
|
|
|
@action
|
|
onDateChange(params: { start_time: string; end_time: string }) {
|
|
this.args.onFilterChange(params);
|
|
}
|
|
}
|