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

feat(UI): Upload permissions page UI and API Implementation done #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ const DeleteGroup = React.lazy(() => import("pages/Admin/Group/Delete"));
const DeleteUser = React.lazy(() => import("pages/Admin/Users/Delete"));
const AddUser = React.lazy(() => import("pages/Admin/Users/Add"));
const EditUser = React.lazy(() => import("pages/Admin/Users/Edit"));
const UploadPermissions = React.lazy(() =>
import("pages/Admin/uploadPermissions")
);
const AddLicense = React.lazy(() => import("pages/Admin/License/Create"));
const SelectLicense = React.lazy(() =>
import("pages/Admin/License/SelectLicense")
Expand Down Expand Up @@ -302,6 +305,11 @@ const Routes = () => {
path={routes.admin.license.selectLicense}
component={SelectLicense}
/>
<AdminLayout
exact
path={routes.admin.uploadPermissions}
component={UploadPermissions}
/>
<AdminLayout
exact
path={routes.admin.users.delete}
Expand Down
25 changes: 25 additions & 0 deletions src/api/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,31 @@ export const getUploadSummaryApi = (uploadId) => {
});
};

// Getting all groups with permissions based on upload ID
export const getGroupsWithPermissionsApi = (uploadId) => {
const url = endpoints.upload.getGroupsWithPermissions(uploadId);
return sendRequest({
url,
method: "GET",
headers: {
Authorization: getToken(),
},
});
};

// change permissions for a upload for different groups
export const changeUploadPermissionsApi = (payload) => {
const url = endpoints.upload.uploadPermissions(payload.uploadId);
return sendRequest({
url,
method: "PUT",
body: payload,
headers: {
Authorization: getToken(),
},
});
};

// Getting a Upload License
export const getUploadLicenseApi = (uploadId, agent) => {
const url = endpoints.upload.getLicense(uploadId);
Expand Down
6 changes: 6 additions & 0 deletions src/assets/images/loader.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ const Header = () => {
</NavDropdown.Item>
</div>
</DropdownButton>
<NavDropdown.Item
as={Link}
to={routes.admin.uploadPermissions}
>
Upload Permissions
</NavDropdown.Item>
<DropdownButton
variant=""
drop="right"
Expand Down
10 changes: 6 additions & 4 deletions src/components/Widgets/Input/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ const InputContainer = ({
return (
<div className="my-1 py-0">
{children && (
<label htmlFor={id} className="font-demi">
{children}
</label>
<>
<label htmlFor={id} className="font-demi">
{children}
</label>
&emsp;
</>
)}
&emsp;
<select
name={name}
className={
Expand Down
5 changes: 5 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,35 @@ export const accessLevels = [
id: 0,
name: "None (very basic, no database access)",
disabled: false,
permId: 0,
value: "none",
},
{
id: 1,
name: "Read-only (read, but no writes or downloads)",
disabled: false,
permId: 1,
value: "read_only",
},
{
id: 2,
name: "Read-Write (read, download, or edit information)",
disabled: false,
permId: 3,
value: "read_write",
},
{
id: 3,
name: "Clearing Administrator (read, download, edit information and edit decisions)",
disabled: false,
permId: 5,
value: "clearing_admin",
},
{
id: 4,
name: "Full Administrator (all access including adding and deleting users)",
disabled: false,
permId: 10,
value: "admin",
},
];
Expand Down
4 changes: 4 additions & 0 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const endpoints = {
getId: (uploadId) => `${apiUrl}/uploads/${uploadId}`,
getSummary: (uploadId) => `${apiUrl}/uploads/${uploadId}/summary`,
getLicense: (uploadId) => `${apiUrl}/uploads/${uploadId}/licenses`,
getGroupsWithPermissions: (uploadId) =>
`${apiUrl}/uploads/${uploadId}/perm-groups`,
uploadPermissions: (uploadId) =>
`${apiUrl}/uploads/${uploadId}/permissions`,
},
browse: {
get: () => `${apiUrl}/uploads`,
Expand Down
1 change: 1 addition & 0 deletions src/constants/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const routes = {
licenseCSV: "/licenseCSV/fossology-license-export.csv",
},
mantainance: "/admin/mantainance",
uploadPermissions: "/admin/upload-permissions",
},
browseUploads: {
softwareHeritage: "/browse/softwareHeritage",
Expand Down
Loading