Skip to content

Commit

Permalink
refactor: remove extraTabs property
Browse files Browse the repository at this point in the history
  • Loading branch information
infacc committed Jul 7, 2023
1 parent a063cca commit 3e9b1e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/app/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
</a>
<a class="navigation-link" mat-button
[routerLink]="['/experiments', (experimentId|async), 'extra', tab.resourceKey?.uiTemplateTabId]" [queryParams]="{template: templateId}"
routerLinkActive="active" *ngFor="let tab of extraTabs">
routerLinkActive="active" *ngFor="let tab of experimentExtraTabs">
{{tab.name}}
</a>
</ng-container>
<ng-container *ngIf="(currentExperiment|async) == null">
<a class="navigation-link" mat-button
[routerLink]="['extra', tab.resourceKey?.uiTemplateTabId]" [queryParams]="{template: templateId}"
routerLinkActive="active" *ngFor="let tab of extraTabs">
routerLinkActive="active" *ngFor="let tab of generalExtraTabs">
{{tab.name}}
</a>
</ng-container>
Expand Down
18 changes: 0 additions & 18 deletions src/app/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export class NavbarComponent implements OnInit, OnDestroy {
experimentExtraTabsGroupLink: ApiLink | null = null;
experimentExtraTabs: ApiLink[] = [];

extraTabs: ApiLink[] = [];

templateId: string | null = null;
template: TemplateApiObject | null = null;

Expand Down Expand Up @@ -94,7 +92,6 @@ export class NavbarComponent implements OnInit, OnDestroy {

private async onTemplateChanges(template: TemplateApiObject | null) {
if (template == null) {
this.extraTabs = [];
return;
}
const experimentNavGroup = template.groups.find(group => group.resourceKey?.["?group"] === "experiment-navigation") ?? null;
Expand All @@ -118,7 +115,6 @@ export class NavbarComponent implements OnInit, OnDestroy {
if (groupLink == null) {
this.experimentExtraTabs = [];
this.experimentExtraTabsGroupLink = null;
this.updateExtraTabs();
return;
}

Expand All @@ -129,15 +125,13 @@ export class NavbarComponent implements OnInit, OnDestroy {
groupResponse?.data?.items?.forEach(tab => extraTabs.push(tab));

this.experimentExtraTabs = extraTabs;
this.updateExtraTabs();
}

private async updateGeneralExtraTabGroup() {
const groupLink = this.generalExtraTabsGroupLink;
if (groupLink == null) {
this.generalExtraTabs = [];
this.generalExtraTabsGroupLink = null;
this.updateExtraTabs();
return;
}

Expand All @@ -148,17 +142,5 @@ export class NavbarComponent implements OnInit, OnDestroy {
groupResponse?.data?.items?.forEach(tab => extraTabs.push(tab));

this.generalExtraTabs = extraTabs;
this.updateExtraTabs();
}

private updateExtraTabs() {
this.experimentId.subscribe(experimentId => {
if (experimentId != null) {
// only show experiment navigation tabs if an experiment is active
this.extraTabs = this.experimentExtraTabs;
} else {
this.extraTabs = this.generalExtraTabs;
}
});
}
}

0 comments on commit 3e9b1e5

Please sign in to comment.