mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
add callback to add permission since without links of new created object are unknown
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import connect from "react-redux/es/connect/connect";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { translate } from "react-i18next";
|
||||
import {
|
||||
fetchPermissions,
|
||||
@@ -13,9 +14,14 @@ import {
|
||||
} from "../modules/permissions";
|
||||
import Loading from "../../components/Loading";
|
||||
import ErrorPage from "../../components/ErrorPage";
|
||||
import type {Permission, PermissionCollection, PermissionEntry} from "../types/Permissions";
|
||||
import type {
|
||||
Permission,
|
||||
PermissionCollection,
|
||||
PermissionEntry
|
||||
} from "../types/Permissions";
|
||||
import SinglePermission from "./SinglePermission";
|
||||
import CreatePermissionForm from "../components/CreatePermissionForm";
|
||||
import type { History } from "history";
|
||||
|
||||
type Props = {
|
||||
namespace: string,
|
||||
@@ -31,12 +37,14 @@ type Props = {
|
||||
createPermission: (
|
||||
permission: PermissionEntry,
|
||||
namespace: string,
|
||||
repoName: string
|
||||
repoName: string,
|
||||
callback?: () => void
|
||||
) => void,
|
||||
|
||||
// context props
|
||||
t: string => string,
|
||||
match: any
|
||||
match: any,
|
||||
history: History
|
||||
};
|
||||
|
||||
class Permissions extends React.Component<Props> {
|
||||
@@ -46,6 +54,11 @@ class Permissions extends React.Component<Props> {
|
||||
fetchPermissions(namespace, repoName);
|
||||
}
|
||||
|
||||
permissionCreated = () => {
|
||||
const { history, namespace, repoName } = this.props;
|
||||
history.push(`/repo/${namespace}/${repoName}/permissions`);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
loading,
|
||||
@@ -75,7 +88,12 @@ class Permissions extends React.Component<Props> {
|
||||
const createPermissionForm = hasPermissionToCreate ? (
|
||||
<CreatePermissionForm
|
||||
createPermission={permission =>
|
||||
this.props.createPermission(permission, namespace, repoName)
|
||||
this.props.createPermission(
|
||||
permission,
|
||||
namespace,
|
||||
repoName,
|
||||
this.permissionCreated()
|
||||
)
|
||||
}
|
||||
loading={loadingCreatePermission}
|
||||
/>
|
||||
@@ -145,9 +163,10 @@ const mapDispatchToProps = dispatch => {
|
||||
createPermission: (
|
||||
permission: PermissionEntry,
|
||||
namespace: string,
|
||||
repoName: string
|
||||
repoName: string,
|
||||
callback?: () => void
|
||||
) => {
|
||||
dispatch(createPermission(permission, namespace, repoName));
|
||||
dispatch(createPermission(permission, namespace, repoName, callback));
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -155,4 +174,4 @@ const mapDispatchToProps = dispatch => {
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("permissions")(Permissions));
|
||||
)(translate("permissions")(withRouter(Permissions)));
|
||||
|
||||
Reference in New Issue
Block a user