feat(admin-ui): Encode location id in URL on location table (#3533)

Encoded the `location_id` into the query params and ensured it gets parsed on mount, into defaults. This allows safer refreshes of the locations table or accurate deep-links to be shared.

Resolves CORE-1252
This commit is contained in:
Rares Stefan
2023-03-21 09:12:58 +01:00
committed by GitHub
parent d525c27774
commit 497c7c55c7
2 changed files with 8 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ interface InventoryFilterState {
additionalFilters: InventoryDefaultFilters | null
}
const allowedFilters = ["location", "q", "offset", "limit"]
const allowedFilters = ["q", "offset", "limit", "location_id"]
const DefaultTabs = {}
@@ -226,8 +226,8 @@ export const useInventoryFilters = (
if (value && typeof value === "string") {
toQuery["q"] = value
}
} else if (key === "offset" || key === "limit") {
toQuery[key] = value
} else if (key === "offset" || key === "limit" || key === "location") {
toQuery[stateFilterMap[key] || key] = value
} else if (value.open) {
toQuery[stateFilterMap[key]] = value.filter
}