Skip to content

Commit

Permalink
feat(UI): Upload permissions page UI and API Implementation done
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna9304 committed Aug 30, 2022
1 parent 615a373 commit d712cf2
Show file tree
Hide file tree
Showing 11 changed files with 530 additions and 4 deletions.
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

0 comments on commit d712cf2

Please sign in to comment.