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

Pv testing bugdfix #3018

Merged
merged 8 commits into from
Jun 12, 2024
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
2 changes: 1 addition & 1 deletion src/Components/AoPage/AoPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AoPage = () => (
<Route path="/profile/ao/availablebidders" render={() => <AvailableBidderContainer isCDO={false} isAO />} />
<Route path="/profile/ao/panelmeetingagendas/:pmID" render={() => <PanelMeetingAgendas isAO />} />
<Route path="/profile/ao/cyclemanagement" render={() => <CycleManagement isAO />} />
<Route path="/profile/ao/projectedvacancy" render={() => <ProjectedVacancy isCDO={false} isAO />} />
<Route path="/profile/ao/projectedvacancy" render={() => <ProjectedVacancy viewType="ao" />} />
<Route path="/profile/ao/assignmentcycle/:id" render={() => <AssignmentCycleEdit isAO />} />
<Route path="/profile/ao/cyclepositionsearch/:id" render={() => <CyclePositionSearch isAO />} />
<Route path="/profile/ao/cycleclassifications/" render={() => <CycleClassifications isAO />} />
Expand Down
2 changes: 1 addition & 1 deletion src/Components/BureauPage/BureauPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BureauPage = () => {
<Route path="/profile/bureau/managepostaccess" render={() => <ManagePostAccess />} />
<Route path="/profile/bureau/positionmanager/:type/:id" render={() => <PositionManagerDetails />} />
<Route path="/profile/bureau/positionmanager" render={() => <PositionManager {...posManagerProps} />} />
<Route path="/profile/bureau/projectedvacancy" render={() => <ProjectedVacancy isCDO={false} isAO={false} />} />
<Route path="/profile/bureau/projectedvacancy" render={() => <ProjectedVacancy viewType="bureau" />} />
<Route path="/profile/bureau/publishablepositions" render={() => <PublishablePositions viewType="bureau" />} />
<Route path="/profile/bureau/searchpostaccess" render={() => <SearchPostAccess />} />
<Route path="/profile/bureau/biddingtool/:id" render={() => <BiddingTool />} />
Expand Down
43 changes: 35 additions & 8 deletions src/Components/BureauPage/ProjectedVacancy/ProjectedVacancy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
projectedVacancyFetchData,
projectedVacancyFilters,
projectedVacancyLangOffsetOptions,
// projectedVacancyLangOffsets,
saveProjectedVacancySelections,
} from 'actions/projectedVacancy';
import { onEditModeSearch, renderSelectionList, userHasPermissions } from 'utilities';
Expand All @@ -29,12 +28,14 @@ const enableCycleImport = () => checkFlag('flags.projected_vacancy_cycle_import'
const enableEdit = () => checkFlag('flags.projected_vacancy_edit');

// eslint-disable-next-line complexity
const ProjectedVacancy = () => {
const ProjectedVacancy = ({ viewType }) => {
const dispatch = useDispatch();

const userProfile = useSelector(state => state.userProfile);
const isAo = userHasPermissions(['ao_user'], userProfile?.permission_groups);
const isBureau = userHasPermissions(['bureau_user'], userProfile?.permission_groups);
const bureauPermissions = useSelector(state => state.userProfile.bureau_permissions);
const isBureauView = viewType === 'bureau';

const userSelections = useSelector(state => state.projectedVacancySelections);
const filters = useSelector(state => state.projectedVacancyFilters) || [];
Expand Down Expand Up @@ -78,7 +79,28 @@ const ProjectedVacancy = () => {
const [selectedCycle, setSelectedCycle] =
useState(userSelections?.selectedCycle || null);

const bureaus = sortBy(filters?.bureaus || [], [o => o.description]);
const getBureauFilters = () => {
const originalBureaus = sortBy(filters?.bureaus || [], [o => o.short_description]);
if (originalBureaus && isBureauView) {
const bureauPermissionsGroups = Object.groupBy(bureauPermissions, ({ short_description }) => short_description);
const userBureauDescPermissions = Object.keys(bureauPermissionsGroups);
// filter out if user does not have that bureau permission
return originalBureaus.filter((a) => userBureauDescPermissions.includes(a?.short_description));
}
return originalBureaus;
};

const filterSelectionValid = () => {
// valid if:
// not Bureau user
// a Bureau filter selected
if (viewType === 'bureau') {
return selectedBureaus.length > 0;
}
return true;
};

const bureaus = getBureauFilters();
const grades = sortBy(filters?.grades || [], [o => o.code]);
const skills = sortBy(filters?.skills || [], [o => o.description]);
const languages = sortBy(filters?.languages || [], [o => o.description]);
Expand Down Expand Up @@ -140,6 +162,8 @@ const ProjectedVacancy = () => {
overlay = <Spinner type="standard-center" class="homepage-position-results" size="big" />;
} else if (resultsErrored) {
overlay = <Alert type="error" title="Error displaying Projected Vacancies" messages={[{ body: 'Please try again.' }]} />;
} else if (!filterSelectionValid()) {
overlay = <Alert type="info" title="Select Bureau Filter" messages={[{ body: 'Please select a Bureau Filter.' }]} />;
} else if (!positionsData?.results?.length) {
overlay = <Alert type="info" title="No results found" messages={[{ body: 'No projected vacancies for filter inputs.' }]} />;
} else {
Expand Down Expand Up @@ -187,11 +211,13 @@ const ProjectedVacancy = () => {
} else {
setClearFilters(true);
}
if (resetPage) {
setPage(1);
if (filterSelectionValid()) {
if (resetPage) {
setPage(1);
}
dispatch(projectedVacancyFetchData(getQuery()));
dispatch(saveProjectedVacancySelections(getCurrentInputs()));
}
dispatch(projectedVacancyFetchData(getQuery()));
dispatch(saveProjectedVacancySelections(getCurrentInputs()));
};

useEffect(() => {
Expand Down Expand Up @@ -353,7 +379,7 @@ const ProjectedVacancy = () => {
disabled={disableInput}
/>
</div>
{enableCycleImport &&
{enableCycleImport() &&
<div className="filter-div">
<div className="label">Cycle:</div>
<Picky
Expand Down Expand Up @@ -474,6 +500,7 @@ const ProjectedVacancy = () => {


ProjectedVacancy.propTypes = {
viewType: PropTypes.string.isRequired,
bureauFiltersIsLoading: PropTypes.bool,
};

Expand Down
Loading