-
Notifications
You must be signed in to change notification settings - Fork 6
Skill Categories page now gets settings from query parameters #2272
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
Changes from all commits
6ec66a5
5f2388e
8a83c15
f50a916
e5468e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import React, { useContext, useState } from 'react'; | ||
| import { Link } from 'react-router-dom'; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just moved up a few lines. |
||
|
|
||
| import { AppContext } from '../context/AppContext'; | ||
| import { selectOrderedSkills, selectPendingSkills } from '../context/selectors'; | ||
| import EditSkillsCard from '../components/edit_skills/EditSkillsCard'; | ||
| import EditSkillsModal from '../components/edit_skills/EditSkillsModal'; | ||
| import { Link } from 'react-router-dom'; | ||
| import { useQueryParameters } from '../helpers/query-parameters'; | ||
|
|
||
| import { Button, TextField } from '@mui/material'; | ||
|
|
||
|
|
@@ -26,6 +27,21 @@ const EditSkillsPage = () => { | |
|
|
||
| const handleClick = () => setShowAllSkills(!showAllSkills); | ||
|
|
||
| useQueryParameters([ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds support for maintaining state with query parameters. |
||
| { | ||
| name: 'search', | ||
| default: '', | ||
| value: searchText, | ||
| setter: setSearchText | ||
| }, | ||
| { | ||
| name: 'showAll', | ||
| default: false, | ||
| value: showAllSkills, | ||
| setter: setShowAllSkills | ||
| } | ||
| ]); | ||
|
|
||
| return ( | ||
| <div className="pending-skills-page"> | ||
| <div className="search"> | ||
|
|
@@ -42,10 +58,10 @@ const EditSkillsPage = () => { | |
| <div className="show-all-skills"> | ||
| <label htmlFor="all-skills">Show all skills</label> | ||
| <input | ||
| onClick={handleClick} | ||
| onChange={handleClick} | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's recommended to use |
||
| id="all-skills" | ||
| type="checkbox" | ||
| value={showAllSkills} | ||
| checked={showAllSkills} | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,37 @@ | ||
| import React, { useCallback, useContext, useEffect, useState } from 'react'; | ||
| import { styled } from '@mui/material/styles'; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reordered several of the imports. |
||
|
|
||
| import { AppContext } from '../context/AppContext'; | ||
|
|
||
| import fileDownload from 'js-file-download'; | ||
|
|
||
| import { Search } from '@mui/icons-material'; | ||
| import DownloadIcon from '@mui/icons-material/FileDownload'; | ||
| import { | ||
| Autocomplete, | ||
| Button, | ||
| Dialog, | ||
| DialogActions, | ||
| DialogContent, | ||
| DialogContentText, | ||
| DialogTitle, | ||
| IconButton, | ||
| InputAdornment, | ||
| TextField, | ||
| Tooltip, | ||
| Typography | ||
| } from '@mui/material'; | ||
| import SkillCategoryCard from '../components/skill-category-card/SkillCategoryCard'; | ||
| import { styled } from '@mui/material/styles'; | ||
|
|
||
| import './SkillCategoriesPage.css'; | ||
| import { selectCsrfToken, selectOrderedSkills } from '../context/selectors'; | ||
| import { | ||
| createSkillCategory, | ||
| deleteSkillCategory, | ||
| getSkillCategories, | ||
| getSkillsCsv | ||
| } from '../api/skillcategory'; | ||
| import SkillCategoryCard from '../components/skill-category-card/SkillCategoryCard'; | ||
| import SkillCategoryNewDialog from '../components/skill-category-new-dialog/SkillCategoryNewDialog'; | ||
| import { UPDATE_TOAST } from '../context/actions'; | ||
| import Dialog from '@mui/material/Dialog'; | ||
| import InputAdornment from '@mui/material/InputAdornment'; | ||
| import { Search } from '@mui/icons-material'; | ||
| import Autocomplete from '@mui/material/Autocomplete'; | ||
| import DownloadIcon from '@mui/icons-material/FileDownload'; | ||
| import { AppContext } from '../context/AppContext'; | ||
| import { selectCsrfToken, selectOrderedSkills } from '../context/selectors'; | ||
| import { useQueryParameters } from '../helpers/query-parameters'; | ||
|
|
||
| import './SkillCategoriesPage.css'; | ||
|
|
||
| const PREFIX = 'SkillCategoriesPage'; | ||
| const classes = { | ||
|
|
@@ -65,6 +64,33 @@ const SkillCategoriesPage = () => { | |
| const [query, setQuery] = useState(''); | ||
| const [skillFilter, setSkillFilter] = useState(null); | ||
|
|
||
| useQueryParameters([ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds support for maintaining state with query parameters. |
||
| { | ||
| name: 'addNew', | ||
| default: false, | ||
| value: dialogOpen, | ||
| setter: setDialogOpen | ||
| }, | ||
| { | ||
| name: 'filter', | ||
| default: null, | ||
| value: skillFilter, | ||
| setter(value) { | ||
| const skill = skills.find(s => s.name === value) || null; | ||
| setSkillFilter(skill); | ||
| }, | ||
| toQP(filter) { | ||
| return filter?.name ?? null; | ||
| } | ||
| }, | ||
| { | ||
| name: 'search', | ||
| default: '', | ||
| value: query, | ||
| setter: setQuery | ||
| } | ||
| ]); | ||
|
|
||
| const retrieveCategories = useCallback(async () => { | ||
| if (csrf) { | ||
| const res = await getSkillCategories(csrf); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,6 @@ exports[`renders correctly 1`] = ` | |
| <input | ||
| id="all-skills" | ||
| type="checkbox" | ||
| value="false" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using the |
||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using the
checkedproperty now instead of thevalueproperty.