-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(webapp): don't reload runs list when toggling bulk action inspector #3841
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: fix | ||
| --- | ||
|
|
||
| Stop reloading the runs list when opening or closing the bulk action inspector |
This file contains hidden or 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
75 changes: 75 additions & 0 deletions
75
...nizationSlug.projects.$projectParam.env.$envParam.runs._index/shouldRevalidateRunsList.ts
This file contains hidden or 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,75 @@ | ||
| import type { Navigation, ShouldRevalidateFunction } from "@remix-run/react"; | ||
|
|
||
| /** Search params that only control the bulk-action inspector UI, not list data. */ | ||
| export const RUNS_BULK_INSPECTOR_UI_SEARCH_PARAMS = ["bulkInspector", "action", "mode"] as const; | ||
|
|
||
| /** URL value set on `bulkInspector` when the inspector panel is open (presence flag). */ | ||
| export const RUNS_BULK_INSPECTOR_OPEN_VALUE = "show"; | ||
|
|
||
| /** Returns a copy with bulk-inspector UI params removed. */ | ||
| export function stripBulkInspectorUiParams(params: URLSearchParams): URLSearchParams { | ||
| const stripped = new URLSearchParams(params); | ||
| for (const key of RUNS_BULK_INSPECTOR_UI_SEARCH_PARAMS) { | ||
| stripped.delete(key); | ||
| } | ||
| return stripped; | ||
| } | ||
|
|
||
| /** Canonical string for list-data params (UI keys stripped, entries sorted by key). */ | ||
| export function canonicalRunsListDataSearchParams(params: URLSearchParams): string { | ||
| const stripped = stripBulkInspectorUiParams(params); | ||
| stripped.sort(); | ||
| return stripped.toString(); | ||
| } | ||
|
|
||
| export function searchParamsEqualIgnoringBulkInspectorUiState( | ||
| current: URLSearchParams, | ||
| next: URLSearchParams | ||
| ) { | ||
| return ( | ||
| canonicalRunsListDataSearchParams(current) === canonicalRunsListDataSearchParams(next) | ||
| ); | ||
| } | ||
|
|
||
| /** True when navigation should show the runs table loading state (excludes bulk-inspector UI toggles). */ | ||
| export function isRunsListLoading(navigation: Navigation, currentSearch: string): boolean { | ||
| if (navigation.state === "idle" || !navigation.location) { | ||
| return false; | ||
| } | ||
|
|
||
| const currentParams = new URLSearchParams(currentSearch); | ||
| const nextParams = new URLSearchParams(navigation.location.search); | ||
|
|
||
| if (searchParamsEqualIgnoringBulkInspectorUiState(currentParams, nextParams)) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Skip runs list loader revalidation when only bulk-inspector UI params change. | ||
| * Explicit revalidate() (unchanged URL) and filter/pagination changes still revalidate. | ||
| */ | ||
| export const shouldRevalidateRunsList: ShouldRevalidateFunction = ({ | ||
| currentUrl, | ||
| nextUrl, | ||
| defaultShouldRevalidate, | ||
| }) => { | ||
| if (currentUrl.pathname !== nextUrl.pathname) { | ||
| return defaultShouldRevalidate; | ||
| } | ||
|
|
||
| const currentParams = new URLSearchParams(currentUrl.search); | ||
| const nextParams = new URLSearchParams(nextUrl.search); | ||
|
|
||
| if (currentParams.toString() === nextParams.toString()) { | ||
| return defaultShouldRevalidate; | ||
| } | ||
|
|
||
| if (searchParamsEqualIgnoringBulkInspectorUiState(currentParams, nextParams)) { | ||
| return false; | ||
| } | ||
|
|
||
| return defaultShouldRevalidate; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.