WiP on permissions
Table of shares per user
This commit is contained in:
parent
89c9615592
commit
89256d62bd
20 changed files with 354 additions and 171 deletions
|
|
@ -24,9 +24,7 @@ export default class CUD extends Component {
|
|||
|
||||
this.passwordValidator = passwordValidator(props.t);
|
||||
|
||||
this.state = {
|
||||
globalRoles: []
|
||||
};
|
||||
this.state = {};
|
||||
|
||||
if (props.edit) {
|
||||
this.state.entityId = parseInt(props.match.params.id);
|
||||
|
|
@ -49,14 +47,6 @@ export default class CUD extends Component {
|
|||
return this.props.match.params.action === 'delete';
|
||||
}
|
||||
|
||||
@withAsyncErrorHandler
|
||||
async fetchGlobalRoles() {
|
||||
const result = await axios.get('/rest/users-global-roles');
|
||||
this.setState({
|
||||
globalRoles: result.data
|
||||
});
|
||||
}
|
||||
|
||||
@withAsyncErrorHandler
|
||||
async loadFormValues() {
|
||||
await this.getFormValuesFromURL(`/rest/users/${this.state.entityId}`, data => {
|
||||
|
|
@ -221,20 +211,12 @@ export default class CUD extends Component {
|
|||
const userId = this.getFormValue('id');
|
||||
const canDelete = userId !== 1 && mailtrainConfig.userId !== userId;
|
||||
|
||||
const roles = mailtrainConfig.roles.global;
|
||||
|
||||
const rolesColumns = [
|
||||
{ data: 1, title: "Name" },
|
||||
{ data: 2, title: "Description" },
|
||||
];
|
||||
|
||||
|
||||
const rolesData = [];
|
||||
for (const key in roles) {
|
||||
const role = roles[key];
|
||||
rolesData.push([ key, role.name, role.description ]);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{edit && canDelete &&
|
||||
|
|
@ -258,7 +240,7 @@ export default class CUD extends Component {
|
|||
<InputField id="password2" label={t('Repeat Password')} type="password"/>
|
||||
</div>
|
||||
}
|
||||
<TableSelect id="role" label={t('Role')} withHeader dropdown data={rolesData} columns={rolesColumns} selectionLabelIndex={1}/>
|
||||
<TableSelect id="role" label={t('Role')} withHeader dropdown dataUrl={'/rest/shares-roles-table/global'} columns={rolesColumns} selectionLabelIndex={1}/>
|
||||
<NamespaceSelect/>
|
||||
|
||||
<ButtonRow>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ export default class List extends Component {
|
|||
{
|
||||
label: 'Edit',
|
||||
link: '/users/edit/' + data[0]
|
||||
},
|
||||
{
|
||||
label: 'Shares',
|
||||
link: '/users/shares/' + data[0]
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -34,6 +38,7 @@ export default class List extends Component {
|
|||
}
|
||||
|
||||
columns.push({ data: 3, title: "Namespace" });
|
||||
columns.push({ data: 4, title: "Role" });
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -8,24 +8,9 @@ import i18n from '../lib/i18n';
|
|||
import { Section } from '../lib/page';
|
||||
import CUD from './CUD';
|
||||
import List from './List';
|
||||
import mailtrainConfig from 'mailtrainConfig';
|
||||
import UserShares from '../shares/UserShares';
|
||||
|
||||
const getStructure = t => {
|
||||
const subPaths = {};
|
||||
|
||||
if (mailtrainConfig.isAuthMethodLocal) {
|
||||
subPaths.edit = {
|
||||
title: t('Edit User'),
|
||||
params: [':id', ':action?'],
|
||||
render: props => (<CUD edit {...props} />)
|
||||
};
|
||||
|
||||
subPaths.create = {
|
||||
title: t('Create User'),
|
||||
render: props => (<CUD {...props} />)
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
'': {
|
||||
title: t('Home'),
|
||||
|
|
@ -35,7 +20,22 @@ const getStructure = t => {
|
|||
title: t('Users'),
|
||||
link: '/users',
|
||||
component: List,
|
||||
children: subPaths
|
||||
children: {
|
||||
edit: {
|
||||
title: t('Edit User'),
|
||||
params: [':id', ':action?'],
|
||||
render: props => (<CUD edit {...props} />)
|
||||
},
|
||||
create: {
|
||||
title: t('Create User'),
|
||||
render: props => (<CUD {...props} />)
|
||||
},
|
||||
shares: {
|
||||
title: t('User Shares'),
|
||||
params: [':id' ],
|
||||
component: UserShares
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue