Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exports[`EditSkillsCard > renders correctly 1`] = `
<input
id="all-skills"
type="checkbox"
value="false"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the checked property now instead of the value property.

/>
</div>
</div>
Expand Down
22 changes: 19 additions & 3 deletions web-ui/src/pages/EditSkillsPage.jsx
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';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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';

Expand All @@ -26,6 +27,21 @@ const EditSkillsPage = () => {

const handleClick = () => setShowAllSkills(!showAllSkills);

useQueryParameters([
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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">
Expand All @@ -42,10 +58,10 @@ const EditSkillsPage = () => {
<div className="show-all-skills">
<label htmlFor="all-skills">Show all skills</label>
<input
onClick={handleClick}
onChange={handleClick}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recommended to use onChange with checkboxes instead of onClick.

id="all-skills"
type="checkbox"
value={showAllSkills}
checked={showAllSkills}
/>
</div>
</div>
Expand Down
52 changes: 39 additions & 13 deletions web-ui/src/pages/SkillCategoriesPage.jsx
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';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 = {
Expand Down Expand Up @@ -65,6 +64,33 @@ const SkillCategoriesPage = () => {
const [query, setQuery] = useState('');
const [skillFilter, setSkillFilter] = useState(null);

useQueryParameters([
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exports[`renders correctly 1`] = `
<input
id="all-skills"
type="checkbox"
value="false"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the checked property now instead of the value property.

/>
</div>
</div>
Expand Down