Skip to content

Commit 9b49362

Browse files
committed
frontend: Fix 500 error after detail page refresh (#1967)
Fix 500 error when refreshing KWA's detail page by also considering the namespace variable as a query param. Signed-off-by: Elena Zioga <[email protected]>
1 parent 54b020b commit 9b49362

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

pkg/new-ui/v1beta1/frontend/src/app/app-routing.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { TrialModalComponent } from './pages/experiment-details/trials-table/tri
77

88
const routes: Routes = [
99
{ path: '', component: ExperimentsComponent },
10-
{ path: 'experiment/:experimentName', component: ExperimentDetailsComponent },
10+
{
11+
path: 'experiment/:namespace/:experimentName',
12+
component: ExperimentDetailsComponent,
13+
},
1114
{ path: 'new', component: ExperimentCreationComponent },
1215
{
1316
path: 'experiment/:experimentName/trial/:trialName',

pkg/new-ui/v1beta1/frontend/src/app/pages/experiment-details/experiment-details.component.spec.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,32 @@ import { MatSnackBarModule } from '@angular/material/snack-bar';
2626

2727
let KWABackendServiceStub: Partial<KWABackendService>;
2828
let NamespaceServiceStub: Partial<NamespaceService>;
29+
let ActivatedRouteStub: Partial<ActivatedRoute>;
2930

3031
KWABackendServiceStub = {
31-
getExperimentTrialsInfo: () => of([]),
32+
getExperimentTrialsInfo: () =>
33+
of(
34+
'Status,trialName,Validation-accuracy,Train-accuracy,lr,num-layers,optimizer\nSucceeded,tpe-05daf02d,0.977807,0.993104,0.023222418198803642,3,sgd',
35+
),
3236
getExperiment: () => of(),
3337
deleteExperiment: () => of(),
3438
};
3539

3640
NamespaceServiceStub = {
37-
getSelectedNamespace: () => of(),
41+
updateSelectedNamespace: () => {},
42+
};
43+
44+
ActivatedRouteStub = {
45+
params: of({ namespace: 'kubeflow-user', experimentName: '' }),
46+
queryParams: of({}),
3847
};
3948

4049
describe('ExperimentDetailsComponent', () => {
4150
let component: ExperimentDetailsComponent;
4251
let fixture: ComponentFixture<ExperimentDetailsComponent>;
43-
let activatedRouteSpy;
4452

4553
beforeEach(
4654
waitForAsync(() => {
47-
activatedRouteSpy = {
48-
snapshot: {
49-
params: {
50-
experimentName: '',
51-
},
52-
queryParams: {
53-
tab: '',
54-
},
55-
},
56-
};
5755
TestBed.configureTestingModule({
5856
imports: [
5957
CommonModule,
@@ -75,7 +73,7 @@ describe('ExperimentDetailsComponent', () => {
7573
],
7674
declarations: [ExperimentDetailsComponent],
7775
providers: [
78-
{ provide: ActivatedRoute, useValue: activatedRouteSpy },
76+
{ provide: ActivatedRoute, useValue: ActivatedRouteStub },
7977
{ provide: Router, useValue: {} },
8078
{ provide: KWABackendService, useValue: KWABackendServiceStub },
8179
{ provide: ConfirmDialogService, useValue: {} },

pkg/new-ui/v1beta1/frontend/src/app/pages/experiment-details/experiment-details.component.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class ExperimentDetailsComponent implements OnInit, OnDestroy {
4949
private router: Router,
5050
private backendService: KWABackendService,
5151
private confirmDialog: ConfirmDialogService,
52-
private backend: KWABackendService,
5352
private namespaceService: NamespaceService,
5453
) {}
5554

@@ -68,20 +67,18 @@ export class ExperimentDetailsComponent implements OnInit, OnDestroy {
6867
private subs = new Subscription();
6968

7069
ngOnInit() {
71-
this.name = this.activatedRoute.snapshot.params.experimentName;
70+
this.activatedRoute.params.subscribe(params => {
71+
this.namespaceService.updateSelectedNamespace(params.namespace);
7272

73-
if (this.activatedRoute.snapshot.queryParams['tab']) {
74-
this.selectedTab = this.tabs.get(
75-
this.activatedRoute.snapshot.queryParams['tab'],
76-
);
77-
}
73+
this.name = params.experimentName;
74+
this.namespace = params.namespace;
7875

79-
this.subs.add(
80-
this.namespaceService.getSelectedNamespace().subscribe(namespace => {
81-
this.namespace = namespace;
82-
this.updateExperimentInfo();
83-
}),
84-
);
76+
this.updateExperimentInfo();
77+
});
78+
79+
this.activatedRoute.queryParams.subscribe(queryParams => {
80+
this.selectedTab = this.tabs.get(queryParams.tab);
81+
});
8582
}
8683

8784
tabChanged(event: MatTabChangeEvent) {
@@ -146,7 +143,7 @@ export class ExperimentDetailsComponent implements OnInit, OnDestroy {
146143
}
147144

148145
// Close the open dialog only if the DELETE request succeeded
149-
this.backend.deleteExperiment(name, namespace).subscribe({
146+
this.backendService.deleteExperiment(name, namespace).subscribe({
150147
next: _ => {
151148
ref.close(DIALOG_RESP.ACCEPT);
152149
},

pkg/new-ui/v1beta1/frontend/src/app/pages/experiment-details/trials-table/trial-modal/trial-modal.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ export class TrialModalComponent implements OnInit {
221221
}
222222

223223
returnToExperimentDetails() {
224-
this.router.navigate([`/experiment/${this.experimentName}`], {
225-
queryParams: { tab: 'trials' },
226-
});
224+
this.router.navigate(
225+
[`/experiment/${this.namespace}/${this.experimentName}`],
226+
{
227+
queryParams: { tab: 'trials' },
228+
},
229+
);
227230
}
228231
}

pkg/new-ui/v1beta1/frontend/src/app/pages/experiments/experiments.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class ExperimentsComponent implements OnInit, OnDestroy {
8686
const exp = a.data as Experiment;
8787
switch (a.action) {
8888
case 'name:link':
89-
this.router.navigate([`/experiment/${exp.name}`]);
89+
this.router.navigate([`/experiment/${exp.namespace}/${exp.name}`]);
9090
break;
9191
case 'delete':
9292
this.onDeleteExperiment(exp.name);

0 commit comments

Comments
 (0)