Skip to content

Commit

Permalink
Merge pull request #229 from krishna9304/ui/add-user-page
Browse files Browse the repository at this point in the history
feature(ui): ui and formdata implementation for the `add user` page

Reviewed-by: mishra.gaurav@siemens.com
Tested-by: shaheem.azmal@siemens.com
  • Loading branch information
shaheemazmalmmd authored Aug 25, 2022
2 parents 133c1af + 62a68ec commit 4bf185e
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ 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 AddUser = React.lazy(() => import("pages/Admin/Users/Add"));
const AddLicense = React.lazy(() => import("pages/Admin/License/Create"));
const SelectLicense = React.lazy(() =>
import("pages/Admin/License/SelectLicense")
Expand Down Expand Up @@ -299,6 +300,11 @@ const Routes = () => {
path={routes.admin.users.delete}
component={DeleteUser}
/>
<AdminLayout
exact
path={routes.admin.users.add}
component={AddUser}
/>

<AdminLayout
exact
Expand Down
13 changes: 13 additions & 0 deletions src/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ export const getAllUsersApi = () => {
});
};

// Api call to create a new user
export const addUserApi = (userData) => {
const url = endpoints.users.add();
return sendRequest({
url,
method: "POST",
headers: {
Authorization: getToken(),
},
body: userData,
});
};

// Deleting the user info
export const deleteUserApi = (id) => {
const url = endpoints.users.delete(id);
Expand Down
7 changes: 6 additions & 1 deletion src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,12 @@ const Header = () => {
title="Users"
className="font-regular dropdown-item-bottom w-100"
>
<div className="bg-secondaryColor text-white font-12 py-2">
<div className="bg-secondaryColor text-white font-12">
<NavDropdown.Item as={Link} to={routes.admin.users.add}>
Add User
</NavDropdown.Item>
</div>
<div className="bg-secondaryColor text-white font-12">
<NavDropdown.Item
as={Link}
to={routes.admin.users.delete}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Upload/CommonFields/AccessLevel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { InputContainer, Tooltip } from "components/Widgets";

function AccessLevel({ accessLevel, handleChange }) {
return (
<div id="upload-access-level" className="mt-4">
<div id="upload-access-level" className="mt-1">
<InputContainer
type="radio"
value="private"
Expand Down
10 changes: 5 additions & 5 deletions src/components/Upload/CommonFields/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ CommonFields.propTypes = {
nomos: PropTypes.bool.isRequired,
ojo: PropTypes.bool.isRequired,
package: PropTypes.bool.isRequired,
}).isRequired,
}),
decider: PropTypes.shape({
nomosMonk: PropTypes.bool.isRequired,
bulkReused: PropTypes.bool.isRequired,
newScanner: PropTypes.bool.isRequired,
ojoDecider: PropTypes.bool.isRequired,
}).isRequired,
}),
reuse: PropTypes.shape({
reuseUpload: PropTypes.number.isRequired,
reuseGroup: PropTypes.string.isRequired,
reuseMain: PropTypes.bool.isRequired,
reuseEnhanced: PropTypes.bool.isRequired,
reuseReport: PropTypes.bool.isRequired,
reuseCopyright: PropTypes.bool.isRequired,
}).isRequired,
handleChange: PropTypes.func.isRequired,
handleScanChange: PropTypes.func.isRequired,
}),
handleChange: PropTypes.func,
handleScanChange: PropTypes.func,
};

export default CommonFields;
80 changes: 80 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,83 @@ export const initialMantainanceFields = {
rmvRepoOldFiles1: false,
rmvRepoOldFiles2: false,
};
export const accessLevels = [
{
id: 0,
name: "None (very basic, no database access)",
disabled: false,
value: "none",
},
{
id: 1,
name: "Read-only (read, but no writes or downloads)",
disabled: false,
value: "read_only",
},
{
id: 2,
name: "Read-Write (read, download, or edit information)",
disabled: false,
value: "read_write",
},
{
id: 3,
name: "Clearing Administrator (read, download, edit information and edit decisions)",
disabled: false,
value: "clearing_admin",
},
{
id: 4,
name: "Full Administrator (all access including adding and deleting users)",
disabled: false,
value: "admin",
},
];

export const initialAddUserData = {
name: "",
user_pass: "",
description: "",
accessLevel: "",
rootFolderId: 0,
emailNotification: true,
email: "",
defaultVisibility: "public",
defaultBucketpool: 2,
agents: {
mime: false,
monk: false,
ojo: false,
bucket: false,
copyright_email_author: false,
ecc: false,
keyword: false,
nomos: false,
package: false,
reso: false,
heritage: false,
},
};

export const bucketPool = [
{
id: 0,
name: "GPL Demo bucket pool, v1",
disabled: false,
},
];

export const agents = {
bucket: "Bucket Analysis",
copyright_email_author: "Copyright/Email/URL/Author Analysis",
ecc: "ECC Analysis, scanning for text fragments potentially relevant for export control",
keyword: "Keyword Analysis",
mime: "MIME-type Analysis (Determine mimetype of every file. Not needed for licenses or buckets)",
monk: "Monk License Analysis, scanning for licenses performing a text comparison",
nomos:
"Nomos License Analysis, scanning for licenses using regular expressions",
ojo: "Ojo License Analysis, scanning for licenses using SPDX-License-Identifier",
package: "Package Analysis (Parse package headers)",
reso: "REUSE.Software Analysis (forces *Ojo License Analysis*)",
heritage: "Software Heritage Analysis",
};
1 change: 1 addition & 0 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const endpoints = {
getAll: () => `${apiUrl}/users`,
getSingle: (userId) => `${apiUrl}/users/${userId}`,
delete: (userId) => `${apiUrl}/users/${userId}`,
add: () => `${apiUrl}/users`,
},
folders: {
getAll: () => `${apiUrl}/folders`,
Expand Down
1 change: 1 addition & 0 deletions src/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const messages = {
noPageLong: "We could not find the page you were searching for",
groupCreate: "Successfully created the group",
deletedUser: "Successfully deleted the user",
addedUser: "Successfully added the user",
confirmDeletion: "Deletion not confirmed",
loading: "Loading...",
jobsAdded: "Your jobs have been added to job queue",
Expand Down
1 change: 1 addition & 0 deletions src/constants/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const routes = {
delete: "/admin/group/delete",
},
users: {
add: "/admin/users/add",
delete: "/admin/users/delete",
},
license: {
Expand Down
Loading

0 comments on commit 4bf185e

Please sign in to comment.