UNPKG

@fleetbase/ember-ui

Version:

Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.

31 lines (27 loc) 938 B
import Component from '@glimmer/component'; import { action, get } from '@ember/object'; import getModelName from '@fleetbase/ember-core/utils/get-model-name'; export default class PillComponent extends Component { /* eslint-disable ember/no-get */ get resourceName() { const record = this.args.resource; if (!record) return null; return ( get(record, this.args.namePath ?? 'name') ?? get(record, 'display_name') ?? get(record, 'displayName') ?? get(record, 'tracking') ?? get(record, 'public_id') ?? getModelName(record) ); } @action handleClick() { if (typeof this.args.onClick === 'function') { if (this.args.resource) { this.args.onClick(this.args.resource, ...arguments); } else { this.args.onClick(...arguments); } } } }