Skip to content

Commit

Permalink
Add filter query to url on roles page (#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
michellemounde committed Jan 8, 2024
1 parent 4a471a0 commit 12e124e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ui/src/views/Roles/ListRoles/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Fragment, useState, useEffect, useMemo } from 'react';
import { stringify, parse } from 'qs';
import Spinner from '@mozilla-frontend-infra/components/Spinner';
import { makeStyles } from '@material-ui/styles';
import List from '@material-ui/core/List';
Expand Down Expand Up @@ -33,8 +34,10 @@ const useStyles = makeStyles(theme => ({
},
}));

function ListRoles() {
function ListRoles(props) {
const classes = useStyles();
const { search } = props.location;
const query = parse(search.slice(1));
const [usersAction, fetchUsers] = useAction(getUsers);
const [roleFilter, setRoleFilter] = useState(ALL);
const isLoading = usersAction.loading;
Expand Down Expand Up @@ -75,6 +78,13 @@ function ListRoles() {

const handleFilterChange = ({ target: { value } }) => {
setRoleFilter(value);

const qs = {
...query,
role: value !== 'all' ? value : undefined,
};

props.history.push(`/roles${stringify(qs, { addQueryPrefix: true })}`);
};

return (
Expand Down

0 comments on commit 12e124e

Please sign in to comment.