mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15: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
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import connect from "react-redux/es/connect/connect";
|
import connect from "react-redux/es/connect/connect";
|
||||||
|
import { withRouter } from "react-router-dom";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
fetchPermissions,
|
fetchPermissions,
|
||||||
@@ -13,9 +14,14 @@ import {
|
|||||||
} from "../modules/permissions";
|
} from "../modules/permissions";
|
||||||
import Loading from "../../components/Loading";
|
import Loading from "../../components/Loading";
|
||||||
import ErrorPage from "../../components/ErrorPage";
|
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 SinglePermission from "./SinglePermission";
|
||||||
import CreatePermissionForm from "../components/CreatePermissionForm";
|
import CreatePermissionForm from "../components/CreatePermissionForm";
|
||||||
|
import type { History } from "history";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
namespace: string,
|
namespace: string,
|
||||||
@@ -31,12 +37,14 @@ type Props = {
|
|||||||
createPermission: (
|
createPermission: (
|
||||||
permission: PermissionEntry,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
namespace: string,
|
||||||
repoName: string
|
repoName: string,
|
||||||
|
callback?: () => void
|
||||||
) => void,
|
) => void,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
t: string => string,
|
t: string => string,
|
||||||
match: any
|
match: any,
|
||||||
|
history: History
|
||||||
};
|
};
|
||||||
|
|
||||||
class Permissions extends React.Component<Props> {
|
class Permissions extends React.Component<Props> {
|
||||||
@@ -46,6 +54,11 @@ class Permissions extends React.Component<Props> {
|
|||||||
fetchPermissions(namespace, repoName);
|
fetchPermissions(namespace, repoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
permissionCreated = () => {
|
||||||
|
const { history, namespace, repoName } = this.props;
|
||||||
|
history.push(`/repo/${namespace}/${repoName}/permissions`);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
loading,
|
loading,
|
||||||
@@ -75,7 +88,12 @@ class Permissions extends React.Component<Props> {
|
|||||||
const createPermissionForm = hasPermissionToCreate ? (
|
const createPermissionForm = hasPermissionToCreate ? (
|
||||||
<CreatePermissionForm
|
<CreatePermissionForm
|
||||||
createPermission={permission =>
|
createPermission={permission =>
|
||||||
this.props.createPermission(permission, namespace, repoName)
|
this.props.createPermission(
|
||||||
|
permission,
|
||||||
|
namespace,
|
||||||
|
repoName,
|
||||||
|
this.permissionCreated()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
loading={loadingCreatePermission}
|
loading={loadingCreatePermission}
|
||||||
/>
|
/>
|
||||||
@@ -145,9 +163,10 @@ const mapDispatchToProps = dispatch => {
|
|||||||
createPermission: (
|
createPermission: (
|
||||||
permission: PermissionEntry,
|
permission: PermissionEntry,
|
||||||
namespace: string,
|
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(
|
export default connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(translate("permissions")(Permissions));
|
)(translate("permissions")(withRouter(Permissions)));
|
||||||
|
|||||||
Reference in New Issue
Block a user