add reset for delete Permission

This commit is contained in:
Maren Süwer
2018-09-03 15:29:30 +02:00
parent bdb6148e54
commit 0f78ce9d3a
2 changed files with 28 additions and 1 deletions

View File

@@ -10,7 +10,8 @@ import {
modifyPermissionReset,
deletePermission,
getDeletePermissionFailure,
isDeletePermissionPending
isDeletePermissionPending,
deletePermissionReset
} from "../modules/permissions";
import connect from "react-redux/es/connect/connect";
import { withRouter } from "react-router-dom";
@@ -31,6 +32,7 @@ type Props = {
loading: boolean,
error: Error,
permissionReset: (string, string, string) => void,
deletePermissionReset: (string, string, string) => void,
deletePermission: (Permission, string, string) => void,
deleteLoading: boolean
};
@@ -60,6 +62,11 @@ class SinglePermission extends React.Component<Props, State> {
this.props.repoName,
permission.name
);
this.props.deletePermissionReset(
this.props.namespace,
this.props.repoName,
permission.name
);
if (permission) {
this.setState({
permission: {
@@ -204,6 +211,13 @@ const mapDispatchToProps = dispatch => {
repoName: string
) => {
dispatch(deletePermission(permission, namespace, repoName));
},
deletePermissionReset: (
namespace: string,
repoName: string,
permissionname: string
) => {
dispatch(deletePermissionReset(namespace, repoName, permissionname));
}
};
};

View File

@@ -57,6 +57,9 @@ export const DELETE_PERMISSION_SUCCESS = `${DELETE_PERMISSION}_${
export const DELETE_PERMISSION_FAILURE = `${DELETE_PERMISSION}_${
types.FAILURE_SUFFIX
}`;
export const DELETE_PERMISSION_RESET = `${DELETE_PERMISSION}_${
types.RESET_SUFFIX
}`;
const REPOS_URL = "repositories";
const PERMISSIONS_URL = "permissions";
@@ -366,6 +369,16 @@ export function deletePermissionFailure(
};
}
export function deletePermissionReset(
namespace: string,
repoName: string,
permissionname: string
) {
return {
type: DELETE_PERMISSION_RESET,
itemId: namespace + "/" + repoName + "/" + permissionname
};
}
function deletePermissionFromState(
oldPermissions: PermissionCollection,
permission: Permission