Skip to content

Commit

Permalink
fix persistent filter on wfjt detail; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
keithjgrant committed May 19, 2022
1 parent e33564f commit ddbe1d0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions awx/ui/src/components/PersistentFilters/PersistentFilters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect } from 'react';
import { useLocation, useHistory } from 'react-router';

const STORAGE_KEY = 'persistentFilter';
import { PERSISTENT_FILTER_KEY } from '../../constants';

export default function PersistentFilters({ pageKey, children }) {
const location = useLocation();
Expand All @@ -12,7 +11,7 @@ export default function PersistentFilters({ pageKey, children }) {
return;
}

const filterString = sessionStorage.getItem(STORAGE_KEY);
const filterString = sessionStorage.getItem(PERSISTENT_FILTER_KEY);
const filter = filterString ? JSON.parse(filterString) : { qs: '' };

if (filter.pageKey === pageKey) {
Expand All @@ -27,7 +26,7 @@ export default function PersistentFilters({ pageKey, children }) {
pageKey,
qs: location.search,
};
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(filter));
sessionStorage.setItem(PERSISTENT_FILTER_KEY, JSON.stringify(filter));
}, [location.search, pageKey]);

return children;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Router, Route } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import PersistentFilters from './PersistentFilters';

const KEY = 'persistentFilter';
const KEY = 'awx-persistent-filter';

describe('PersistentFilters', () => {
test('should initialize filter in sessionStorage', () => {
Expand Down
1 change: 1 addition & 0 deletions awx/ui/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const JOB_TYPE_URL_SEGMENTS = {

export const SESSION_TIMEOUT_KEY = 'awx-session-timeout';
export const SESSION_REDIRECT_URL = 'awx-redirect-url';
export const PERSISTENT_FILTER_KEY = 'awx-persistent-filter';
1 change: 1 addition & 0 deletions awx/ui/src/screens/Template/WorkflowJobTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function WorkflowJobTemplate({ setBreadcrumb }) {
</>
),
link: `/templates`,
isBackButton: true,
id: 99,
},
{ name: t`Details`, link: `${match.url}/details` },
Expand Down

0 comments on commit ddbe1d0

Please sign in to comment.