Skip to content
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

WIP - RELENG-941: Display used Releases, unless unused requested #2562

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions ui/src/views/Releases/ListReleases/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import FormControl from '@material-ui/core/FormControl';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormLabel from '@material-ui/core/FormLabel';
import Switch from '@material-ui/core/Switch';
import Spinner from '@mozilla-frontend-infra/components/Spinner';
import { Typography } from '@material-ui/core';
import Dashboard from '../../../components/Dashboard';
Expand Down Expand Up @@ -66,6 +68,18 @@ const useStyles = makeStyles(theme => ({
padding: theme.spacing(1),
maxHeight: '80vh',
},
options: {
display: 'flex',
justifyContent: 'flex-end',
margin: theme.spacing(1),
},
formControl: {
display: 'flex',
alignItems: 'center',
},
formLabel: {
transform: 'scale(0.75)',
},
}));

function ListReleases(props) {
Expand All @@ -82,6 +96,7 @@ function ListReleases(props) {
} = elementsHeight(theme);
const releaseListRef = useRef(null);
const { hash } = props.location;
const [showUnreferencedRules, setShowUnreferencedRules] = useState(false);
const [releaseNameHash, setReleaseNameHash] = useState(null);
const [scrollToRow, setScrollToRow] = useState(null);
const [searchValue, setSearchValue] = useState('');
Expand Down Expand Up @@ -135,13 +150,15 @@ function ListReleases(props) {
}

if (!searchValue) {
return releases;
return releases.filter(release => showUnreferencedRules ? true : Object.keys(release.rule_info).length > 0);
}

return releases.filter(release =>
const results = releases.filter(release =>
release.name.toLowerCase().includes(searchValue.toLowerCase())
);
}, [releases, searchValue]);

return results.filter(release => showUnreferencedRules ? true : Object.keys(release.rule_info).length > 0);
}, [releases, searchValue, showUnreferencedRules]);
const filteredReleasesCount = filteredReleases.length;
const handleSignoffRoleChange = ({ target: { value } }) =>
setSignoffRole(value);
Expand Down Expand Up @@ -685,6 +702,10 @@ function ListReleases(props) {
}
};

const handleShowUnreferencedRules = ({ target: { checked } }) => {
setShowUnreferencedRules(checked);
}

const Row = ({ index, style }) => {
const release = filteredReleases[index];
const isSelected = Boolean(hash && hash.replace('#', '') === release.name);
Expand Down Expand Up @@ -809,6 +830,17 @@ function ListReleases(props) {
onChange={handleSearchChange}
value={searchValue}
/>
<div className={classes.options}>
<FormControl className={classes.formControl}>
<FormLabel className={classes.formLabel}>
Show unreferenced rules
</FormLabel>
<Switch
checked={showUnreferencedRules}
onChange={handleShowUnreferencedRules}
/>
</FormControl>
</div>
{isLoading && <Spinner loading />}
{error && <ErrorPanel fixed error={error} />}
{!isLoading && filteredReleases && (
Expand Down