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 @@ -47,7 +47,7 @@ public enum Permission {
CAN_DELETE_REVIEW_PERIOD("Delete review period", "Review Period"),
CAN_ADMINISTER_SETTINGS("Add or edit settings", "Settings"),
CAN_VIEW_SETTINGS("View settings", "Settings"),
CAN_VIEW_ALL_PULSE_RESPONSES("View all pulse responses", "Pulse");
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 moved this permission to the Reporting category since it is a kind of report and we don't have anything else in the Pulse category.

CAN_VIEW_ALL_PULSE_RESPONSES("View pulse responses", "Reporting");

private final String description;
private final String category;
Expand Down Expand Up @@ -76,4 +76,3 @@ public static Permission fromName(String name) {
throw new UnsupportedOperationException(String.format("Unknown permission: '%s'", name));
}
}

3 changes: 1 addition & 2 deletions web-ui/src/components/admin/permissions/Permissions.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useMediaQuery } from '@mui/material';
import React, { useState } from 'react';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

useState is not used here.

import React from 'react';
import DesktopTable from './DesktopTable';
import MobileTable from './MobileTable';
import { allPermissions, roles } from './sample-data';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

allPermissions and roles are not used here.


export default function Permissions() {
const showDesktop = useMediaQuery('(min-width:650px)', { noSsr: true });
Expand Down
5 changes: 2 additions & 3 deletions web-ui/src/components/menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ function Menu({ children }) {
links.push(['/checkins-reports', 'Check-ins']);
}

// TODO: Uncomment this check after PR #2429 is merged.
//if (selectHasViewPulseReportPermission(state)) {
if (selectHasViewPulseReportPermission(state)) {
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 is working now.

links.push(['/pulse-reports', 'Pulses']);
//}
}

if (selectHasSkillsReportPermission(state)) {
links.push(['/skills-reports', 'Skills']);
Expand Down
98 changes: 57 additions & 41 deletions web-ui/src/context/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ export const selectLoading = state => state.loading;
export const selectReviewPeriods = state => state.reviewPeriods;
export const selectPermissions = state => state.permissions;

const hasPermission = permissionName => createSelector(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Prettier made lots of formatting changes in this file.

selectUserProfile,
userProfile =>
userProfile &&
const hasPermission = permissionName =>
createSelector(
selectUserProfile,
userProfile =>
userProfile &&
userProfile.role &&
userProfile.permissions.some(p =>
p?.permission?.includes(permissionName)
)
userProfile.permissions.some(p => p?.permission?.includes(permissionName))
);

export const selectTeamsLoading = createSelector(selectLoading, loading => {
Expand All @@ -47,58 +46,75 @@ export const selectIsAdmin = createSelector(
userProfile && userProfile.role && userProfile.role.includes('ADMIN')
);

export const selectHasPermissionAssignmentPermission =
hasPermission('CAN_ASSIGN_ROLE_PERMISSIONS');
export const selectHasPermissionAssignmentPermission = hasPermission(
'CAN_ASSIGN_ROLE_PERMISSIONS'
);

export const selectHasReportPermission = hasPermission('REPORT');

export const selectHasAnniversaryReportPermission =
hasPermission('CAN_VIEW_ANNIVERSARY_REPORT');
export const selectHasAnniversaryReportPermission = hasPermission(
'CAN_VIEW_ANNIVERSARY_REPORT'
);

export const selectHasBirthdayReportPermission =
hasPermission('CAN_VIEW_BIRTHDAY_REPORT');
export const selectHasBirthdayReportPermission = hasPermission(
'CAN_VIEW_BIRTHDAY_REPORT'
);

export const selectHasCheckinsReportPermission =
hasPermission('CAN_VIEW_CHECKINS_REPORT');
export const selectHasCheckinsReportPermission = hasPermission(
'CAN_VIEW_CHECKINS_REPORT'
);

export const selectHasProfileReportPermission =
hasPermission('CAN_VIEW_PROFILE_REPORT');
export const selectHasProfileReportPermission = hasPermission(
'CAN_VIEW_PROFILE_REPORT'
);

export const selectHasViewPulseReportPermission =
hasPermission('CAN_VIEW_ALL_PULSE_RESPONSES');
export const selectHasViewPulseReportPermission = hasPermission(
'CAN_VIEW_ALL_PULSE_RESPONSES'
);

export const selectHasSkillsReportPermission =
hasPermission('CAN_VIEW_SKILLS_REPORT');
export const selectHasSkillsReportPermission = hasPermission(
'CAN_VIEW_SKILLS_REPORT'
);

export const selectHasTeamSkillsReportPermission =
hasPermission('CAN_VIEW_SKILLS_REPORT');
export const selectHasTeamSkillsReportPermission = hasPermission(
'CAN_VIEW_SKILLS_REPORT'
);

export const selectHasCreateReviewAssignmentsPermission =
hasPermission('CAN_CREATE_REVIEW_ASSIGNMENTS');
export const selectHasCreateReviewAssignmentsPermission = hasPermission(
'CAN_CREATE_REVIEW_ASSIGNMENTS'
);

export const selectHasDeleteReviewAssignmentsPermission =
hasPermission('CAN_DELETE_REVIEW_ASSIGNMENTS');
export const selectHasDeleteReviewAssignmentsPermission = hasPermission(
'CAN_DELETE_REVIEW_ASSIGNMENTS'
);

export const selectHasUpdateReviewAssignmentsPermission =
hasPermission('CAN_UPDATE_REVIEW_ASSIGNMENTS');
export const selectHasUpdateReviewAssignmentsPermission = hasPermission(
'CAN_UPDATE_REVIEW_ASSIGNMENTS'
);

export const selectHasViewReviewAssignmentsPermission =
hasPermission('CAN_VIEW_REVIEW_ASSIGNMENTS');
export const selectHasViewReviewAssignmentsPermission = hasPermission(
'CAN_VIEW_REVIEW_ASSIGNMENTS'
);

export const selectHasCloseReviewPeriodPermission =
hasPermission('CAN_CLOSE_REVIEW_PERIOD');
export const selectHasCloseReviewPeriodPermission = hasPermission(
'CAN_CLOSE_REVIEW_PERIOD'
);

export const selectHasCreateReviewPeriodPermission =
hasPermission('CAN_CREATE_REVIEW_PERIOD');
export const selectHasCreateReviewPeriodPermission = hasPermission(
'CAN_CREATE_REVIEW_PERIOD'
);

export const selectHasDeleteReviewPeriodPermission =
hasPermission('CAN_DELETE_REVIEW_PERIOD');
export const selectHasDeleteReviewPeriodPermission = hasPermission(
'CAN_DELETE_REVIEW_PERIOD'
);

export const selectHasLaunchReviewPeriodPermission =
hasPermission('CAN_LAUNCH_REVIEW_PERIOD');
export const selectHasLaunchReviewPeriodPermission = hasPermission(
'CAN_LAUNCH_REVIEW_PERIOD'
);

export const selectHasUpdateReviewPeriodPermission =
hasPermission('CAN_UPDATE_REVIEW_PERIOD');
export const selectHasUpdateReviewPeriodPermission = hasPermission(
'CAN_UPDATE_REVIEW_PERIOD'
);

export const selectIsPDL = createSelector(
selectUserProfile,
Expand Down
Loading