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

feat(ui): cache namespace selection. Closes #2439 #2441

Merged
merged 3 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ArchivedWorkflowList extends BasePage<RouteComponentProps<any>, Sta
nextOffset: 0,
initialized: false,
managedNamespace: false,
namespace: this.props.match.params.namespace || '',
namespace: this.props.match.params.namespace || Utils.getCurrentNamespace() || '',
selectedPhases: this.queryParams('phase'),
selectedLabels: this.queryParams('label')
};
Expand Down Expand Up @@ -166,6 +166,7 @@ export class ArchivedWorkflowList extends BasePage<RouteComponentProps<any>, Sta
nextOffset: this.parseOffset(list.metadata.continue || ''),
loading: false
});
Utils.setCurrentNamespace(newNamespace);
})
.catch(error => this.setState({error, loading: false}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ZeroState} from '../../../shared/components/zero-state';
import {Consumer} from '../../../shared/context';
import {exampleCronWorkflow} from '../../../shared/examples';
import {services} from '../../../shared/services';
import {Utils} from '../../../shared/utils';

require('./cron-workflow-list.scss');

Expand All @@ -31,6 +32,7 @@ export class CronWorkflowList extends BasePage<RouteComponentProps<any>, State>
this.setState({namespace});
history.pushState(null, '', uiUrl('cron-workflows/' + namespace));
this.fetchCronWorkflows();
Utils.setCurrentNamespace(namespace);
}

private get sidePanel() {
Expand All @@ -42,7 +44,7 @@ export class CronWorkflowList extends BasePage<RouteComponentProps<any>, State>
}
constructor(props: any) {
super(props);
this.state = {loading: true, namespace: this.props.match.params.namespace || ''};
this.state = {loading: true, namespace: this.props.match.params.namespace || Utils.getCurrentNamespace() || ''};
}

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

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

getCurrentNamespace(): string {
return localStorage.getItem('current_namespace');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {ZeroState} from '../../../shared/components/zero-state';
import {Consumer} from '../../../shared/context';
import {exampleWorkflowTemplate} from '../../../shared/examples';
import {services} from '../../../shared/services';
import {Utils} from '../../../shared/utils';

require('./workflow-template-list.scss');

Expand All @@ -31,6 +32,7 @@ export class WorkflowTemplateList extends BasePage<RouteComponentProps<any>, Sta
this.setState({namespace});
history.pushState(null, '', uiUrl('workflow-templates/' + namespace));
this.fetchWorkflowTemplates();
Utils.setCurrentNamespace(namespace);
}

private get sidePanel() {
Expand All @@ -43,7 +45,7 @@ export class WorkflowTemplateList extends BasePage<RouteComponentProps<any>, Sta

constructor(props: RouteComponentProps<any>, context: any) {
super(props, context);
this.state = {loading: true, namespace: this.props.match.params.namespace || ''};
this.state = {loading: true, namespace: this.props.match.params.namespace || Utils.getCurrentNamespace() || ''};
}

public componentDidMount(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
loading: true,
initialized: false,
managedNamespace: false,
namespace: this.props.match.params.namespace || '',
namespace: this.props.match.params.namespace || Utils.getCurrentNamespace() || '',
selectedPhases: this.queryParams('phase'),
selectedLabels: this.queryParams('label')
};
Expand Down Expand Up @@ -143,7 +143,10 @@ export class WorkflowsList extends BasePage<RouteComponentProps<any>, State> {
workflowList
.then(list => list.items)
.then(list => list || [])
.then(workflows => this.setState({workflows, namespace: newNamespace, selectedPhases, selectedLabels}))
.then(workflows => {
this.setState({workflows, namespace: newNamespace, selectedPhases, selectedLabels});
Utils.setCurrentNamespace(newNamespace);
})
.then(() => {
this.subscription = services.workflows
.watch({namespace: newNamespace, phases: selectedPhases, labels: selectedLabels})
Expand Down