Skip to content

Commit 615a373

Browse files
Merge pull request #236 from krishna9304/ui/edit-user-page
feature(ui): ui and styling for the `edit user page` Reviewed-by: [email protected] tested-by: [email protected]
2 parents b175625 + d58d734 commit 615a373

File tree

16 files changed

+1075
-5
lines changed

16 files changed

+1075
-5
lines changed

src/Routes.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const GroupCreate = React.lazy(() => import("pages/Admin/Group/Create"));
9393
const DeleteGroup = React.lazy(() => import("pages/Admin/Group/Delete"));
9494
const DeleteUser = React.lazy(() => import("pages/Admin/Users/Delete"));
9595
const AddUser = React.lazy(() => import("pages/Admin/Users/Add"));
96+
const EditUser = React.lazy(() => import("pages/Admin/Users/Edit"));
9697
const AddLicense = React.lazy(() => import("pages/Admin/License/Create"));
9798
const SelectLicense = React.lazy(() =>
9899
import("pages/Admin/License/SelectLicense")
@@ -311,6 +312,11 @@ const Routes = () => {
311312
path={routes.admin.users.add}
312313
component={AddUser}
313314
/>
315+
<AdminLayout
316+
exact
317+
path={routes.admin.users.edit}
318+
component={EditUser}
319+
/>
314320

315321
<AdminLayout
316322
exact

src/api/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import { randomString, getDate } from "shared/helper";
2727
// Function for calling the fetch function for the APIs
2828
import sendRequest from "./sendRequest";
2929

30-
const fetchTokenApi = (username, password) => {
30+
const fetchTokenApi = (username, password, tokenDetails = null) => {
3131
const url = endpoints.auth.tokens();
3232
return sendRequest({
3333
url,
3434
method: "POST",
35-
body: {
35+
body: tokenDetails || {
3636
username,
3737
password,
3838
token_name: randomString(tokenNameLength),

src/api/users.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,40 @@ export const deleteUserApi = (id) => {
7373
},
7474
});
7575
};
76+
77+
// Modifying user PUT request
78+
export const editUserByIdApi = (id, editedUserDetails) => {
79+
const url = endpoints.users.edit(id);
80+
return sendRequest({
81+
url,
82+
method: "PUT",
83+
body: editedUserDetails,
84+
headers: {
85+
Authorization: getToken(),
86+
},
87+
});
88+
};
89+
90+
// Getting user by id
91+
export const getUserByIdAapi = (id) => {
92+
const url = endpoints.users.getSingle(id);
93+
return sendRequest({
94+
url,
95+
method: "GET",
96+
headers: {
97+
Authorization: getToken(),
98+
},
99+
});
100+
};
101+
102+
// Getting REST API Tokens based on token type (active | expired)
103+
export const getTokensApi = (type) => {
104+
const url = endpoints.users.getTokens(type);
105+
return sendRequest({
106+
url,
107+
method: "GET",
108+
headers: {
109+
Authorization: getToken(),
110+
},
111+
});
112+
};

src/components/Header/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ const Header = () => {
275275
Add User
276276
</NavDropdown.Item>
277277
</div>
278+
<div className="bg-secondaryColor text-white font-12">
279+
<NavDropdown.Item
280+
as={Link}
281+
to={routes.admin.users.edit}
282+
>
283+
Edit User Account
284+
</NavDropdown.Item>
285+
</div>
278286
<div className="bg-secondaryColor text-white font-12">
279287
<NavDropdown.Item
280288
as={Link}

src/components/Upload/CommonFields/AccessLevel/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { InputContainer, Tooltip } from "components/Widgets";
2424

2525
function AccessLevel({ accessLevel, handleChange }) {
2626
return (
27-
<div id="upload-access-level" className="mt-1">
27+
<div id="upload-access-level">
2828
<InputContainer
2929
type="radio"
3030
value="private"

src/components/Widgets/Input/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const InputContainer = ({
5757
}
5858
if (type === "select") {
5959
return (
60-
<div className="my-0 py-0">
60+
<div className="my-1 py-0">
6161
{children && (
6262
<label htmlFor={id} className="font-demi">
6363
{children}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Copyright (C) 2022 Krishna Mahato ([email protected])
3+
4+
SPDX-License-Identifier: GPL-2.0
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU General Public License
8+
version 2 as published by the Free Software Foundation.
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License along
15+
with this program; if not, write to the Free Software Foundation, Inc.,
16+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
.modal-container {
19+
height: 100vh;
20+
width: 100vw;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
position: fixed;
25+
top: 0;
26+
left: 0;
27+
background-color: rgba(0, 0, 0, 0.334);
28+
}
29+
30+
.modal-body {
31+
max-width: 400px;
32+
background-color: white;
33+
border-radius: 10px;
34+
display: flex;
35+
justify-content: center;
36+
align-items: center;
37+
flex-direction: column;
38+
padding: 20px;
39+
gap: 20px;
40+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright (C) 2022 Krishna Mahato ([email protected])
3+
4+
SPDX-License-Identifier: GPL-2.0
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU General Public License
8+
version 2 as published by the Free Software Foundation.
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License along
15+
with this program; if not, write to the Free Software Foundation, Inc.,
16+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
import PropTypes from "prop-types";
20+
import React from "react";
21+
import { Button } from "..";
22+
23+
// css
24+
import "./index.css";
25+
26+
const Modal = ({ show, setShow, children }) => {
27+
return (
28+
show && (
29+
<div className="modal-container">
30+
<div className="modal-body">
31+
{children}
32+
<Button
33+
className="bg-light border text-dark"
34+
type="button"
35+
onClick={() => setShow(false)}
36+
>
37+
Close
38+
</Button>
39+
</div>
40+
</div>
41+
)
42+
);
43+
};
44+
45+
Modal.propTypes = {
46+
show: PropTypes.bool.isRequired,
47+
setShow: PropTypes.func.isRequired,
48+
children: PropTypes.element,
49+
};
50+
51+
export default Modal;

src/constants/constants.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export const initialMantainanceFields = {
260260
rmvRepoOldFiles1: false,
261261
rmvRepoOldFiles2: false,
262262
};
263+
263264
export const accessLevels = [
264265
{
265266
id: 0,
@@ -293,9 +294,24 @@ export const accessLevels = [
293294
},
294295
];
295296

297+
export const userStatus = [
298+
{
299+
id: 0,
300+
name: "Active",
301+
disabled: false,
302+
value: "active",
303+
},
304+
{
305+
id: 1,
306+
name: "Inactive",
307+
disabled: false,
308+
value: "inactive",
309+
},
310+
];
311+
296312
export const initialAddUserData = {
297313
name: "",
298-
user_pass: "",
314+
user_pass: null,
299315
description: "",
300316
accessLevel: "",
301317
rootFolderId: 0,

src/constants/endpoints.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const endpoints = {
4242
getSingle: (userId) => `${apiUrl}/users/${userId}`,
4343
delete: (userId) => `${apiUrl}/users/${userId}`,
4444
add: () => `${apiUrl}/users`,
45+
edit: (userId) => `${apiUrl}/users/${userId}`,
46+
createToken: () => `${apiUrl}/users/tokens`,
47+
getTokens: (type) => `${apiUrl}/users/tokens/${type}`,
4548
},
4649
folders: {
4750
getAll: () => `${apiUrl}/folders`,

0 commit comments

Comments
 (0)