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

Swag at permissions changes #2135

Merged
merged 41 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c812eef
[2064] Permissions Page init
S78901 Dec 5, 2023
bb8545e
[2064] Menu Addition
S78901 Dec 6, 2023
e64fa3e
[2064] Actions
S78901 Dec 7, 2023
6b1c28e
Merge remote-tracking branch 'origin/develop' into feature-2064/admin…
S78901 Dec 7, 2023
a60e3cf
Merge remote-tracking branch 'origin/develop' into feature-2064/admin…
S78901 Dec 12, 2023
0ac03e5
[2064] Updating Permissions page
S78901 Dec 13, 2023
491b7cb
Merge branch 'develop' into feature-2064/admin-ui-page
S78901 Dec 25, 2023
60e44aa
[2064] Update Permissions Page
S78901 Dec 25, 2023
13a9d09
[2064] Adding API
S78901 Jan 8, 2024
3d7091d
[2064] Simplify UI / add roles to permissions tree
S78901 Jan 30, 2024
a105b81
[2064] More roles
S78901 Jan 30, 2024
256990b
[2064] More roles
S78901 Jan 31, 2024
8061b1e
[2064] Another chunk of roles
S78901 Feb 2, 2024
0c1ae52
[2064] Final Roles input batch
S78901 Feb 2, 2024
3f092e1
[2064] Add several API's & work on connections
S78901 Feb 5, 2024
ea06c05
[2064] Add restrictions for role
S78901 Feb 5, 2024
5fd43f3
[2064] UI Linked to Roles Dynamically
S78901 Feb 5, 2024
e8c01ac
[2064] Fix csrf loading issue
S78901 Feb 23, 2024
3704a7b
[2064] Solution for CSRF
S78901 Feb 26, 2024
7a08cc7
[2064] Remove unneeded section
S78901 Feb 29, 2024
daef620
[2064] Fix role ID's
S78901 Mar 4, 2024
3919d18
[2064] Add Post action for role permissions
S78901 Mar 4, 2024
c3191f4
[2064] Role permissions adjustments
S78901 Mar 4, 2024
f88993f
[2064] Fix achieved, api error?
S78901 Mar 6, 2024
57d2166
[2064] Small adjustment
S78901 Mar 6, 2024
297d35c
[2064] Adjustment
S78901 Mar 6, 2024
27cd0dc
[2064] Fix 'Delete' Method
S78901 Mar 7, 2024
d00aba6
[2064] Dynamic ID lookup for roles and permissions id's
S78901 Mar 11, 2024
c3cccf9
Merge remote-tracking branch 'origin/develop' into feature-2064/admin…
S78901 Mar 11, 2024
b12100c
[2064] Small fix
S78901 Mar 11, 2024
5d710df
[2064] Added more sections for the API
S78901 Mar 11, 2024
5b4113a
[2064] Finishing up api calls
S78901 Mar 14, 2024
e574aab
[2064] Post testing fix for nonworking calls
S78901 Mar 14, 2024
be7726a
[2064] Fix typo/omission
S78901 Mar 14, 2024
223a189
Swag at permissions changes
mkimberlin Mar 20, 2024
407bb6a
Disable eslint rule for now
mkimberlin Mar 20, 2024
5bc6f3e
Fix permissions tests
mkimberlin Mar 20, 2024
7b9f480
Use dynamically loaded Permission description and categories
mkimberlin Mar 21, 2024
ac04b91
Prevent duplicate call to load permissions
mkimberlin Mar 21, 2024
f620b5c
fixed a hook dependency
mkimberlin Mar 21, 2024
74ba469
Adjustments from PR feedback
mkimberlin Mar 21, 2024
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
pieperm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
package com.objectcomputing.checkins.security.permissions;

public enum Permissions {
CAN_VIEW_FEEDBACK_REQUEST,
CAN_CREATE_FEEDBACK_REQUEST,
CAN_DELETE_FEEDBACK_REQUEST,
CAN_VIEW_FEEDBACK_ANSWER,
CAN_DELETE_ORGANIZATION_MEMBERS,
CAN_CREATE_ORGANIZATION_MEMBERS,
CAN_VIEW_ROLE_PERMISSIONS,
CAN_ASSIGN_ROLE_PERMISSIONS,
CAN_VIEW_PERMISSIONS,
CAN_VIEW_SKILLS_REPORT,
CAN_VIEW_RETENTION_REPORT,
CAN_VIEW_ANNIVERSARY_REPORT,
CAN_VIEW_BIRTHDAY_REPORT,
CAN_VIEW_PROFILE_REPORT,
CAN_CREATE_CHECKINS,
CAN_VIEW_CHECKINS,
CAN_UPDATE_CHECKINS,
}
CAN_VIEW_FEEDBACK_REQUEST("View feedback requests", "Feedback"),
CAN_CREATE_FEEDBACK_REQUEST("Create feedback requests", "Feedback"),
CAN_DELETE_FEEDBACK_REQUEST("Delete feedback requests", "Feedback"),
CAN_VIEW_FEEDBACK_ANSWER("View feedback answers", "Feedback"),
CAN_DELETE_ORGANIZATION_MEMBERS("Delete organization members", "User Management"),
CAN_CREATE_ORGANIZATION_MEMBERS("Create organization members", "User Management"),
CAN_VIEW_ROLE_PERMISSIONS("View role permissions", "Security"),
CAN_ASSIGN_ROLE_PERMISSIONS("Assign role permissions", "Security"),
CAN_VIEW_PERMISSIONS("View all permissions", "Security"),
CAN_VIEW_SKILLS_REPORT("View skills report", "Reporting"),
CAN_VIEW_RETENTION_REPORT("View retention report", "Reporting"),
CAN_VIEW_ANNIVERSARY_REPORT("View anniversary report", "Reporting"),
CAN_VIEW_BIRTHDAY_REPORT("View birthday report", "Reporting"),
CAN_VIEW_PROFILE_REPORT("View profile report", "Reporting"),
CAN_CREATE_CHECKINS("Create check-ins", "Check-ins"),
CAN_VIEW_CHECKINS("View check-ins", "Check-ins"),
CAN_UPDATE_CHECKINS("Update check-ins", "Check-ins");

private final String description;
private final String category;

Permissions(String description, String category) {
this.description = description;
this.category = category;
}

public String getDescription() {
return description;
}

public String getCategory() {
return category;
}
}
pieperm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.objectcomputing.checkins.services.permissions;

import com.objectcomputing.checkins.security.permissions.Permissions;
import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.data.annotation.AutoPopulated;
Expand All @@ -11,6 +12,7 @@
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;
import java.util.Objects;
import java.util.UUID;
Expand Down Expand Up @@ -59,13 +61,18 @@ public void setPermission(String permission) {
}

public String getDescription() {
return description;
return Permissions.valueOf(permission).getDescription(); //ignoring the database for now...
}

public void setDescription(String description) {
pieperm marked this conversation as resolved.
Show resolved Hide resolved
this.description = description;
}

@Transient
public String getCategory() {
return Permissions.valueOf(permission).getCategory();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public interface PermissionFixture extends RepositoryFixture, RolePermissionFixt
);

default Permission createACustomPermission(Permissions perm) {
return getPermissionRepository().save(new Permission(null, perm.name(), null));
return getPermissionRepository().save(new Permission(null, perm.name(), perm.getDescription()));
}

default void saveAllPermissions() {
for(Permissions permissions : Permissions.values()) {
getPermissionRepository().save(new Permission(null, permissions.name(), null));
getPermissionRepository().save(new Permission(null, permissions.name(), permissions.getDescription()));
}
}

Expand Down
11 changes: 11 additions & 0 deletions web-ui/src/api/memberroles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { resolve } from "./api.js";

const memberRolesUrl = "/services/roles/members"

export const getMemberRolesList = async (cookie) => {
return resolve({
url: memberRolesUrl,
responseType: "json",
headers: { "X-CSRF-Header": cookie },
});
};
11 changes: 11 additions & 0 deletions web-ui/src/api/permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { resolve } from "./api.js";

const permissionsListUrl = "/services/permissions"

export const getPermissionsList = async (cookie) => {
return resolve({
url: permissionsListUrl,
responseType: "json",
headers: { "X-CSRF-Header": cookie },
});
};
31 changes: 31 additions & 0 deletions web-ui/src/api/rolepermissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { resolve } from "./api.js";

const rolePermissionsListUrl = "/services/roles/role-permissions";

export const getRolePermissionsList = async (cookie) => {
return resolve({
url: rolePermissionsListUrl,
responseType: "json",
headers: { "X-CSRF-Header": cookie },
});
};

export const postRolePermissionsList = async (roleData, cookie) => {
return resolve({
method: "post",
url: rolePermissionsListUrl,
responseType: "json",
data: roleData,
headers: { "X-CSRF-Header": cookie },
});
};

export const deleteRolePermissionsList = async (roleData, cookie) => {
return resolve({
method: "delete",
url: rolePermissionsListUrl,
responseType: "json",
data: roleData,
headers: { "X-CSRF-Header": cookie },
});
};
pieperm marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions web-ui/src/api/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export const getAllUserRoles = async (cookie) => {
});
};

export const getCurrentUserRole = async (memberId, cookie) => {
return resolve({
url: `${roleURL}/${memberId}`,
responseType: "json",
headers: { "X-CSRF-Header": cookie },
});
};

pieperm marked this conversation as resolved.
Show resolved Hide resolved
export const removeUserFromRole = async (roleId, memberId, cookie) => {
return resolve({
method: "delete",
Expand Down
1 change: 1 addition & 0 deletions web-ui/src/components/menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const Root = styled('div')(({theme}) => ({

const adminLinks = [
// ["/admin/permissions", "Permissions"],
pieperm marked this conversation as resolved.
Show resolved Hide resolved
["/admin/edit-permissions", "Permissions Roles"],
["/admin/roles", "Roles"],
["/admin/users", "Users"],
["/admin/email", "Send Email"],
Expand Down
5 changes: 5 additions & 0 deletions web-ui/src/components/routes/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BirthdayAnniversaryReportPage from "../../pages/BirthdayAnniversaryReport
import CheckinsPage from "../../pages/CheckinsPage";
import CheckinsReportPage from "../../pages/CheckinsReportPage";
import EditSkillsPage from "../../pages/EditSkillsPage";
import EditPermissionsPage from "../../pages/EditPermissionsPage";
import GroupIcon from "@mui/icons-material/Group";
import GuildsPage from "../../pages/GuildsPage";
import Header from "../header/Header";
Expand Down Expand Up @@ -101,6 +102,10 @@ export default function Routes() {
<Header title="Skills" />
<EditSkillsPage />
</Route>
<Route path="/admin/edit-permissions">
<Header title="Permissions Roles" />
<EditPermissionsPage />
</Route>
<Route path="/checkins-reports">
<Header title="Check-in Report" />
<CheckinsReportPage />
Expand Down
3 changes: 3 additions & 0 deletions web-ui/src/context/actions.js
pieperm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ export const ADD_CHECKIN = "@@check-ins/add_checkin";
export const ADD_GUILD = "@@check-ins/add_guild";
export const ADD_MEMBER_SKILL = "@@check-ins/add_member_skill";
export const ADD_SKILL = "@@check-ins/add-skill";
export const ADD_PERMISSION = "@@check-ins/add-permission";
export const ADD_TEAM = "@@check-ins/add_team";
export const DELETE_MEMBER_PROFILE = "@@check-ins/delete_member_profile";
export const DELETE_MEMBER_SKILL = "@@check-ins/delete_member_skill";
export const DELETE_SKILL = "@@check-ins/delete-skill";
export const DELETE_PERMISSION = "@@check-ins/delete-permission";
export const DELETE_ROLE = "@@check-ins/delete-role";
export const MY_PROFILE_UPDATE = "@@check-ins/update_profile";
export const SET_CSRF = "@@check-ins/update_csrf";
Expand All @@ -21,6 +23,7 @@ export const UPDATE_MEMBER_SKILLS = "@@check-ins/update_member_skills";
export const UPDATE_ROLES = "@@check-ins/update_roles";
export const UPDATE_SKILL = "@@check-ins/update_skill";
export const UPDATE_SKILLS = "@@check-ins/update_skills";
export const UPDATE_PERMISSION = "@@check-ins/update-permission";
export const UPDATE_TEAM_MEMBERS = "@@check-ins/update_team_members";
export const UPDATE_TEAMS = "@@check-ins/update_teams";
export const UPDATE_TERMINATED_MEMBERS =
Expand Down
10 changes: 10 additions & 0 deletions web-ui/src/context/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const selectTeams = (state) => state.teams;
export const selectGuilds = (state) => state.guilds;
export const selectLoading = (state) => state.loading;
export const selectReviewPeriods = (state) => state.reviewPeriods;
export const selectPermissions = (state) => state.permissions;

export const selectTeamsLoading = createSelector (
selectLoading,
Expand Down Expand Up @@ -434,6 +435,15 @@ export const selectMyGuilds = createSelector(
)
);

export const selectMyPermissions = createSelector(
selectCurrentUserId,
selectPermissions,
(id, permissions) =>
permissions?.filter((permission) =>
permission.permissions?.some((member) => member.memberId === id)
)
);

export const selectMyTeams = createSelector(
selectCurrentUserId,
selectTeams,
Expand Down
32 changes: 32 additions & 0 deletions web-ui/src/helpers/checks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Full check for whether an array actually exists or is empty, etc
* @param arr - an array
* @returns a boolean
*/

export const isArrayPresent = (arr) => Array.isArray(arr) && arr.length;

/**
* Check for whether unique object is already in an array and return a boolean.
* @param arr - an array
* @returns a boolean
*/
export const isObjectInArray = (arr, obj) => {
return arr.includes(obj);
};
pieperm marked this conversation as resolved.
Show resolved Hide resolved

/**
* If a parameter is found in an object within an array, return the array with just that object.
* @param arr - an array
* @param value - a value
* @param key - an optional key with which to search
* @returns an array
*/

export function filterObjectByValOrKey(arr, value, key) {
return arr.filter(
key
? (a) => a[key].indexOf(value) > -1
: (a) => Object.keys(a).some((k) => a[k] === value)
);
}
7 changes: 7 additions & 0 deletions web-ui/src/pages/EditPermissionsPage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.edit-permissions-page {
margin: 2rem;
}

.edit-permissions-list {
margin: 1rem;
}
Loading
Loading