vault/ui/app/components/clients/page/client-list.ts
claire bontempo 7d4854d549
UI: Build dropdown filter toolbar (#31475)
* build filter toolbar component

* delete unused controllers

* rename enum and move to client count utils

* wire up filters to route query params

* update test coverage

* add support for appliedFilters from parent

* update type of ns param

* move lists to client-list page component
2025-08-12 17:41:15 +00:00

41 lines
1.1 KiB
TypeScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import ActivityComponent from '../activity';
import { action } from '@ember/object';
import { cached } from '@glimmer/tracking';
import type { ClientFilterTypes, MountClients } from 'core/utils/client-count-utils';
export default class ClientsClientListPageComponent extends ActivityComponent {
@cached
get namespaceLabels() {
// TODO namespace list will be updated to come from the export data, not by_namespace from sys/internal/counters/activity
return this.args.activity.byNamespace.map((n) => n.label);
}
@cached
get mounts() {
// TODO same comment here
return this.args.activity.byNamespace.map((n) => n.mounts).flat();
}
@cached
get mountPaths() {
return [...new Set(this.mounts.map((m: MountClients) => m.label))];
}
@cached
get mountTypes() {
return [...new Set(this.mounts.map((m: MountClients) => m.mount_type))];
}
@action
handleFilter(filters: Record<ClientFilterTypes, string>) {
const { nsLabel, mountPath, mountType } = filters;
this.args.onFilterChange({ nsLabel, mountPath, mountType });
}
}