Skip to content

Commit

Permalink
fix(ui): Correctly load and store namespace. Fixes #3773 and #3775 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Aug 17, 2020
1 parent a9577ab commit 2263678
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
12 changes: 8 additions & 4 deletions ui/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export class App extends React.Component<{}, {version?: Version; popupProps: Pop
this.popupManager = new PopupManager();
this.notificationsManager = new NotificationsManager();
this.navigationManager = new NavigationManager(history);
Utils.onNamespaceChange = namespace => {
this.setState({namespace});
};
}

public componentDidMount() {
Expand Down Expand Up @@ -170,18 +173,19 @@ export class App extends React.Component<{}, {version?: Version; popupProps: Pop
}

private get archivedWorkflowsUrl() {
return archivedWorkflowsUrl + '/' + this.state.namespace;
return archivedWorkflowsUrl + '/' + this.state.namespace || '';
}

private get cronWorkflowsUrl() {
return cronWorkflowsUrl + '/' + this.state.namespace;
return cronWorkflowsUrl + '/' + this.state.namespace || '';
}

private get workflowTemplatesUrl() {
return workflowTemplatesUrl + '/' + this.state.namespace;
return workflowTemplatesUrl + '/' + this.state.namespace || '';
}

private get workflowsUrl() {
return workflowsUrl + '/' + this.state.namespace;
return workflowsUrl + '/' + this.state.namespace || '';
}

public getChildContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class ArchivedWorkflowList extends BasePage<RouteComponentProps<any>, Sta
}

private saveHistory() {
this.url = uiUrl('archived-workflows/' + this.state.namespace + '?' + this.filterParams.toString());
this.url = uiUrl('archived-workflows/' + (this.state.namespace || '') + '?' + this.filterParams.toString());
Utils.setCurrentNamespace(this.state.namespace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class CronWorkflowList extends BasePage<RouteComponentProps<any>, State>
}

private saveHistory() {
this.url = uiUrl('cron-workflows/' + this.state.namespace);
this.url = uiUrl('cron-workflows/' + this.state.namespace || '');
Utils.setCurrentNamespace(this.state.namespace);
}

Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/shared/services/archived-workflows-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export class ArchivedWorkflowsService {
if (filter.pagination.offset) {
queryParams.push(`listOptions.continue=${filter.pagination.offset}`);
}
queryParams.push(`listOptions.limit=${filter.pagination.limit}`);
if (filter.pagination.limit) {
queryParams.push(`listOptions.limit=${filter.pagination.limit}`);
}
return queryParams;
}

Expand Down
5 changes: 5 additions & 0 deletions ui/src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ export const Utils = {
return wf.status.phase === 'Running';
},

onNamespaceChange(value: string) {
// noop
},

setCurrentNamespace(value: string): void {
localStorage.setItem('current_namespace', value);
this.onNamespaceChange(value);
},

getCurrentNamespace(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ export class WorkflowTemplateList extends BasePage<RouteComponentProps<any>, Sta
}

private saveHistory() {
this.url = uiUrl('workflow-templates/' + this.namespace);
this.url = uiUrl('workflow-templates/' + this.namespace || '');
Utils.setCurrentNamespace(this.namespace);
}

private fetchWorkflowTemplates(namespace: string): void {
services.workflowTemplate
.list(namespace)
.then(templates => this.setState({templates}, this.saveHistory))
.then(templates => this.setState({namespace, templates}, this.saveHistory))
.catch(error => this.setState({error}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
.then(wfList => {
this.setState(
{
namespace,
workflows: wfList.items || [],
pagination: {offset: pagination.offset, limit: pagination.limit, nextOffset: wfList.metadata.continue},
selectedPhases,
Expand Down Expand Up @@ -265,7 +266,7 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {

private saveHistory() {
WorkflowsList.saveOptions(this.options);
this.url = uiUrl('workflows/' + this.state.namespace + '?' + this.filterParams.toString());
this.url = uiUrl('workflows/' + this.state.namespace || '' + '?' + this.filterParams.toString());
Utils.setCurrentNamespace(this.state.namespace);
}

Expand Down

0 comments on commit 2263678

Please sign in to comment.