Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octane migration - deprecation-item-source #1906

Merged
merged 6 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
onclick={{this.handleClick}}
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
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>
37 changes: 24 additions & 13 deletions app/components/deprecation-item-source.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { tagName } from '@ember-decorators/component';
import { computed, get } from '@ember/object';
import { get, 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';
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
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');
const source = get(this.args, 'itemModel.map.source');
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
if (this.known) {
return `${source}:${get(this, 'model.map.line')}`;
return `${source}:${get(this.args, 'itemModel.map.line')}`;
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
} else {
return 'Unkown source';
}
}

@readOnly('port.adapter') adapter;
get adapter() {
return this.port.adapter;
}

get isClickable() {
return this.known && this.adapter.canOpenResource;
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
}

get known() {
return this.args.itemModel.map.source;
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
}

@and('known', 'adapter.canOpenResource') isClickable;
@action
handleClick() {
this.args.traceSource?.(this.args.modelGroup, this.args.itemModel);
}

@action
handleRedirect() {
this.args.openResource?.(this.args.itemModel.map);
michaelbdai marked this conversation as resolved.
Show resolved Hide resolved
}
}
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