Browse Source

fix(page-filters): Reset params on change (#35389)

This was missing in the switch over to page filters and only existed in the old style GSH which isn't being used anymore.

This usage of the prop basically tells the page filters to reset cursor anytime their selection is changed.
David Wang 2 years ago
parent
commit
145d2af935

+ 7 - 1
static/app/components/projectPageFilter.tsx

@@ -48,6 +48,11 @@ type Props = WithRouterProps & {
    */
    */
   maxTitleLength?: number;
   maxTitleLength?: number;
 
 
+  /**
+   * Reset these URL params when we fire actions (custom routing only)
+   */
+  resetParamsOnChange?: string[];
+
   /**
   /**
    * A project will be forced from parent component (selection is disabled, and if user
    * A project will be forced from parent component (selection is disabled, and if user
    * does not have multi-project support enabled, it will not try to auto select a project).
    * does not have multi-project support enabled, it will not try to auto select a project).
@@ -77,6 +82,7 @@ function ProjectPageFilter({
   router,
   router,
   specificProjectSlugs,
   specificProjectSlugs,
   maxTitleLength = 30,
   maxTitleLength = 30,
+  resetParamsOnChange = [],
   ...otherProps
   ...otherProps
 }: Props) {
 }: Props) {
   const [currentSelectedProjects, setCurrentSelectedProjects] = useState<number[] | null>(
   const [currentSelectedProjects, setCurrentSelectedProjects] = useState<number[] | null>(
@@ -105,7 +111,7 @@ function ProjectPageFilter({
   const handleApplyChange = (newProjects: number[]) => {
   const handleApplyChange = (newProjects: number[]) => {
     updateProjects(newProjects, router, {
     updateProjects(newProjects, router, {
       save: true,
       save: true,
-      resetParams: [],
+      resetParams: resetParamsOnChange,
       environments: [], // Clear environments when switching projects
       environments: [], // Clear environments when switching projects
     });
     });
   };
   };

+ 1 - 1
static/app/views/monitors/monitors.tsx

@@ -82,7 +82,7 @@ class Monitors extends AsyncView<Props, State> {
           </HeaderTitle>
           </HeaderTitle>
         </PageHeader>
         </PageHeader>
         <Filters>
         <Filters>
-          <ProjectPageFilter />
+          <ProjectPageFilter resetParamsOnChange={['cursor']} />
           <SearchBar
           <SearchBar
             query={decodeScalar(qs.parse(location.search)?.query, '')}
             query={decodeScalar(qs.parse(location.search)?.query, '')}
             placeholder={t('Search for monitors.')}
             placeholder={t('Search for monitors.')}

+ 3 - 3
static/app/views/replays/filters.tsx

@@ -20,9 +20,9 @@ function ReplaysFilters({organization, handleSearchQuery, query}: Props) {
     <FilterContainer>
     <FilterContainer>
       <SearchContainer>
       <SearchContainer>
         <PageFilterBar condensed>
         <PageFilterBar condensed>
-          <ProjectPageFilter />
-          <EnvironmentPageFilter />
-          <DatePageFilter alignDropdown="left" />
+          <ProjectPageFilter resetParamsOnChange={['cursor']} />
+          <EnvironmentPageFilter resetParamsOnChange={['cursor']} />
+          <DatePageFilter alignDropdown="left" resetParamsOnChange={['cursor']} />
         </PageFilterBar>
         </PageFilterBar>
         <SearchBar
         <SearchBar
           organization={organization}
           organization={organization}