-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
357 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| export function AccessRequest({ users, roles, onDeleteUser, onChangeUserRole }) { | ||
|
|
||
| return ( | ||
| <> | ||
| {(!users || !users.length) ? | ||
| <> | ||
| <div className="d-flex justify-content-center"> | ||
| <div className="w-25 alert alert-info m-3"> | ||
| <p className="text-center">There are no new user requests at this time.</p> | ||
| </div> | ||
| </div> | ||
| </> | ||
| : | ||
| users.map((user, i) => ( | ||
| <div key={i}> | ||
| <div className="p-3 bg-light border-light rounded m-3"> | ||
| <div className="row align-items-center"> | ||
| <div className="col-10"> | ||
| <div className="row"> | ||
| <div className="col text-right font-weight-bold"> | ||
| <Translate value="label.user-id">UserId</Translate> | ||
| </div> | ||
| <div className="col">{ user.username }</div> | ||
| <div className="col text-right font-weight-bold"> | ||
| <Translate value="label.email">Email</Translate> | ||
| </div> | ||
| <div className="col">{ user.emailAddress }</div> | ||
| </div> | ||
| <div className="w-100 my-1"></div> | ||
| <div className="row"> | ||
| <div className="col text-right font-weight-bold" > | ||
| <Translate value="label.name">Name</Translate> | ||
| </div> | ||
| <div className="col">{ user.firstName } { user.lastName }</div> | ||
| <label htmlFor={`role-${i}`} className="d-block col text-right font-weight-bold" > | ||
| <Translate value="label.role">Role</Translate> | ||
| </label> | ||
| <div className="col"> | ||
| <select id={`role-${i}`} name={user.username} value={user.role} className="form-control form-control-sm" | ||
| disablevalidation="true" onChange={(event) => onChangeUserRole(user, event.target.value)}> | ||
| {roles.map((role, ridx) => | ||
| <option value={role} key={ridx}>{ role }</option> | ||
| )} | ||
| </select> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="col-2 text-right"> | ||
| <button className="btn btn-danger btn-sm" onClick={() => onDeleteUser(user.username)}> | ||
| <i className="fa fa-trash fa-lg"></i> | ||
| | ||
| <span > | ||
| <Translate value="label.delete-request">Delete Request</Translate> | ||
| </span> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ))} | ||
| </> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import { faTrash } from '@fortawesome/free-solid-svg-icons'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
| import { useCurrentUser } from '../../core/user/UserContext'; | ||
|
|
||
| export default function UserMaintenance({ users, roles, onDeleteUser, onChangeUserRole }) { | ||
|
|
||
| const currentUser = useCurrentUser(); | ||
|
|
||
| return ( | ||
| <div className="table-responsive mt-3 provider-list"> | ||
| <table className="table table-striped w-100 table-hover"> | ||
| <thead> | ||
| <tr> | ||
| <th scope="col"><Translate value="label.user-id">UserId</Translate></th> | ||
| <th scope="col" ><Translate value="label.name">Name</Translate></th> | ||
| <th scope="col"><Translate value="label.email">Email</Translate></th> | ||
| <th scope="col" ><Translate value="label.role">Role</Translate></th> | ||
| <th scope="col"><Translate value="label.delete">Delete?</Translate></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {users.map((user, idx) => | ||
| <tr key={idx}> | ||
| <th>{user.username}</th> | ||
| <td>{user.firstName} {user.lastName}</td> | ||
| <td>{user.emailAddress}</td> | ||
| <td> | ||
| <label htmlFor={`role-${user.username}`} className="sr-only"><Translate value="action.user-role">User role</Translate></label> | ||
| <select | ||
| id={`role-${user.username}`} | ||
| name={`role-${user.username}`} | ||
| model="user.role" | ||
| className="form-control" | ||
| onChange={(event) => onChangeUserRole(user, event.target.value)} | ||
| value={user.role} | ||
| disabled={currentUser.username === user.username} | ||
| disablevalidation="true"> | ||
| {roles.map((role, ridx) => ( | ||
| <option key={role} value={role}>{role}</option> | ||
| ))} | ||
| </select> | ||
| </td> | ||
| <td> | ||
| {currentUser.username !== user.username && | ||
| <button className="btn btn-link text-danger" onClick={() => onDeleteUser(user.username)}> | ||
| <span className="sr-only"> | ||
| <Translate value="label.delete-user">Delete User</Translate> | ||
| </span> | ||
| <FontAwesomeIcon icon={faTrash} /> | ||
| </button> | ||
| } | ||
| </td> | ||
| </tr> | ||
| )} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react'; | ||
| import SourceList from '../../metadata/domain/source/component/SourceList'; | ||
| import { useMetadataEntity } from '../../metadata/hooks/api'; | ||
|
|
||
| export function SourcesActions ({sources, reloadSources}) { | ||
|
|
||
| const { del, response } = useMetadataEntity('source', { | ||
| cachePolicy: 'no-cache' | ||
| }); | ||
|
|
||
| async function deleteSource(id) { | ||
| await del(`/${id}`); | ||
| if (response.ok) { | ||
| reloadSources(); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <SourceList entities={sources} onDelete={ deleteSource } /> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from 'react'; | ||
| import { AccessRequest } from '../../admin/component/AccessRequest'; | ||
| import UserManagement from '../../admin/container/UserManagement'; | ||
|
|
||
| export function UserActions({ users, reloadUsers }) { | ||
| return ( | ||
| <UserManagement users={users} reload={reloadUsers}> | ||
| {(u, roles, onChangeUserRole, onDeleteUser) => | ||
| <AccessRequest users={u} roles={roles} onChangeUserRole={onChangeUserRole} onDeleteUser={onDeleteUser} />} | ||
| </UserManagement> | ||
| ); | ||
| } | ||
|
|
||
| export default UserActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
| import { Redirect, Route } from 'react-router'; | ||
|
|
||
| import { useIsAdmin } from '../user/UserContext'; | ||
|
|
||
| export function AdminRoute({ children, ...rest }) { | ||
| const isAdmin = useIsAdmin(); | ||
| return ( | ||
| <Route | ||
| {...rest} | ||
| render={({ location }) => | ||
| isAdmin ? ( | ||
| children | ||
| ) : ( | ||
| <Redirect | ||
| to={{ | ||
| pathname: "/dashboard", | ||
| state: { from: location } | ||
| }} | ||
| /> | ||
| ) | ||
| } | ||
| /> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.