Skip to content

Commit

Permalink
Updated guid route component logic, updated if statement logic, updat…
Browse files Browse the repository at this point in the history
…ed OsfLink to use if logic instead of unless.
  • Loading branch information
chth0n1x committed Sep 28, 2023
1 parent 5aba7e7 commit 3910a2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
19 changes: 8 additions & 11 deletions app/resolve-guid/guid-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,25 @@ export default abstract class GuidRoute extends Route {
@service ready!: Ready;
@service store!: Store;

abstract modelName(): keyof ModelRegistry;

@task
@waitFor
async getModel(guid: string) {
const blocker = this.ready.getBlocker();

let model;
try {
model = await this.store.findRecord(this.modelName(), guid, {
const blocker = this.ready.getBlocker();
const model = await this.store.findRecord(this.modelName(), guid, {
include: this.include(),
adapterOptions: this.adapterOptions(),
});
blocker.done();
return model;
} catch (e) {
// To do custom error handling, add an error() action to the route that subclasses GuidRoute.
this.send('error', e);
}

blocker.done();

return model;
}

abstract modelName(): keyof ModelRegistry;

adapterOptions(): {} {
return {};
}
Expand All @@ -52,8 +48,9 @@ export default abstract class GuidRoute extends Route {
}

model(params: { guid: string }) {
const paramsGuid = params.guid;
return {
guid: params.guid,
guid: paramsGuid,
taskInstance: taskFor(this.getModel).perform(params.guid),
task: this.getModel,
};
Expand Down
2 changes: 1 addition & 1 deletion lib/registries/addon/overview/index/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Overview extends Controller {

@computed('registration.{root,isRoot}')
get root() {
if (!this.registration || this.registration.isRoot) {
if (!this.registration || !this.registration.isRoot) {
return undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/registries/addon/overview/index/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#unless this.registration.isRoot}}
{{#if this.registration.isRoot}}
<div data-test-root-link local-class='AboutComponent'>
{{t 'registries.overview.component_of'}}
<OsfLink
Expand All @@ -8,7 +8,7 @@
{{this.root.title}}
</OsfLink>
</div>
{{/unless}}
{{/if}}

{{#if this.registration}}
<Overview::-Components::DiffManager
Expand Down

0 comments on commit 3910a2a

Please sign in to comment.