Skip to content

Commit

Permalink
🐛 Persist filters in URL for applications table (#2033)
Browse files Browse the repository at this point in the history
Fix regression after: #1980
Resolves: https://issues.redhat.com/browse/MTA-1390

Initial filter values work best if the table is not persisting state
between reloads (default strategy, component state). If the table uses
session or local storage then any existing filter overwrites the default
value. From the end user perspective the functionality works only on the
first load with a clean browser (no previous state).

Switching to URL filter persistence provides the same functionality and
ensures we have only one source of filters.

Reference-Url:  #1698

Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko authored Jul 31, 2024
1 parent 04c244e commit a2646a5
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ import { checkAccess } from "@app/utils/rbac-utils";
import WarningTriangleIcon from "@patternfly/react-icons/dist/esm/icons/warning-triangle-icon";

// Hooks
import {
deserializeFilterUrlParams,
useLocalTableControls,
} from "@app/hooks/table-controls";
import { useLocalTableControls } from "@app/hooks/table-controls";

// Queries
import { getArchetypeById, getAssessmentsByItemId } from "@app/api/rest";
Expand Down Expand Up @@ -308,11 +305,6 @@ export const ApplicationsTable: React.FC = () => {
};

// ----- Table controls
const urlParams = new URLSearchParams(window.location.search);
const filters = urlParams.get("filters");

const deserializedFilterValues = deserializeFilterUrlParams({ filters });

const tableControls = useLocalTableControls({
tableName: "applications",
idProperty: "id",
Expand All @@ -333,7 +325,7 @@ export const ApplicationsTable: React.FC = () => {
isActiveItemEnabled: true,
persistTo: {
activeItem: "urlParams",
filter: "sessionStorage",
filter: "urlParams",
pagination: "sessionStorage",
sort: "sessionStorage",
},
Expand All @@ -343,7 +335,6 @@ export const ApplicationsTable: React.FC = () => {
initialColumns: {
name: { isIdentity: true },
},
initialFilterValues: deserializedFilterValues,
getSortValues: (app) => ({
name: app.name,
businessService: app.businessService?.name || "",
Expand Down

0 comments on commit a2646a5

Please sign in to comment.