vault/ui/lib/core/addon/components/info-table-item-array.js
Vault Automation 48efc519bc
[UI] Ember Data Migration - Core Addon (#14891) (#14953)
* removes store service from confirm-leave decorator

* updates secret list header tab component to use capabilities service for database type

* removes store service from edit-form component

* removes ember data fetch support from InfoTableItemArray component

* removes store from shamir components

* removes store from replication components in core addon

* adds missing service injection to shamir flow component

* fixes reduced disclosure test

* fixes issues with seal/unseal workflow

* reverts assertion change in info-table-item-array test

* fixes database test

* updates shamir flow test

* removes commented out code

Co-authored-by: Jordan Reimer <zofskeez@gmail.com>
2026-05-21 16:52:55 -06:00

60 lines
2.8 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { assert } from '@ember/debug';
/**
* @module InfoTableItemArray
* The `InfoTableItemArray` component handles arrays in the info-table-row component.
* If an array has more than 10 items, then only 5 are displayed and a count of total items is displayed next to the five.
* If a isLink is true than a link can be set for the use to click on the specific array item
* Wildcard items are rendered as the raw string passed through the display array.
*
* @example
* <InfoTableItemArray @label="Roles" @displayArray={{array "test-1" "test-2" "test-3"}} />
*
* @param {string} label - used to render lowercased display text for "View all [label]."
* @param {array} displayArray - The array of data to be displayed. (In InfoTableRow this comes from the `@value` arg.) If the array length > 10, and `@doNotTruncate` is false only 5 will show with a count of the number hidden.
* @param {boolean} [isLink] - Indicates if the item should contain a link-to component. Only setup for arrays, but this could be changed if needed.
* @param {string | array} [rootRoute=vault.cluster.secrets.backend.list-root] - Tells what route the link should go to when selecting "view all". If the route requires more than one dynamic param, insert an array.
* @param {string | array} [itemRoute=vault.cluster.secrets.backend.show] - Tells what route the link should go to when selecting the individual item. If the route requires more than one dynamic param, insert an array.
* @param {array} [arrayOptions] - Optional array of preloaded item names used to count wildcard matches.
* @param {string} [wildcardLabel] - Singular label used when rendering a wildcard match count badge.
* @param {string} [backend] - To specify which backend to point the link to.
* @param {boolean} [doNotTruncate=false] - Determines whether to show the View all "roles" link. Otherwise uses the ReadMore component's "See More" toggle
*/
export default class InfoTableItemArray extends Component {
constructor() {
super(...arguments);
assert('@label is required for InfoTableItemArray components', this.args.label);
}
get rootRoute() {
return this.args.rootRoute || 'vault.cluster.secrets.backend.list-root';
}
get itemRoute() {
return this.args.itemRoute || 'vault.cluster.secrets.backend.show';
}
get doNotTruncate() {
return this.args.doNotTruncate || false;
}
get displayArrayTruncated() {
const { displayArray } = this.args;
if (!displayArray) return null;
if (displayArray.length >= 10 && !this.args.doNotTruncate) {
// if array greater than 10 in length only display the first 5
return displayArray.slice(0, 5);
}
return displayArray;
}
get wildcardLabel() {
return this.args.wildcardLabel || '';
}
}