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

ui: save filters on cache for Transactions page #73003

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

maryliag
Copy link
Contributor

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@maryliag maryliag marked this pull request as draft November 19, 2021 22:28
@maryliag maryliag force-pushed the cache-filter-txn branch 3 times, most recently from 0194c10 to 945a9ee Compare November 22, 2021 20:54
@maryliag maryliag requested a review from a team November 22, 2021 20:57
@maryliag maryliag marked this pull request as ready for review November 22, 2021 20:57
Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring! 🚀. Just some nits and questions

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 116 at r1 (raw file):

/**
 * Get Filters from Query String and if it's different from current
 * filters calls the onFilterChange function.

"if it's different from filters calls the onFilterChange function", something feels missing in that sentence


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 131 at r1 (raw file):

  const filtersQueryString = getFiltersFromQueryString(history.location.search);
  const searchParams = new URLSearchParams(history.location.search);
  const hasFilter = searchParams.get("app") || undefined;

quick question: why are we only check "app"here? :thinking: , doesn't thesearchParams` also include other things like "node" and "regions" etc. ?


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 466 at r1 (raw file):

export const updateSortSettingQueryParamsOnTab = (
  tab: string,
  ss: SortSetting,

nit: s/ss/sortSetting/? I feel we don't really have much abbreviation across the entire code base


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 467 at r1 (raw file):

  tab: string,
  ss: SortSetting,
  defaultSS: SortSetting,

ditto

Copy link
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng)


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 116 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

"if it's different from filters calls the onFilterChange function", something feels missing in that sentence

Changed


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 131 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

quick question: why are we only check "app"here? :thinking: , doesn't thesearchParams` also include other things like "node" and "regions" etc. ?

Good catch, initially I was always adding app, so it was easy to use that to check if we had any filter, but I updated now so it checks for any filter


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 466 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

nit: s/ss/sortSetting/? I feel we don't really have much abbreviation across the entire code base

done


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 467 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

ditto

done

Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 11 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 131 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

Good catch, initially I was always adding app, so it was easy to use that to check if we had any filter, but I updated now so it checks for any filter

Nice!


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 179 at r2 (raw file):

 * @param history
 */
export const updateFiltersQueryParamsOnTab = (

same nit


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 421 at r2 (raw file):

/**
 * Get Sort Setting from Query String and if it's different from current
 * sortSetting calls the onSortChange function.

super nit: "if it's different ...., then calls the onSortChange function"


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 464 at r2 (raw file):

 * @param history
 */
export const updateSortSettingQueryParamsOnTab = (

super nit: s/updateSortSettingQueryParamsOnTab/updateSortSettingQueryParamsOnTabChange/


pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx, line 182 at r2 (raw file):

  }

  updateQueryParamsOnTabSwitch(): void {

Hmm, it seems like we are updating query params more than just when we switch tabs? So perhaps we can drop OnTabSwitch suffix here?

Copy link
Contributor Author

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng)


pkg/ui/workspaces/cluster-ui/src/queryFilter/filter.tsx, line 179 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

same nit

same as other comment


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 421 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

super nit: "if it's different ...., then calls the onSortChange function"

Done.


pkg/ui/workspaces/cluster-ui/src/sortedtable/sortedtable.tsx, line 464 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

super nit: s/updateSortSettingQueryParamsOnTab/updateSortSettingQueryParamsOnTabChange/

I named this on purpose, because it's not on the event of TabChange, is during any updated events when you're on a specific Tab. So I'm keeping this name as is :)


pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.tsx, line 182 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

Hmm, it seems like we are updating query params more than just when we switch tabs? So perhaps we can drop OnTabSwitch suffix here?

Done.

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 cockroachdb#71851

Release note: None
@maryliag
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 24, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Nov 24, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Nov 24, 2021

Build failed (retrying...):

@craig craig bot merged commit 8fa3a38 into cockroachdb:master Nov 24, 2021
@craig
Copy link
Contributor

craig bot commented Nov 24, 2021

Build succeeded:

@maryliag maryliag deleted the cache-filter-txn branch November 25, 2021 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants