From d6f8610455fefeb2285ab11bbc50b1c66995948c Mon Sep 17 00:00:00 2001 From: Bing Dai Date: Thu, 10 Feb 2022 12:43:54 -0800 Subject: [PATCH] octane migration - deprecation-item-source (#1906) * octane migration - deprecation-item-source * Update app/components/deprecation-item-source.js Co-authored-by: Ricardo Mendes * Update app/components/deprecation-item-source.js Co-authored-by: Ricardo Mendes * Update app/components/deprecation-item-source.js Co-authored-by: Ricardo Mendes * fix linting error * Update app/components/deprecation-item-source.hbs Co-authored-by: Robert Wagner Co-authored-by: Bing Dai Co-authored-by: Ricardo Mendes Co-authored-by: Robert Wagner --- app/components/deprecation-item-source.hbs | 29 ++++++++++++++++- app/components/deprecation-item-source.js | 36 ++++++++++++++-------- app/components/deprecation-item.hbs | 36 ++++------------------ 3 files changed, 58 insertions(+), 43 deletions(-) diff --git a/app/components/deprecation-item-source.hbs b/app/components/deprecation-item-source.hbs index f4a0b59217..ee93624367 100644 --- a/app/components/deprecation-item-source.hbs +++ b/app/components/deprecation-item-source.hbs @@ -1 +1,28 @@ -{{yield this}} +
+ + + {{#if this.isClickable}} + + {{this.url}} + + {{else}} + + {{this.url}} + + {{/if}} + +
\ No newline at end of file diff --git a/app/components/deprecation-item-source.js b/app/components/deprecation-item-source.js index 66aa0ec6bb..91f7c28562 100644 --- a/app/components/deprecation-item-source.js +++ b/app/components/deprecation-item-source.js @@ -1,26 +1,38 @@ -import { tagName } from '@ember-decorators/component'; -import { computed, get } from '@ember/object'; +import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import { and, readOnly, bool } from '@ember/object/computed'; -import Component from '@ember/component'; -@tagName('') +import Component from '@glimmer/component'; export default class DeprecationItemSource extends Component { @service port; - @bool('model.map.source') known; - - @computed('model.map.{line,source}', 'known') get url() { - let source = get(this, 'model.map.source'); + let source = this.args.itemModel?.map.source; if (this.known) { - return `${source}:${get(this, 'model.map.line')}`; + return `${source}:${this.args.itemModel?.map.line}`; } else { return 'Unkown source'; } } - @readOnly('port.adapter') adapter; + get adapter() { + return this.port.adapter; + } - @and('known', 'adapter.canOpenResource') isClickable; + get isClickable() { + return this.known && this.adapter.canOpenResource; + } + + get known() { + return this.args.itemModel?.map.source; + } + + @action + handleClick() { + this.args.traceSource?.(this.args.modelGroup, this.args.itemModel); + } + + @action + handleRedirect() { + this.args.openResource?.(this.args.itemModel?.map); + } } diff --git a/app/components/deprecation-item.hbs b/app/components/deprecation-item.hbs index 39545588af..c32cc3a795 100644 --- a/app/components/deprecation-item.hbs +++ b/app/components/deprecation-item.hbs @@ -50,36 +50,12 @@ {{#if (and @model.hasSourceMap disclosure.isExpanded)}} {{#each @model.sources as |single|}} - -
- - - {{#if source.isClickable}} - - {{source.url}} - - {{else}} - - {{source.url}} - - {{/if}} - -
-
+ {{/each}} {{/if}}