Skip to content

Commit

Permalink
octane migration - deprecation-item-source (#1906)
Browse files Browse the repository at this point in the history
* octane migration - deprecation-item-source

* Update app/components/deprecation-item-source.js

Co-authored-by: Ricardo Mendes <rokusu@gmail.com>

* Update app/components/deprecation-item-source.js

Co-authored-by: Ricardo Mendes <rokusu@gmail.com>

* Update app/components/deprecation-item-source.js

Co-authored-by: Ricardo Mendes <rokusu@gmail.com>

* fix linting error

* Update app/components/deprecation-item-source.hbs

Co-authored-by: Robert Wagner <rwwagner90@gmail.com>

Co-authored-by: Bing Dai <bdai@linkedin.com>
Co-authored-by: Ricardo Mendes <rokusu@gmail.com>
Co-authored-by: Robert Wagner <rwwagner90@gmail.com>
  • Loading branch information
4 people committed Feb 10, 2022
1 parent 31efd7c commit d6f8610
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 43 deletions.
29 changes: 28 additions & 1 deletion app/components/deprecation-item-source.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
{{yield this}}
<div class="deprecation-source pb-2" data-test-deprecation-source>
<button
class="send-to-console send-to-console--chevron-only mr-3"
title="Trace deprecations in console"
data-test-trace-deprecations-btn
{{on "click" this.handleClick}}
type="button"
>
{{svg-jar "send-with-chevron" width="6px" height="9px"}}
Trace in the Console
</button>
<span class="source">
{{#if this.isClickable}}
<a
class="font-mono"
href="#"
data-test-deprecation-source-link
{{on "click" this.handleRedirect}}
>
{{this.url}}
</a>
{{else}}
<span class="font-mono" data-test-deprecation-source-text>
{{this.url}}
</span>
{{/if}}
</span>
</div>
36 changes: 24 additions & 12 deletions app/components/deprecation-item-source.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
36 changes: 6 additions & 30 deletions app/components/deprecation-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,12 @@

{{#if (and @model.hasSourceMap disclosure.isExpanded)}}
{{#each @model.sources as |single|}}
<DeprecationItemSource @model={{single}} as |source|>
<div class="deprecation-source pb-2" data-test-deprecation-source>
<button
class="send-to-console send-to-console--chevron-only mr-3"
title="Trace deprecations in console"
data-test-trace-deprecations-btn
{{on "click" (fn @traceSource @model source.model)}}
type="button"
>
{{svg-jar "send-with-chevron" width="6px" height="9px"}}
Trace in the Console
</button>
<span class="source">
{{#if source.isClickable}}
<a
class="font-mono"
href="#"
data-test-deprecation-source-link
{{on "click" (fn @openResource source.model.map)}}
>
{{source.url}}
</a>
{{else}}
<span class="font-mono" data-test-deprecation-source-text>
{{source.url}}
</span>
{{/if}}
</span>
</div>
</DeprecationItemSource>
<DeprecationItemSource
@itemModel={{single}}
@modelGroup={{@model}}
@traceSource={{@traceSource}}
@openResource={{@openResource}}
/>
{{/each}}
{{/if}}
</div>
Expand Down

0 comments on commit d6f8610

Please sign in to comment.