Skip to content

Commit

Permalink
Merge #73755
Browse files Browse the repository at this point in the history
73755: ui: updating query params for Jobs page r=maryliag a=maryliag

Previously, the filter values for Jobs page were being saved
on cache, but the value on query params were not being updated
and not being used.
On this commit, those values are updated and the query params
take priority from cached values.

Partially addresses #68199

Release note: None

Co-authored-by: Marylia Gutierrez <[email protected]>
  • Loading branch information
craig[bot] and maryliag committed Dec 14, 2021
2 parents 7167b22 + 4c2a56a commit 14367d7
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion pkg/ui/workspaces/db-console/src/views/jobs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ export class JobsTable extends React.Component<JobsTableProps> {

const { history } = this.props;
const searchParams = new URLSearchParams(history.location.search);

// Sort Settings.
const ascending = (searchParams.get("ascending") || undefined) === "true";
const columnTitle = searchParams.get("columnTitle") || undefined;
const sortSetting = this.props.sort;

if (
this.props.setSort &&
columnTitle &&
Expand All @@ -115,6 +116,24 @@ export class JobsTable extends React.Component<JobsTableProps> {
) {
this.props.setSort({ columnTitle, ascending });
}

// Filter Status.
const status = searchParams.get("status") || undefined;
if (this.props.setStatus && status && status != this.props.status) {
this.props.setStatus(status);
}

// Filter Show.
const show = searchParams.get("show") || undefined;
if (this.props.setShow && show && show != this.props.show) {
this.props.setShow(show);
}

// Filter Type.
const type = parseInt(searchParams.get("type"), 10) || undefined;
if (this.props.setType && type && type != this.props.type) {
this.props.setType(type);
}
}

refresh(props = this.props) {
Expand Down Expand Up @@ -145,17 +164,38 @@ export class JobsTable extends React.Component<JobsTableProps> {
const filter = selected.value === "" ? "all" : selected.value;
trackFilter("Status", filter);
this.props.setStatus(selected.value);

util.syncHistory(
{
status: selected.value,
},
this.props.history,
);
};

onTypeSelected = (selected: DropdownOption) => {
const type = parseInt(selected.value, 10);
const typeLabel = typeOptions[type].label;
trackFilter("Type", typeLabel);
this.props.setType(type);

util.syncHistory(
{
type: type.toString(),
},
this.props.history,
);
};

onShowSelected = (selected: DropdownOption) => {
this.props.setShow(selected.value);

util.syncHistory(
{
show: selected.value,
},
this.props.history,
);
};

changeSortSetting = (ss: SortSetting): void => {
Expand Down

0 comments on commit 14367d7

Please sign in to comment.