Target aliases list view (#2225)

target aliases list view
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-04-11 14:18:38 -07:00
1 parent 9bd45164bf
commit f74f4d4a20
10 files changed
+431 -218

No files matched your search

@@ -0,0 +1,60 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Controller, { inject as controller } from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
export default class ScopesScopeTargetsTargetIndexController extends Controller {
@controller('scopes/scope/targets/target/index') targets;
// =services
@service can;
@service router;
// =attributes
@tracked showFlyout = false;
// =actions
/**
* Handles flyout visibility
*/
@action
toggleFlyout() {
this.showFlyout = !this.showFlyout;
}
/**
* Returns true when there are more than 3 aliases associated with the target
* @returns {boolean}
*/
get showFlyoutBtn() {
return this.model.aliases.length > 3;
}
/**
* Returns only the first three items in the aliases array if there are more than 3
* @returns {array}
*/
get aliases() {
if (this.model.aliases.length > 3) {
const arrWithThreeItems = this.model.aliases.slice(0, 3);
return arrWithThreeItems;
} else {
return this.model.aliases;
}
}
/**
* Returns remaining items in the aliases array if there are more than 3
* @returns {array}
*/
get remainingAliases() {
return this.model.aliases.slice(3);
}
}