Get basic modal view for editing/creating a new subuser working
This commit is contained in:
parent
8d52e2e1a7
commit
51c5cf4dbb
13 changed files with 293 additions and 186 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Client;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Transformers\Api\Client\ServerTransformer;
|
||||
|
@ -72,16 +71,10 @@ class ClientController extends ClientApiController
|
|||
*/
|
||||
public function permissions()
|
||||
{
|
||||
$permissions = Permission::permissions()->map(function ($values, $key) {
|
||||
return Collection::make($values)->map(function ($permission) use ($key) {
|
||||
return $key . '.' . $permission;
|
||||
})->values()->toArray();
|
||||
})->flatten();
|
||||
|
||||
return [
|
||||
'object' => 'system_permissions',
|
||||
'attributes' => [
|
||||
'permissions' => $permissions,
|
||||
'permissions' => Permission::permissions(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -98,105 +98,90 @@ class Permission extends Validable
|
|||
*/
|
||||
protected static $permissions = [
|
||||
'websocket' => [
|
||||
// Allows the user to connect to the server websocket, this will give them
|
||||
// access to view the console output as well as realtime server stats (CPU
|
||||
// and Memory usage).
|
||||
'*',
|
||||
'description' => 'Allows the user to connect to the server websocket, giving them access to view console output and realtime server stats.',
|
||||
'keys' => [
|
||||
'*' => 'Gives user full read access to the websocket.',
|
||||
],
|
||||
],
|
||||
|
||||
'control' => [
|
||||
// Allows the user to send data to the server console process. A user with this
|
||||
// permission will not be able to stop the server directly by issuing the specified
|
||||
// stop command for the Egg, however depending on plugins and server configuration
|
||||
// they may still be able to control the server power state.
|
||||
'console', // power.send-command
|
||||
|
||||
// Allows the user to start/stop/restart/kill the server process.
|
||||
'start', // power.power-start
|
||||
'stop', // power.power-stop
|
||||
'restart', // power.power-restart
|
||||
'kill', // power.power-kill
|
||||
'description' => 'Permissions that control a user\'s ability to control the power state of a server, or send commands.',
|
||||
'keys' => [
|
||||
'console' => 'Allows a user to send commands to the server instance via the console.',
|
||||
'start' => 'Allows a user to start the server if it is stopped.',
|
||||
'stop' => 'Allows a user to stop a server if it is running.',
|
||||
'restart' => 'Allows a user to perform a server restart. This allows them to start the server if it is offline, but not put the server in a completely stopped state.',
|
||||
'kill' => 'Allows a user to terminate a server process.',
|
||||
],
|
||||
],
|
||||
|
||||
'user' => [
|
||||
// Allows a user to create a new user assigned to the server. They will not be able
|
||||
// to assign any permissions they do not already have on their account as well.
|
||||
'create', // subuser.create-subuser
|
||||
'read', // subuser.list-subusers, subuser.view-subuser
|
||||
'update', // subuser.edit-subuser
|
||||
'delete', // subuser.delete-subuser
|
||||
'description' => 'Permissions that allow a user to manage other subusers on a server. They will never be able to edit their own account, or assign permissions they do not have themselves.',
|
||||
'keys' => [
|
||||
'create' => 'Allows a user to create new subusers for the server.',
|
||||
'read' => 'Allows the user to view subusers and their permissions for the server.',
|
||||
'update' => 'Allows a user to modify other subusers.',
|
||||
'delete' => 'Allows a user to delete a subuser from the server.',
|
||||
],
|
||||
],
|
||||
|
||||
'file' => [
|
||||
// Allows a user to create additional files and folders either via the Panel,
|
||||
// or via a direct upload.
|
||||
'create', // files.create-files, files.upload-files, files.copy-files, files.move-files
|
||||
|
||||
// Allows a user to view the contents of a directory as well as read the contents
|
||||
// of a given file. A user with this permission will be able to download files
|
||||
// as well.
|
||||
'read', // files.list-files, files.download-files
|
||||
|
||||
// Allows a user to update the contents of an existing file or directory.
|
||||
'update', // files.edit-files, files.save-files
|
||||
|
||||
// Allows a user to delete a file or directory.
|
||||
'delete', // files.delete-files
|
||||
|
||||
// Allows a user to archive the contents of a directory as well as decompress existing
|
||||
// archives on the system.
|
||||
'archive', // files.compress-files, files.decompress-files
|
||||
|
||||
// Allows the user to connect and manage server files using their account
|
||||
// credentials and a SFTP client.
|
||||
'sftp', // files.access-sftp
|
||||
'description' => 'Permissions that control a user\'s ability to modify the filesystem for this server.',
|
||||
'keys' => [
|
||||
'create' => 'Allows a user to create additional files and folders via the Panel or direct upload.',
|
||||
'read' => 'Allows a user to view the contents of a directory and read the contents of a file. Users with this permission can also download files.',
|
||||
'update' => 'Allows a user to update the contents of an existing file or directory.',
|
||||
'delete' => 'Allows a user to delete files or directories.',
|
||||
'archive' => 'Allows a user to archive the contents of a directory as well as decompress existing archives on the system.',
|
||||
'sftp' => 'Allows a user to connect to SFTP and manage server files using the other assigned file permissions.',
|
||||
],
|
||||
],
|
||||
|
||||
// Controls permissions for editing or viewing a server's allocations.
|
||||
'allocation' => [
|
||||
'read', // server.view-allocations
|
||||
'update', // server.edit-allocation
|
||||
'description' => 'Permissions that control a user\'s ability to modify the port allocations for this server.',
|
||||
'keys' => [
|
||||
'read' => 'Allows a user to view the allocations assigned to this server.',
|
||||
'update' => 'Allows a user to modify the allocations assigned to this server.',
|
||||
],
|
||||
],
|
||||
|
||||
// Controls permissions for editing or viewing a server's startup parameters.
|
||||
'startup' => [
|
||||
'read', // server.view-startup
|
||||
'update', // server.edit-startup
|
||||
'description' => 'Permissions that control a user\'s ability to view this server\'s startup parameters.',
|
||||
'keys' => [
|
||||
'read' => '',
|
||||
'update' => '',
|
||||
],
|
||||
],
|
||||
|
||||
'database' => [
|
||||
// Allows a user to create a new database for a server.
|
||||
'create', // database.create-database
|
||||
|
||||
// Allows a user to view the databases associated with the server. If they do not also
|
||||
// have the view_password permission they will only be able to see the connection address
|
||||
// and the name of the user.
|
||||
'read', // database.view-databases
|
||||
|
||||
// Allows a user to rotate the password on a database instance. If the user does not
|
||||
// alow have the view_password permission they will not be able to see the updated password
|
||||
// anywhere, but it will still be rotated.
|
||||
'update', // database.reset-db-password
|
||||
|
||||
// Allows a user to delete a database instance.
|
||||
'delete', // database.delete-database
|
||||
|
||||
// Allows a user to view the password associated with a database instance for the
|
||||
// server. Note that a user without this permission may still be able to access these
|
||||
// credentials by viewing files or the console.
|
||||
'view_password', // database.reset-db-password
|
||||
'description' => 'Permissions that control a user\'s access to the database management for this server.',
|
||||
'keys' => [
|
||||
'create' => 'Allows a user to create a new database for this server.',
|
||||
'read' => 'Allows a user to view the database associated with this server.',
|
||||
'update' => 'Allows a user to rotate the password on a database instance. If the user does not have the view_password permission they will not see the updated password.',
|
||||
'delete' => 'Allows a user to remove a database instance from this server.',
|
||||
'view_password' => 'Allows a user to view the password associated with a database instance for this server.',
|
||||
],
|
||||
],
|
||||
|
||||
'schedule' => [
|
||||
'create', // task.create-schedule
|
||||
'read', // task.view-schedule, task.list-schedules
|
||||
'update', // task.edit-schedule, task.queue-schedule, task.toggle-schedule
|
||||
'delete', // task.delete-schedule
|
||||
'description' => 'Permissions that control a user\'s access to the schedule management for this server.',
|
||||
'keys' => [
|
||||
'create' => '', // task.create-schedule
|
||||
'read' => '', // task.view-schedule, task.list-schedules
|
||||
'update' => '', // task.edit-schedule, task.queue-schedule, task.toggle-schedule
|
||||
'delete' => '', // task.delete-schedule
|
||||
],
|
||||
],
|
||||
|
||||
'settings' => [
|
||||
'rename',
|
||||
'reinstall',
|
||||
'description' => 'Permissions that control a user\'s access to the settings for this server.',
|
||||
'keys' => [
|
||||
'rename' => '',
|
||||
'reinstall' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { SubuserPermission } from '@/state/server/subusers';
|
||||
import { PanelPermissions } from '@/state/permissions';
|
||||
import http from '@/api/http';
|
||||
|
||||
export default (): Promise<SubuserPermission[]> => {
|
||||
export default (): Promise<PanelPermissions> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(`/api/client/permissions`)
|
||||
.then(({ data }) => resolve(data.attributes.permissions))
|
||||
|
|
|
@ -95,7 +95,7 @@ export default () => {
|
|||
>
|
||||
<FontAwesomeIcon
|
||||
icon={faTrashAlt}
|
||||
className={'text-neutral-400 hover:text-red-400 transition-color duration-150'}
|
||||
className={'text-neutral-400 hover:text-red-400 transition-colors duration-150'}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||
|
||||
type Props = Readonly<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
||||
title?: string;
|
||||
borderColor?: string;
|
||||
showFlashes?: string | boolean;
|
||||
showLoadingOverlay?: boolean;
|
||||
}>;
|
||||
|
||||
const ContentBox = ({ title, borderColor, showFlashes, children, ...props }: Props) => (
|
||||
const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => (
|
||||
<div {...props}>
|
||||
{title && <h2 className={'text-neutral-300 mb-4 px-4'}>{title}</h2>}
|
||||
{showFlashes &&
|
||||
|
@ -20,6 +22,7 @@ const ContentBox = ({ title, borderColor, showFlashes, children, ...props }: Pro
|
|||
<div className={classNames('bg-neutral-700 p-4 rounded shadow-lg relative', borderColor, {
|
||||
'border-t-4': !!borderColor,
|
||||
})}>
|
||||
<SpinnerOverlay visible={showLoadingOverlay || false}/>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|||
|
||||
interface Props {
|
||||
icon?: IconProp;
|
||||
title: string;
|
||||
title: string | React.ReactNode;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
@ -12,9 +12,13 @@ interface Props {
|
|||
const TitledGreyBox = ({ icon, title, children, className }: Props) => (
|
||||
<div className={`rounded shadow-md bg-neutral-700 ${className}`}>
|
||||
<div className={'bg-neutral-900 rounded-t p-3 border-b border-black'}>
|
||||
<p className={'text-sm uppercase'}>
|
||||
{icon && <FontAwesomeIcon icon={icon} className={'mr-2 text-neutral-300'}/>}{title}
|
||||
</p>
|
||||
{typeof title === 'string' ?
|
||||
<p className={'text-sm uppercase'}>
|
||||
{icon && <FontAwesomeIcon icon={icon} className={'mr-2 text-neutral-300'}/>}{title}
|
||||
</p>
|
||||
:
|
||||
title
|
||||
}
|
||||
</div>
|
||||
<div className={'p-3'}>
|
||||
{children}
|
||||
|
|
|
@ -78,7 +78,7 @@ export default ({ schedule, task, onTaskUpdated, onTaskRemoved }: Props) => {
|
|||
<button
|
||||
type={'button'}
|
||||
aria-label={'Edit scheduled task'}
|
||||
className={'block text-sm p-2 text-neutral-500 hover:text-neutral-100 transition-color duration-150 mr-4'}
|
||||
className={'block text-sm p-2 text-neutral-500 hover:text-neutral-100 transition-colors duration-150 mr-4'}
|
||||
onClick={() => setIsEditing(true)}
|
||||
>
|
||||
<FontAwesomeIcon icon={faPencilAlt}/>
|
||||
|
@ -86,7 +86,7 @@ export default ({ schedule, task, onTaskUpdated, onTaskRemoved }: Props) => {
|
|||
<button
|
||||
type={'button'}
|
||||
aria-label={'Delete scheduled task'}
|
||||
className={'block text-sm p-2 text-neutral-500 hover:text-red-600 transition-color duration-150'}
|
||||
className={'block text-sm p-2 text-neutral-500 hover:text-red-600 transition-colors duration-150'}
|
||||
onClick={() => setVisible(true)}
|
||||
>
|
||||
<FontAwesomeIcon icon={faTrashAlt}/>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import React, { useState } from 'react';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faUserPlus } from '@fortawesome/free-solid-svg-icons/faUserPlus';
|
||||
import EditSubuserModal from '@/components/server/users/EditSubuserModal';
|
||||
|
||||
export default () => {
|
||||
const [ visible, setVisible ] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{visible && <EditSubuserModal
|
||||
appear={true}
|
||||
visible={true}
|
||||
onDismissed={() => setVisible(false)}
|
||||
/>}
|
||||
<button className={'btn btn-primary btn-sm'} onClick={() => setVisible(true)}>
|
||||
<FontAwesomeIcon icon={faUserPlus} className={'mr-1'}/> New User
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
};
|
139
resources/scripts/components/server/users/EditSubuserModal.tsx
Normal file
139
resources/scripts/components/server/users/EditSubuserModal.tsx
Normal file
|
@ -0,0 +1,139 @@
|
|||
import React from 'react';
|
||||
import { Subuser } from '@/state/server/subusers';
|
||||
import { Formik, FormikHelpers, useFormikContext } from 'formik';
|
||||
import { array, object, string } from 'yup';
|
||||
import Modal, { RequiredModalProps } from '@/components/elements/Modal';
|
||||
import Field from '@/components/elements/Field';
|
||||
import { useStoreState } from 'easy-peasy';
|
||||
import { ApplicationStore } from '@/state';
|
||||
import TitledGreyBox from '@/components/elements/TitledGreyBox';
|
||||
import Checkbox from '@/components/elements/Checkbox';
|
||||
import styled from 'styled-components';
|
||||
import classNames from 'classnames';
|
||||
|
||||
type Props = {
|
||||
subuser?: Subuser;
|
||||
} & RequiredModalProps;
|
||||
|
||||
interface Values {
|
||||
email: string;
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
const PermissionLabel = styled.label`
|
||||
${tw`flex items-center border border-transparent rounded p-2 cursor-pointer`};
|
||||
text-transform: none;
|
||||
|
||||
&:hover {
|
||||
${tw`border-neutral-500 bg-neutral-800`};
|
||||
}
|
||||
`;
|
||||
|
||||
const EditSubuserModal = ({ subuser, ...props }: Props) => {
|
||||
const { values, isSubmitting, setFieldValue } = useFormikContext<Values>();
|
||||
const permissions = useStoreState((state: ApplicationStore) => state.permissions.data);
|
||||
|
||||
return (
|
||||
<Modal {...props} showSpinnerOverlay={isSubmitting}>
|
||||
<h3>{subuser ? 'Edit subuser' : 'Create new subuser'}</h3>
|
||||
<div className={'mt-6'}>
|
||||
<Field
|
||||
name={'email'}
|
||||
label={'User Email'}
|
||||
description={'Enter the email address of the user you wish to invite as a subuser for this server.'}
|
||||
/>
|
||||
</div>
|
||||
<div className={'mt-6'}>
|
||||
{Object.keys(permissions).filter(key => key !== 'websocket').map((key, index) => (
|
||||
<TitledGreyBox
|
||||
key={key}
|
||||
title={
|
||||
<div className={'flex items-center'}>
|
||||
<p className={'text-sm uppercase flex-1'}>{key}</p>
|
||||
<input
|
||||
type={'checkbox'}
|
||||
onClick={e => {
|
||||
if (e.currentTarget.checked) {
|
||||
setFieldValue('permissions', [
|
||||
...values.permissions,
|
||||
...Object.keys(permissions[key].keys)
|
||||
.map(pkey => `${key}.${pkey}`)
|
||||
.filter(permission => values.permissions.indexOf(permission) === -1),
|
||||
]);
|
||||
} else {
|
||||
setFieldValue('permissions', [
|
||||
...values.permissions.filter(
|
||||
permission => Object.keys(permissions[key].keys)
|
||||
.map(pkey => `${key}.${pkey}`)
|
||||
.indexOf(permission) < 0,
|
||||
),
|
||||
]);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
className={index !== 0 ? 'mt-4' : undefined}
|
||||
>
|
||||
<p className={'text-sm text-neutral-400 mb-4'}>
|
||||
{permissions[key].description}
|
||||
</p>
|
||||
{Object.keys(permissions[key].keys).map((pkey, index) => (
|
||||
<PermissionLabel
|
||||
htmlFor={`permission_${key}_${pkey}`}
|
||||
className={classNames('transition-colors duration-75', {
|
||||
'mt-2': index !== 0,
|
||||
})}
|
||||
>
|
||||
<div className={'p-2'}>
|
||||
<Checkbox
|
||||
id={`permission_${key}_${pkey}`}
|
||||
name={'permissions'}
|
||||
value={`${key}.${pkey}`}
|
||||
className={'w-5 h-5 mr-2'}
|
||||
/>
|
||||
</div>
|
||||
<div className={'flex-1'}>
|
||||
<span className={'input-dark-label font-medium'}>
|
||||
{pkey}
|
||||
</span>
|
||||
{permissions[key].keys[pkey].length > 0 &&
|
||||
<p className={'text-xs text-neutral-400 mt-1'}>
|
||||
{permissions[key].keys[pkey]}
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</PermissionLabel>
|
||||
))}
|
||||
</TitledGreyBox>
|
||||
))}
|
||||
</div>
|
||||
<div className={'mt-6 pb-6 flex justify-end'}>
|
||||
<button className={'btn btn-primary btn-sm'} type={'submit'}>
|
||||
{subuser ? 'Save' : 'Invite User'}
|
||||
</button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default (props: Props) => {
|
||||
const submit = (values: Values, helpers: FormikHelpers<Values>) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
onSubmit={submit}
|
||||
initialValues={{
|
||||
email: '',
|
||||
permissions: [],
|
||||
} as Values}
|
||||
validationSchema={object().shape({
|
||||
email: string().email('A valid email address must be provided.').required('A valid email address must be provided.'),
|
||||
permissions: array().of(string()),
|
||||
})}
|
||||
>
|
||||
<EditSubuserModal {...props}/>
|
||||
</Formik>
|
||||
);
|
||||
};
|
|
@ -1,19 +1,12 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faUserPlus } from '@fortawesome/free-solid-svg-icons/faUserPlus';
|
||||
import { ServerContext } from '@/state/server';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import { Subuser } from '@/state/server/subusers';
|
||||
import { CSSTransition } from 'react-transition-group';
|
||||
import classNames from 'classnames';
|
||||
import PermissionEditor from '@/components/server/users/PermissionEditor';
|
||||
import { Actions, useStoreActions, useStoreState } from 'easy-peasy';
|
||||
import { ApplicationStore } from '@/state';
|
||||
import { faArrowLeft } from '@fortawesome/free-solid-svg-icons/faArrowLeft';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import AddSubuserButton from '@/components/server/users/AddSubuserButton';
|
||||
|
||||
export default () => {
|
||||
const [ loading, setLoading ] = useState(true);
|
||||
const [ editSubuser, setEditSubuser ] = useState<Subuser | null>(null);
|
||||
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const subusers = ServerContext.useStoreState(state => state.subusers.data);
|
||||
|
@ -23,10 +16,8 @@ export default () => {
|
|||
const getPermissions = useStoreActions((actions: Actions<ApplicationStore>) => actions.permissions.getPermissions);
|
||||
|
||||
useEffect(() => {
|
||||
if (!permissions.length) {
|
||||
getPermissions().catch(error => console.error(error));
|
||||
}
|
||||
}, [ permissions, getPermissions ]);
|
||||
getPermissions().catch(error => console.error(error));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getSubusers(uuid)
|
||||
|
@ -37,84 +28,47 @@ export default () => {
|
|||
}, [ uuid, getSubusers ]);
|
||||
|
||||
useEffect(() => {
|
||||
if (subusers.length > 0) {
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(!subusers);
|
||||
}, [ subusers ]);
|
||||
|
||||
if (loading || !Object.keys(permissions).length) {
|
||||
return <Spinner size={'large'} centered={true}/>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'flex my-10'}>
|
||||
<div className={'w-1/2'}>
|
||||
<h2 className={'text-neutral-300 mb-4'}>Subusers</h2>
|
||||
<div
|
||||
className={classNames('border-t-4 grey-box mt-0', {
|
||||
'border-cyan-400': editSubuser === null,
|
||||
'border-neutral-400': editSubuser !== null,
|
||||
})}
|
||||
>
|
||||
{(loading || !permissions.length) ?
|
||||
<div className={'w-full'}>
|
||||
<Spinner centered={true}/>
|
||||
<div className={'my-10'}>
|
||||
{!subusers.length ?
|
||||
<p className={'text-center text-sm text-neutral-400'}>
|
||||
It looks like you don't have any subusers.
|
||||
</p>
|
||||
:
|
||||
subusers.map(subuser => (
|
||||
<div key={subuser.uuid} className={'flex items-center w-full'}>
|
||||
<img
|
||||
className={'w-10 h-10 rounded-full bg-white border-2 border-inset border-neutral-800'}
|
||||
src={`${subuser.image}?s=400`}
|
||||
/>
|
||||
<div className={'ml-4 flex-1'}>
|
||||
<p className={'text-sm'}>{subuser.email}</p>
|
||||
</div>
|
||||
<div className={'ml-4'}>
|
||||
<button
|
||||
className={'btn btn-xs btn-primary'}
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
className={'ml-2 btn btn-xs btn-red btn-secondary'}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
:
|
||||
!subusers.length ?
|
||||
<p className={'text-sm'}>It looks like you don't have any subusers.</p>
|
||||
:
|
||||
subusers.map(subuser => (
|
||||
<div key={subuser.uuid} className={'flex items-center w-full'}>
|
||||
<img
|
||||
className={'w-10 h-10 rounded-full bg-white border-2 border-inset border-neutral-800'}
|
||||
src={`${subuser.image}?s=400`}
|
||||
/>
|
||||
<div className={'ml-4 flex-1'}>
|
||||
<p className={'text-sm'}>{subuser.email}</p>
|
||||
</div>
|
||||
<div className={'ml-4'}>
|
||||
<button
|
||||
className={'btn btn-xs btn-primary'}
|
||||
onClick={() => setEditSubuser(subuser)}
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
className={'ml-2 btn btn-xs btn-red btn-secondary'}
|
||||
onClick={() => setEditSubuser(null)}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
<div className={'flex justify-end mt-6'}>
|
||||
<button className={'btn btn-primary btn-sm'}>
|
||||
<FontAwesomeIcon icon={faUserPlus} className={'mr-1'}/> New User
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{editSubuser &&
|
||||
<CSSTransition timeout={250} classNames={'fade'} appear={true} in={true}>
|
||||
<div className={'flex-1 ml-6'}>
|
||||
<h2 className={'flex items-center text-neutral-300 mb-4'}>
|
||||
<span onClick={() => setEditSubuser(null)}>
|
||||
<FontAwesomeIcon
|
||||
icon={faArrowLeft}
|
||||
className={'text-base mr-2 text-neutral-200 hover:text-neutral-100 cursor-pointer'}
|
||||
/>
|
||||
</span>
|
||||
Edit {editSubuser.email}
|
||||
</h2>
|
||||
<div className={'border-t-4 border-cyan-400 grey-box mt-0 p-4'}>
|
||||
<React.Suspense fallback={'Loading...'}>
|
||||
<PermissionEditor
|
||||
defaultPermissions={editSubuser.permissions}
|
||||
/>
|
||||
</React.Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</CSSTransition>
|
||||
))
|
||||
}
|
||||
<div className={'flex justify-end mt-6'}>
|
||||
<AddSubuserButton/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -14,6 +14,7 @@ import FileEditContainer from '@/components/server/files/FileEditContainer';
|
|||
import SettingsContainer from '@/components/server/settings/SettingsContainer';
|
||||
import ScheduleContainer from '@/components/server/schedules/ScheduleContainer';
|
||||
import ScheduleEditContainer from '@/components/server/schedules/ScheduleEditContainer';
|
||||
import UsersContainer from '@/components/server/users/UsersContainer';
|
||||
|
||||
const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => {
|
||||
const server = ServerContext.useStoreState(state => state.server.data);
|
||||
|
@ -35,8 +36,8 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
|||
<NavLink to={`${match.url}`} exact>Console</NavLink>
|
||||
<NavLink to={`${match.url}/files`}>File Manager</NavLink>
|
||||
<NavLink to={`${match.url}/databases`}>Databases</NavLink>
|
||||
{/* <NavLink to={`${match.url}/users`}>User Management</NavLink> */}
|
||||
<NavLink to={`${match.url}/schedules`}>Schedules</NavLink>
|
||||
<NavLink to={`${match.url}/users`}>Users</NavLink>
|
||||
<NavLink to={`${match.url}/settings`}>Settings</NavLink>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -62,9 +63,9 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
|
|||
exact
|
||||
/>
|
||||
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
|
||||
{/* <Route path={`${match.path}/users`} component={UsersContainer} exact/> */}
|
||||
<Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/>
|
||||
<Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} exact/>
|
||||
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
|
||||
<Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
|
||||
</Switch>
|
||||
</React.Fragment>
|
||||
|
|
|
@ -1,15 +1,21 @@
|
|||
import { SubuserPermission } from '@/state/server/subusers';
|
||||
import { action, Action, thunk, Thunk } from 'easy-peasy';
|
||||
import getSystemPermissions from '@/api/getSystemPermissions';
|
||||
|
||||
export interface PanelPermissions {
|
||||
[key: string]: {
|
||||
description: string;
|
||||
keys: { [k: string]: string };
|
||||
};
|
||||
}
|
||||
|
||||
export interface GloablPermissionsStore {
|
||||
data: SubuserPermission[];
|
||||
setPermissions: Action<GloablPermissionsStore, SubuserPermission[]>;
|
||||
data: PanelPermissions;
|
||||
setPermissions: Action<GloablPermissionsStore, PanelPermissions>;
|
||||
getPermissions: Thunk<GloablPermissionsStore, void, {}, any, Promise<void>>;
|
||||
}
|
||||
|
||||
const permissions: GloablPermissionsStore = {
|
||||
data: [],
|
||||
data: {},
|
||||
|
||||
setPermissions: action((state, payload) => {
|
||||
state.data = payload;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
& > .modal-container {
|
||||
@apply .relative .w-full .max-w-md .m-auto .flex-col .flex;
|
||||
|
||||
&.top {
|
||||
/*&.top {
|
||||
margin-top: 10%;
|
||||
}
|
||||
}*/
|
||||
|
||||
& > .modal-close-icon {
|
||||
@apply .absolute .pin-r .p-2 .text-white .cursor-pointer .opacity-50;
|
||||
|
@ -22,7 +22,8 @@
|
|||
}
|
||||
|
||||
& > .modal-content {
|
||||
@apply .bg-neutral-800 .rounded .shadow-md;
|
||||
@apply .bg-neutral-800 .rounded .shadow-md .overflow-y-scroll;
|
||||
max-height: calc(100vh - 16rem);
|
||||
transition: all 250ms ease;
|
||||
}
|
||||
|
||||
|
@ -39,7 +40,7 @@
|
|||
}
|
||||
|
||||
& > .modal-container.full-screen {
|
||||
@apply .w-3/4 .mt-32;
|
||||
@apply .w-3/4;
|
||||
height: calc(100vh - 16rem);
|
||||
max-width: none;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue