mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-22 16:38:21 +00:00
Move users & permissions to a new page from modal
This commit is contained in:
parent
a7c9140ba2
commit
2e5f8eab75
5 changed files with 157 additions and 120 deletions
|
|
@ -10,6 +10,7 @@ import { Editor, Viewer } from '@/Editor';
|
|||
import '@/_styles/theme.scss';
|
||||
import { ToastContainer, toast } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { ManageOrgUsers } from '@/ManageOrgUsers';
|
||||
|
||||
class App extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -45,6 +46,7 @@ class App extends React.Component {
|
|||
<PrivateRoute exact path="/apps/:id" component={Editor} />
|
||||
<PrivateRoute exact path="/applications/:id" component={Viewer} />
|
||||
<PrivateRoute exact path="/oauth2/authorize" component={Authorize} />
|
||||
<PrivateRoute exact path="/users" component={ManageOrgUsers} />
|
||||
|
||||
</div>
|
||||
</Router>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import React from 'react';
|
||||
import { appService, authenticationService } from '@/_services';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ManageOrgUsers } from './ManageOrgUsers';
|
||||
import Skeleton from 'react-loading-skeleton';
|
||||
|
||||
class HomePage extends React.Component {
|
||||
|
|
@ -47,7 +46,9 @@ class HomePage extends React.Component {
|
|||
<div className="navbar-nav flex-row order-md-last">
|
||||
<div class="nav-item d-none d-md-flex me-3">
|
||||
<div class="btn-list">
|
||||
<ManageOrgUsers/>
|
||||
<Link to={`/users`}>
|
||||
<button className="btn btn-sm" onClick={() => this.setState({ showModal: true })}> Manage Users</button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="nav-item dropdown d-none d-md-flex me-3">
|
||||
|
|
|
|||
|
|
@ -1,118 +0,0 @@
|
|||
import React from 'react';
|
||||
import { organizationService } from '@/_services';
|
||||
import Modal from 'react-bootstrap/Modal';
|
||||
import Button from 'react-bootstrap/Button';
|
||||
import { toast } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import Skeleton from 'react-loading-skeleton';
|
||||
|
||||
class ManageOrgUsers extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
showModal: false,
|
||||
appId: props.appId,
|
||||
isLoading: true,
|
||||
addingUser: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
const appId = this.props.appId;
|
||||
|
||||
organizationService.getUsers(appId).then(data => this.setState({
|
||||
users: data.users,
|
||||
isLoading: false,
|
||||
}));
|
||||
|
||||
this.setState({ appId });
|
||||
}
|
||||
|
||||
hideModal = () => {
|
||||
this.setState({
|
||||
showModal: false
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { showModal, isLoading, users } = this.state;
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
{!showModal && <button className="btn btn-sm" onClick={() => this.setState({ showModal: true })}> Manage Users</button>}
|
||||
|
||||
<Modal
|
||||
show={this.state.showModal}
|
||||
size="lg"
|
||||
backdrop="static"
|
||||
centered={true}
|
||||
keyboard={true}>
|
||||
|
||||
<Modal.Header>
|
||||
<Modal.Title>
|
||||
Users and permissions
|
||||
</Modal.Title>
|
||||
<div>
|
||||
<button className="btn btn-primary mx-2">Add User</button>
|
||||
|
||||
<Button variant="light" onClick={() => this.hideModal()}>
|
||||
x
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
</Modal.Header>
|
||||
|
||||
<Modal.Body>
|
||||
{isLoading ?
|
||||
<div style={{width: '100%'}} className="p-5">
|
||||
<Skeleton count={5}/>
|
||||
</div>
|
||||
:
|
||||
<div class="table-responsive">
|
||||
<table
|
||||
class="table table-vcenter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th class="w-1"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{users.map((user) =>
|
||||
<tr>
|
||||
<td >{user.name}</td>
|
||||
<td class="text-muted" >
|
||||
<a href="#" class="text-reset">{user.email}</a>
|
||||
</td>
|
||||
<td class="text-muted" >
|
||||
{user.role}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
</Modal.Body>
|
||||
|
||||
<Modal.Footer>
|
||||
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export { ManageOrgUsers };
|
||||
151
frontend/src/ManageOrgUsers/ManageOrgUsers.jsx
Normal file
151
frontend/src/ManageOrgUsers/ManageOrgUsers.jsx
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
import React from 'react';
|
||||
import { organizationService } from '@/_services';
|
||||
import { authenticationService } from '@/_services';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Skeleton from 'react-loading-skeleton';
|
||||
|
||||
class ManageOrgUsers extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
currentUser: authenticationService.currentUserValue,
|
||||
showModal: false,
|
||||
isLoading: true,
|
||||
addingUser: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
organizationService.getUsers(null).then(data => this.setState({
|
||||
users: data.users,
|
||||
isLoading: false,
|
||||
}));
|
||||
}
|
||||
|
||||
hideModal = () => {
|
||||
this.setState({
|
||||
showModal: false
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { isLoading, users } = this.state;
|
||||
|
||||
return (
|
||||
<div className="wrapper">
|
||||
<header className="navbar navbar-expand-md navbar-light d-print-none">
|
||||
<div className="container-xl">
|
||||
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-menu">
|
||||
<span className="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<h1 className="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
|
||||
<a href=".">
|
||||
<img src="/images/logo.svg" width="110" height="32" className="navbar-brand-image"/>
|
||||
</a>
|
||||
</h1>
|
||||
<div className="navbar-nav flex-row order-md-last">
|
||||
<div class="nav-item d-none d-md-flex me-3">
|
||||
<div class="btn-list">
|
||||
<Link to={`/users`}>
|
||||
<button className="btn btn-sm" onClick={() => this.setState({ showModal: true })}> Manage Users</button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="nav-item dropdown d-none d-md-flex me-3">
|
||||
|
||||
<div className="dropdown-menu dropdown-menu-end dropdown-menu-card">
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ad amet consectetur exercitationem fugiat in ipsa ipsum, natus odio quidem quod repudiandae sapiente. Amet debitis et magni maxime necessitatibus ullam.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="nav-item dropdown">
|
||||
<a href="#" className="nav-link d-flex lh-1 text-reset p-0" data-bs-toggle="dropdown" aria-label="Open user menu">
|
||||
<div className="d-none d-xl-block ps-2">
|
||||
<div>{this.state.currentUser.first_name}</div>
|
||||
<div className="mt-1 small text-muted">Admin</div>
|
||||
</div>
|
||||
</a>
|
||||
<div className="dropdown-menu dropdown-menu-end dropdown-menu-arrow">
|
||||
<a href="#" className="dropdown-item">Settings</a>
|
||||
<a href="#" className="dropdown-item">Logout</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="page-wrapper">
|
||||
<div className="container-xl">
|
||||
<div className="page-header d-print-none">
|
||||
<div className="row align-items-center">
|
||||
<div className="col">
|
||||
<div className="page-pretitle">
|
||||
{/* Dashboard */}
|
||||
</div>
|
||||
<h2 className="page-title">
|
||||
Users & Permissions
|
||||
</h2>
|
||||
</div>
|
||||
<div className="col-auto ms-auto d-print-none">
|
||||
<div className="btn btn-primary">
|
||||
Add User
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="page-body">
|
||||
<div className="container-xl">
|
||||
{isLoading ?
|
||||
<div style={{width: '100%'}} className="p-5">
|
||||
<Skeleton count={5}/>
|
||||
</div>
|
||||
:
|
||||
<div className="card">
|
||||
<div class="card-table table-responsive table-bordered">
|
||||
<table
|
||||
class="table table-vcenter">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th class="w-1"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{users.map((user) =>
|
||||
<tr>
|
||||
<td >{user.name}</td>
|
||||
<td class="text-muted" >
|
||||
<a href="#" class="text-reset">{user.email}</a>
|
||||
</td>
|
||||
<td class="text-muted" >
|
||||
{user.role}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#">Remove</a>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export { ManageOrgUsers };
|
||||
1
frontend/src/ManageOrgUsers/index.js
Normal file
1
frontend/src/ManageOrgUsers/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './ManageOrgUsers';
|
||||
Loading…
Reference in a new issue