Get basic modal view for editing/creating a new subuser working

This commit is contained in:
Dane Everitt 2020-03-25 21:58:37 -07:00
parent 8d52e2e1a7
commit 51c5cf4dbb
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 293 additions and 186 deletions

View file

@ -3,7 +3,6 @@
namespace Pterodactyl\Http\Controllers\Api\Client; namespace Pterodactyl\Http\Controllers\Api\Client;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Illuminate\Support\Collection;
use Pterodactyl\Models\Permission; use Pterodactyl\Models\Permission;
use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository;
use Pterodactyl\Transformers\Api\Client\ServerTransformer; use Pterodactyl\Transformers\Api\Client\ServerTransformer;
@ -72,16 +71,10 @@ class ClientController extends ClientApiController
*/ */
public function permissions() 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 [ return [
'object' => 'system_permissions', 'object' => 'system_permissions',
'attributes' => [ 'attributes' => [
'permissions' => $permissions, 'permissions' => Permission::permissions(),
], ],
]; ];
} }

View file

@ -98,105 +98,90 @@ class Permission extends Validable
*/ */
protected static $permissions = [ protected static $permissions = [
'websocket' => [ 'websocket' => [
// Allows the user to connect to the server websocket, this will give them 'description' => 'Allows the user to connect to the server websocket, giving them access to view console output and realtime server stats.',
// access to view the console output as well as realtime server stats (CPU 'keys' => [
// and Memory usage). '*' => 'Gives user full read access to the websocket.',
'*', ],
], ],
'control' => [ 'control' => [
// Allows the user to send data to the server console process. A user with this 'description' => 'Permissions that control a user\'s ability to control the power state of a server, or send commands.',
// permission will not be able to stop the server directly by issuing the specified 'keys' => [
// stop command for the Egg, however depending on plugins and server configuration 'console' => 'Allows a user to send commands to the server instance via the console.',
// they may still be able to control the server power state. 'start' => 'Allows a user to start the server if it is stopped.',
'console', // power.send-command '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.',
// Allows the user to start/stop/restart/kill the server process. 'kill' => 'Allows a user to terminate a server process.',
'start', // power.power-start ],
'stop', // power.power-stop
'restart', // power.power-restart
'kill', // power.power-kill
], ],
'user' => [ 'user' => [
// Allows a user to create a new user assigned to the server. They will not be able '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.',
// to assign any permissions they do not already have on their account as well. 'keys' => [
'create', // subuser.create-subuser 'create' => 'Allows a user to create new subusers for the server.',
'read', // subuser.list-subusers, subuser.view-subuser 'read' => 'Allows the user to view subusers and their permissions for the server.',
'update', // subuser.edit-subuser 'update' => 'Allows a user to modify other subusers.',
'delete', // subuser.delete-subuser 'delete' => 'Allows a user to delete a subuser from the server.',
],
], ],
'file' => [ 'file' => [
// Allows a user to create additional files and folders either via the Panel, 'description' => 'Permissions that control a user\'s ability to modify the filesystem for this server.',
// or via a direct upload. 'keys' => [
'create', // files.create-files, files.upload-files, files.copy-files, files.move-files '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.',
// Allows a user to view the contents of a directory as well as read the contents 'update' => 'Allows a user to update the contents of an existing file or directory.',
// of a given file. A user with this permission will be able to download files 'delete' => 'Allows a user to delete files or directories.',
// as well. 'archive' => 'Allows a user to archive the contents of a directory as well as decompress existing archives on the system.',
'read', // files.list-files, files.download-files 'sftp' => 'Allows a user to connect to SFTP and manage server files using the other assigned file permissions.',
],
// 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
], ],
// Controls permissions for editing or viewing a server's allocations. // Controls permissions for editing or viewing a server's allocations.
'allocation' => [ 'allocation' => [
'read', // server.view-allocations 'description' => 'Permissions that control a user\'s ability to modify the port allocations for this server.',
'update', // server.edit-allocation '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. // Controls permissions for editing or viewing a server's startup parameters.
'startup' => [ 'startup' => [
'read', // server.view-startup 'description' => 'Permissions that control a user\'s ability to view this server\'s startup parameters.',
'update', // server.edit-startup 'keys' => [
'read' => '',
'update' => '',
],
], ],
'database' => [ 'database' => [
// Allows a user to create a new database for a server. 'description' => 'Permissions that control a user\'s access to the database management for this server.',
'create', // database.create-database 'keys' => [
'create' => 'Allows a user to create a new database for this server.',
// Allows a user to view the databases associated with the server. If they do not also 'read' => 'Allows a user to view the database associated with this server.',
// have the view_password permission they will only be able to see the connection address '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.',
// and the name of the user. 'delete' => 'Allows a user to remove a database instance from this server.',
'read', // database.view-databases 'view_password' => 'Allows a user to view the password associated with a database instance for this server.',
],
// 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
], ],
'schedule' => [ 'schedule' => [
'create', // task.create-schedule 'description' => 'Permissions that control a user\'s access to the schedule management for this server.',
'read', // task.view-schedule, task.list-schedules 'keys' => [
'update', // task.edit-schedule, task.queue-schedule, task.toggle-schedule 'create' => '', // task.create-schedule
'delete', // task.delete-schedule 'read' => '', // task.view-schedule, task.list-schedules
'update' => '', // task.edit-schedule, task.queue-schedule, task.toggle-schedule
'delete' => '', // task.delete-schedule
],
], ],
'settings' => [ 'settings' => [
'rename', 'description' => 'Permissions that control a user\'s access to the settings for this server.',
'reinstall', 'keys' => [
'rename' => '',
'reinstall' => '',
],
], ],
]; ];

View file

@ -1,7 +1,7 @@
import { SubuserPermission } from '@/state/server/subusers'; import { PanelPermissions } from '@/state/permissions';
import http from '@/api/http'; import http from '@/api/http';
export default (): Promise<SubuserPermission[]> => { export default (): Promise<PanelPermissions> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
http.get(`/api/client/permissions`) http.get(`/api/client/permissions`)
.then(({ data }) => resolve(data.attributes.permissions)) .then(({ data }) => resolve(data.attributes.permissions))

View file

@ -95,7 +95,7 @@ export default () => {
> >
<FontAwesomeIcon <FontAwesomeIcon
icon={faTrashAlt} 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> </button>
</div> </div>

View file

@ -1,14 +1,16 @@
import * as React from 'react'; import * as React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import FlashMessageRender from '@/components/FlashMessageRender'; import FlashMessageRender from '@/components/FlashMessageRender';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
type Props = Readonly<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & { type Props = Readonly<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
title?: string; title?: string;
borderColor?: string; borderColor?: string;
showFlashes?: string | boolean; showFlashes?: string | boolean;
showLoadingOverlay?: boolean;
}>; }>;
const ContentBox = ({ title, borderColor, showFlashes, children, ...props }: Props) => ( const ContentBox = ({ title, borderColor, showFlashes, showLoadingOverlay, children, ...props }: Props) => (
<div {...props}> <div {...props}>
{title && <h2 className={'text-neutral-300 mb-4 px-4'}>{title}</h2>} {title && <h2 className={'text-neutral-300 mb-4 px-4'}>{title}</h2>}
{showFlashes && {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, { <div className={classNames('bg-neutral-700 p-4 rounded shadow-lg relative', borderColor, {
'border-t-4': !!borderColor, 'border-t-4': !!borderColor,
})}> })}>
<SpinnerOverlay visible={showLoadingOverlay || false}/>
{children} {children}
</div> </div>
</div> </div>

View file

@ -4,7 +4,7 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core';
interface Props { interface Props {
icon?: IconProp; icon?: IconProp;
title: string; title: string | React.ReactNode;
className?: string; className?: string;
children: React.ReactNode; children: React.ReactNode;
} }
@ -12,9 +12,13 @@ interface Props {
const TitledGreyBox = ({ icon, title, children, className }: Props) => ( const TitledGreyBox = ({ icon, title, children, className }: Props) => (
<div className={`rounded shadow-md bg-neutral-700 ${className}`}> <div className={`rounded shadow-md bg-neutral-700 ${className}`}>
<div className={'bg-neutral-900 rounded-t p-3 border-b border-black'}> <div className={'bg-neutral-900 rounded-t p-3 border-b border-black'}>
<p className={'text-sm uppercase'}> {typeof title === 'string' ?
{icon && <FontAwesomeIcon icon={icon} className={'mr-2 text-neutral-300'}/>}{title} <p className={'text-sm uppercase'}>
</p> {icon && <FontAwesomeIcon icon={icon} className={'mr-2 text-neutral-300'}/>}{title}
</p>
:
title
}
</div> </div>
<div className={'p-3'}> <div className={'p-3'}>
{children} {children}

View file

@ -78,7 +78,7 @@ export default ({ schedule, task, onTaskUpdated, onTaskRemoved }: Props) => {
<button <button
type={'button'} type={'button'}
aria-label={'Edit scheduled task'} 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)} onClick={() => setIsEditing(true)}
> >
<FontAwesomeIcon icon={faPencilAlt}/> <FontAwesomeIcon icon={faPencilAlt}/>
@ -86,7 +86,7 @@ export default ({ schedule, task, onTaskUpdated, onTaskRemoved }: Props) => {
<button <button
type={'button'} type={'button'}
aria-label={'Delete scheduled task'} 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)} onClick={() => setVisible(true)}
> >
<FontAwesomeIcon icon={faTrashAlt}/> <FontAwesomeIcon icon={faTrashAlt}/>

View file

@ -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>
</>
);
};

View 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>
);
};

View file

@ -1,19 +1,12 @@
import React, { useEffect, useState } from 'react'; 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 { 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 { Actions, useStoreActions, useStoreState } from 'easy-peasy';
import { ApplicationStore } from '@/state'; 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 () => { export default () => {
const [ loading, setLoading ] = useState(true); const [ loading, setLoading ] = useState(true);
const [ editSubuser, setEditSubuser ] = useState<Subuser | null>(null);
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
const subusers = ServerContext.useStoreState(state => state.subusers.data); const subusers = ServerContext.useStoreState(state => state.subusers.data);
@ -23,10 +16,8 @@ export default () => {
const getPermissions = useStoreActions((actions: Actions<ApplicationStore>) => actions.permissions.getPermissions); const getPermissions = useStoreActions((actions: Actions<ApplicationStore>) => actions.permissions.getPermissions);
useEffect(() => { useEffect(() => {
if (!permissions.length) { getPermissions().catch(error => console.error(error));
getPermissions().catch(error => console.error(error)); }, []);
}
}, [ permissions, getPermissions ]);
useEffect(() => { useEffect(() => {
getSubusers(uuid) getSubusers(uuid)
@ -37,84 +28,47 @@ export default () => {
}, [ uuid, getSubusers ]); }, [ uuid, getSubusers ]);
useEffect(() => { useEffect(() => {
if (subusers.length > 0) { setLoading(!subusers);
setLoading(false);
}
}, [ subusers ]); }, [ subusers ]);
if (loading || !Object.keys(permissions).length) {
return <Spinner size={'large'} centered={true}/>;
}
return ( return (
<div className={'flex my-10'}> <div className={'my-10'}>
<div className={'w-1/2'}> {!subusers.length ?
<h2 className={'text-neutral-300 mb-4'}>Subusers</h2> <p className={'text-center text-sm text-neutral-400'}>
<div It looks like you don't have any subusers.
className={classNames('border-t-4 grey-box mt-0', { </p>
'border-cyan-400': editSubuser === null, :
'border-neutral-400': editSubuser !== null, subusers.map(subuser => (
})} <div key={subuser.uuid} className={'flex items-center w-full'}>
> <img
{(loading || !permissions.length) ? className={'w-10 h-10 rounded-full bg-white border-2 border-inset border-neutral-800'}
<div className={'w-full'}> src={`${subuser.image}?s=400`}
<Spinner centered={true}/> />
<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> </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>
</div> ))
</CSSTransition>
} }
<div className={'flex justify-end mt-6'}>
<AddSubuserButton/>
</div>
</div> </div>
); );
}; };

View file

@ -14,6 +14,7 @@ import FileEditContainer from '@/components/server/files/FileEditContainer';
import SettingsContainer from '@/components/server/settings/SettingsContainer'; import SettingsContainer from '@/components/server/settings/SettingsContainer';
import ScheduleContainer from '@/components/server/schedules/ScheduleContainer'; import ScheduleContainer from '@/components/server/schedules/ScheduleContainer';
import ScheduleEditContainer from '@/components/server/schedules/ScheduleEditContainer'; import ScheduleEditContainer from '@/components/server/schedules/ScheduleEditContainer';
import UsersContainer from '@/components/server/users/UsersContainer';
const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => { const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => {
const server = ServerContext.useStoreState(state => state.server.data); 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}`} exact>Console</NavLink>
<NavLink to={`${match.url}/files`}>File Manager</NavLink> <NavLink to={`${match.url}/files`}>File Manager</NavLink>
<NavLink to={`${match.url}/databases`}>Databases</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}/schedules`}>Schedules</NavLink>
<NavLink to={`${match.url}/users`}>Users</NavLink>
<NavLink to={`${match.url}/settings`}>Settings</NavLink> <NavLink to={`${match.url}/settings`}>Settings</NavLink>
</div> </div>
</div> </div>
@ -62,9 +63,9 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
exact exact
/> />
<Route path={`${match.path}/databases`} component={DatabasesContainer} 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`} component={ScheduleContainer} exact/>
<Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} 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/> <Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
</Switch> </Switch>
</React.Fragment> </React.Fragment>

View file

@ -1,15 +1,21 @@
import { SubuserPermission } from '@/state/server/subusers';
import { action, Action, thunk, Thunk } from 'easy-peasy'; import { action, Action, thunk, Thunk } from 'easy-peasy';
import getSystemPermissions from '@/api/getSystemPermissions'; import getSystemPermissions from '@/api/getSystemPermissions';
export interface PanelPermissions {
[key: string]: {
description: string;
keys: { [k: string]: string };
};
}
export interface GloablPermissionsStore { export interface GloablPermissionsStore {
data: SubuserPermission[]; data: PanelPermissions;
setPermissions: Action<GloablPermissionsStore, SubuserPermission[]>; setPermissions: Action<GloablPermissionsStore, PanelPermissions>;
getPermissions: Thunk<GloablPermissionsStore, void, {}, any, Promise<void>>; getPermissions: Thunk<GloablPermissionsStore, void, {}, any, Promise<void>>;
} }
const permissions: GloablPermissionsStore = { const permissions: GloablPermissionsStore = {
data: [], data: {},
setPermissions: action((state, payload) => { setPermissions: action((state, payload) => {
state.data = payload; state.data = payload;

View file

@ -6,9 +6,9 @@
& > .modal-container { & > .modal-container {
@apply .relative .w-full .max-w-md .m-auto .flex-col .flex; @apply .relative .w-full .max-w-md .m-auto .flex-col .flex;
&.top { /*&.top {
margin-top: 10%; margin-top: 10%;
} }*/
& > .modal-close-icon { & > .modal-close-icon {
@apply .absolute .pin-r .p-2 .text-white .cursor-pointer .opacity-50; @apply .absolute .pin-r .p-2 .text-white .cursor-pointer .opacity-50;
@ -22,7 +22,8 @@
} }
& > .modal-content { & > .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; transition: all 250ms ease;
} }
@ -39,7 +40,7 @@
} }
& > .modal-container.full-screen { & > .modal-container.full-screen {
@apply .w-3/4 .mt-32; @apply .w-3/4;
height: calc(100vh - 16rem); height: calc(100vh - 16rem);
max-width: none; max-width: none;
} }