Files
threshold-ui/ui/admin/app/controllers/scopes/scope/targets/target/index.js
T
hashiccandLisbet Alvarez 3a847605ed Reapply ember-can upgrade (#3111)
* chore: 🤖 reapply previous ember-can upgrade from #3093

* chore: 🤖 add missing ember-inflector dependency

* chore: 🤖 move @ember/string to be a dependency in desktop

* chore: 🤖 re-run pnpm install to resolve lockfile dupe key error

* chore: 🤖 remove unused abilities service injections

Co-Authored-By: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com>

---------

Co-authored-by: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com>
2026-02-24 13:48:34 -05:00

69 lines
1.5 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import Controller, { inject as controller } from '@ember/controller';
import { action } from '@ember/object';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
export default class ScopesScopeTargetsTargetIndexController extends Controller {
@controller('scopes/scope/targets/index') targets;
// =services
@service abilities;
@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;
}
/**
* Decides when to show the flyout component
* @returns {boolean}
*/
get showFlyOutComponent() {
return this.showFlyout && 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);
}
}