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 all 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
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 All @@ -36,6 +38,8 @@ public class Permission {
@Schema(description = "A more verbose description of the permission to be displayed on UI")
private String description;

public Permission() {}

public Permission(UUID id, String permission, @Nullable String description) {
this.id = id;
this.permission = permission;
Expand All @@ -59,13 +63,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) {
public void setDescription(@Nullable String description) {
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 postRolePermission = async (roleData, cookie) => {
return resolve({
method: "post",
url: rolePermissionsListUrl,
responseType: "json",
data: roleData,
headers: { "X-CSRF-Header": cookie },
});
};

export const deleteRolePermission = async (roleData, cookie) => {
return resolve({
method: "delete",
url: rolePermissionsListUrl,
responseType: "json",
data: roleData,
headers: { "X-CSRF-Header": cookie },
});
};
2 changes: 1 addition & 1 deletion web-ui/src/components/menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Root = styled('div')(({theme}) => ({
}));

const adminLinks = [
// ["/admin/permissions", "Permissions"],
["/admin/permissions", "Permissions"],
["/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/PermissionsPage";
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/permissions">
<Header title="Permissions" />
<EditPermissionsPage />
</Route>
<Route path="/checkins-reports">
<Header title="Check-in Report" />
<CheckinsReportPage />
Expand Down
7 changes: 7 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 All @@ -40,6 +41,12 @@ export const selectIsAdmin = createSelector(
userProfile && userProfile.role && userProfile.role.includes("ADMIN")
);

export const selectHasPermissionAssignmentPermission = createSelector(
selectUserProfile,
(userProfile) =>
userProfile && userProfile.role && userProfile.permissions.some((p) => p?.permission?.includes("CAN_ASSIGN_ROLE_PERMISSIONS"))
);

export const selectHasReportPermission = createSelector(
selectUserProfile,
(userProfile) =>
Expand Down
23 changes: 23 additions & 0 deletions web-ui/src/helpers/checks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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;

/**
* 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