Skip to content

Commit

Permalink
fix(9656): stores all states except workflows in browser local storag…
Browse files Browse the repository at this point in the history
…e for archived workflows
  • Loading branch information
athityakumar authored and Athitya Kumar committed Oct 17, 2022
1 parent c007afe commit 10a97d8
Showing 1 changed file with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,54 @@ export class ArchivedWorkflowList extends BasePage<RouteComponentProps<any>, Sta
return params;
}

private filterStateObject(state: State, whitelistedStates: string[], blacklistedStates: string[]) {
let filteredState: State = {} as State;

if (whitelistedStates.includes("pagination") || !blacklistedStates.includes("pagination")) {
filteredState.pagination = state.pagination;
}

if (whitelistedStates.includes("namespace") || !blacklistedStates.includes("namespace")) {
filteredState.namespace = state.namespace;
}

if (whitelistedStates.includes("name") || !blacklistedStates.includes("name")) {
filteredState.name = state.name;
}

if (whitelistedStates.includes("namePrefix") || !blacklistedStates.includes("namePrefix")) {
filteredState.namePrefix = state.namePrefix;
}

if (whitelistedStates.includes("selectedPhases") || !blacklistedStates.includes("selectedPhases")) {
filteredState.selectedPhases = state.selectedPhases;
}

if (whitelistedStates.includes("selectedLabels") || !blacklistedStates.includes("selectedLabels")) {
filteredState.selectedLabels = state.selectedLabels;
}

if (whitelistedStates.includes("minStartedAt") || !blacklistedStates.includes("minStartedAt")) {
filteredState.minStartedAt = state.minStartedAt;
}

if (whitelistedStates.includes("maxStartedAt") || !blacklistedStates.includes("maxStartedAt")) {
filteredState.maxStartedAt = state.maxStartedAt;
}

if (whitelistedStates.includes("error") || !blacklistedStates.includes("error")) {
filteredState.error = state.error;
}

if (whitelistedStates.includes("deep") || !blacklistedStates.includes("deep")) {
filteredState.deep = state.deep;
}

return filteredState;
}

private saveHistory() {
this.storage.setItem('options', this.state, {} as State);
this.storage.setItem('options', this.filterStateObject(this.state, [], ["workflows"]), {} as State);
const newNamespace = Utils.managedNamespace ? '' : this.state.namespace;
this.url = uiUrl('archived-workflows' + (newNamespace ? '/' + newNamespace : '') + '?' + this.filterParams.toString());
Utils.currentNamespace = this.state.namespace;
Expand Down

0 comments on commit 10a97d8

Please sign in to comment.