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 13, 2022
1 parent 133c1af commit 8eaa2fc
Show file tree
Hide file tree
Showing 11 changed files with 574 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 @@ -91,6 +91,9 @@ const UploadDelete = React.lazy(() => import("pages/Organize/Uploads/Delete"));
// Admin Pages
const GroupCreate = React.lazy(() => import("pages/Admin/Group/Create"));
const DeleteUser = React.lazy(() => import("pages/Admin/Users/Delete"));
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 @@ -294,6 +297,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 @@ -261,6 +261,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-0 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
38 changes: 38 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,41 @@ export const initialMantainanceFields = {
rmvRepoOldFiles1: false,
rmvRepoOldFiles2: false,
};

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",
},
];
4 changes: 4 additions & 0 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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 @@ -77,6 +77,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 8eaa2fc

Please sign in to comment.