Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi permission dialog fixes #887

Merged
merged 5 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions gsa/src/web/entity/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SectionElements.propTypes = {
onPermissionCreateClick: PropTypes.func.isRequired,
};

class EntityPermissions extends React.Component {
class Permissions extends React.Component {

constructor(...args) {
super(...args);
Expand Down Expand Up @@ -157,7 +157,9 @@ class EntityPermissions extends React.Component {

handleMultipleSave(data) {
const {gmp, onChanged} = this.props;
return gmp.permissions.create(data).then(onChanged);
return gmp.permissions.create(data)
.then(onChanged)
.then(() => this.closeMultiplePermissionDialog());
}

render() {
Expand Down Expand Up @@ -235,7 +237,7 @@ class EntityPermissions extends React.Component {
}
}

EntityPermissions.propTypes = {
Permissions.propTypes = {
entity: PropTypes.model.isRequired,
gmp: PropTypes.gmp.isRequired,
permissions: PropTypes.array,
Expand All @@ -247,9 +249,9 @@ EntityPermissions.propTypes = {
onPermissionEditClick: PropTypes.func.isRequired,
};

EntityPermissions = withGmp(EntityPermissions);
Permissions = withGmp(Permissions);

const Permissions = ({
const EntityPermissions = ({
onChanged,
onDownloaded,
onError,
Expand All @@ -272,7 +274,7 @@ const Permissions = ({
download,
edit,
}) => (
<EntityPermissions
<Permissions
{...props}
onChanged={onChanged}
onPermissionCreateClick={create}
Expand All @@ -285,12 +287,12 @@ const Permissions = ({
</PermissionComponent>
);

Permissions.propTypes = {
EntityPermissions.propTypes = {
onChanged: PropTypes.func.isRequired,
onDownloaded: PropTypes.func.isRequired,
onError: PropTypes.func.isRequired,
};

export default Permissions;
export default EntityPermissions;

// vim: set ts=2 sw=2 tw=80:
22 changes: 10 additions & 12 deletions gsa/src/web/pages/permissions/multipledialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,24 @@ const MultiplePermissionDialog = withCapabilities(({
title = _('Create Multiple Permissions'),
userId,
users = [],
visible = true,
onClose,
onSave,
}) => {
const hasRelated = related.length > 0;

const data = {
entityName,
entityType,
const defaultValues = {
groupId,
groups,
id,
includeRelated,
permission,
related,
roleId,
roles,
subjectType,
userId,
users,
};

const values = {
id,
entityType,
related,
};

const includeRelatedItems = [];
Expand All @@ -105,11 +103,11 @@ const MultiplePermissionDialog = withCapabilities(({

return (
<SaveDialog
visible={visible}
title={title}
onClose={onClose}
onSave={onSave}
defaultValues={data}
defaultValues={defaultValues}
values={values}
>
{({
values: state,
Expand Down Expand Up @@ -205,7 +203,7 @@ const MultiplePermissionDialog = withCapabilities(({
>
<Divider>
<span>{typeName(getEntityType(state))}</span>
<i>{state.entityName}</i>
<i>{entityName}</i>
<Select
name="includeRelated"
value={state.includeRelated}
Expand Down