-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: save filters on cache for Transactions page
Previously, a sort selection was not maintained when the page change (e.g. changing tabs/pages). This commits saves the selected value to be used. Partially adresses #71851 Release note: None
- Loading branch information
Showing
12 changed files
with
432 additions
and
116 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import { Filters, getFiltersFromQueryString } from "./filter"; | ||
|
||
describe("Test filter functions", (): void => { | ||
describe("Test get filters from query string", (): void => { | ||
it("no values on query string", (): void => { | ||
const expectedFilters: Filters = { | ||
app: "", | ||
timeNumber: "0", | ||
timeUnit: "seconds", | ||
fullScan: false, | ||
sqlType: "", | ||
database: "", | ||
regions: "", | ||
nodes: "", | ||
}; | ||
const resultFilters = getFiltersFromQueryString(""); | ||
expect(resultFilters).toEqual(expectedFilters); | ||
}); | ||
}); | ||
|
||
it("different values from default values on query string", (): void => { | ||
const expectedFilters: Filters = { | ||
app: "$ internal", | ||
timeNumber: "1", | ||
timeUnit: "milliseconds", | ||
fullScan: true, | ||
sqlType: "DML", | ||
database: "movr", | ||
regions: "us-central", | ||
nodes: "n1,n2", | ||
}; | ||
const resultFilters = getFiltersFromQueryString( | ||
"app=%24+internal&timeNumber=1&timeUnit=milliseconds&fullScan=true&sqlType=DML&database=movr®ions=us-central&nodes=n1,n2", | ||
); | ||
expect(resultFilters).toEqual(expectedFilters); | ||
}); | ||
|
||
it("testing boolean with full scan = true", (): void => { | ||
const expectedFilters: Filters = { | ||
app: "", | ||
timeNumber: "0", | ||
timeUnit: "seconds", | ||
fullScan: true, | ||
sqlType: "", | ||
database: "", | ||
regions: "", | ||
nodes: "", | ||
}; | ||
const resultFilters = getFiltersFromQueryString("fullScan=true"); | ||
expect(resultFilters).toEqual(expectedFilters); | ||
}); | ||
|
||
it("testing boolean with full scan = false", (): void => { | ||
const expectedFilters: Filters = { | ||
app: "", | ||
timeNumber: "0", | ||
timeUnit: "seconds", | ||
fullScan: false, | ||
sqlType: "", | ||
database: "", | ||
regions: "", | ||
nodes: "", | ||
}; | ||
const resultFilters = getFiltersFromQueryString("fullScan=false"); | ||
expect(resultFilters).toEqual(expectedFilters); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.