-
- {passwordChangeField}
-
-
+
-
-
-
+
+ >
);
}
diff --git a/scm-ui/src/users/components/buttons/CreateUserButton.js b/scm-ui/src/users/components/buttons/CreateUserButton.js
deleted file mode 100644
index f34820cd0d..0000000000
--- a/scm-ui/src/users/components/buttons/CreateUserButton.js
+++ /dev/null
@@ -1,20 +0,0 @@
-//@flow
-import React from "react";
-import { translate } from "react-i18next";
-import { CreateButton } from "@scm-manager/ui-components";
-
-// TODO remove
-type Props = {
- t: string => string
-};
-
-class CreateUserButton extends React.Component
{
- render() {
- const { t } = this.props;
- return (
-
- );
- }
-}
-
-export default translate("users")(CreateUserButton);
diff --git a/scm-ui/src/users/components/navLinks/DeleteUserNavLink.js b/scm-ui/src/users/components/navLinks/DeleteUserNavLink.js
deleted file mode 100644
index 80c355e999..0000000000
--- a/scm-ui/src/users/components/navLinks/DeleteUserNavLink.js
+++ /dev/null
@@ -1,56 +0,0 @@
-// @flow
-import React from "react";
-import { translate } from "react-i18next";
-import type { User } from "@scm-manager/ui-types";
-import { NavAction, confirmAlert } from "@scm-manager/ui-components";
-
-type Props = {
- user: User,
- confirmDialog?: boolean,
- t: string => string,
- deleteUser: (user: User) => void
-};
-
-class DeleteUserNavLink extends React.Component {
- static defaultProps = {
- confirmDialog: true
- };
-
- deleteUser = () => {
- this.props.deleteUser(this.props.user);
- };
-
- confirmDelete = () => {
- const { t } = this.props;
- confirmAlert({
- title: t("delete-user-button.confirm-alert.title"),
- message: t("delete-user-button.confirm-alert.message"),
- buttons: [
- {
- label: t("delete-user-button.confirm-alert.submit"),
- onClick: () => this.deleteUser()
- },
- {
- label: t("delete-user-button.confirm-alert.cancel"),
- onClick: () => null
- }
- ]
- });
- };
-
- isDeletable = () => {
- return this.props.user._links.delete;
- };
-
- render() {
- const { confirmDialog, t } = this.props;
- const action = confirmDialog ? this.confirmDelete : this.deleteUser;
-
- if (!this.isDeletable()) {
- return null;
- }
- return ;
- }
-}
-
-export default translate("users")(DeleteUserNavLink);
diff --git a/scm-ui/src/users/components/navLinks/DeleteUserNavLink.test.js b/scm-ui/src/users/components/navLinks/DeleteUserNavLink.test.js
deleted file mode 100644
index 500235ab94..0000000000
--- a/scm-ui/src/users/components/navLinks/DeleteUserNavLink.test.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import React from "react";
-import { mount, shallow } from "enzyme";
-import "../../../tests/enzyme";
-import "../../../tests/i18n";
-import DeleteUserNavLink from "./DeleteUserNavLink";
-
-import { confirmAlert } from "@scm-manager/ui-components";
-jest.mock("@scm-manager/ui-components", () => ({
- confirmAlert: jest.fn(),
- NavAction: require.requireActual("@scm-manager/ui-components").NavAction
-}));
-
-describe("DeleteUserNavLink", () => {
- it("should render nothing, if the delete link is missing", () => {
- const user = {
- _links: {}
- };
-
- const navLink = shallow(
- {}} />
- );
- expect(navLink.text()).toBe("");
- });
-
- it("should render the navLink", () => {
- const user = {
- _links: {
- delete: {
- href: "/users"
- }
- }
- };
-
- const navLink = mount(
- {}} />
- );
- expect(navLink.text()).not.toBe("");
- });
-
- it("should open the confirm dialog on navLink click", () => {
- const user = {
- _links: {
- delete: {
- href: "/users"
- }
- }
- };
-
- const navLink = mount(
- {}} />
- );
- navLink.find("a").simulate("click");
-
- expect(confirmAlert.mock.calls.length).toBe(1);
- });
-
- it("should call the delete user function with delete url", () => {
- const user = {
- _links: {
- delete: {
- href: "/users"
- }
- }
- };
-
- let calledUrl = null;
- function capture(user) {
- calledUrl = user._links.delete.href;
- }
-
- const navLink = mount(
-
- );
- navLink.find("a").simulate("click");
-
- expect(calledUrl).toBe("/users");
- });
-});
diff --git a/scm-ui/src/users/components/navLinks/EditUserNavLink.js b/scm-ui/src/users/components/navLinks/EditUserNavLink.js
index 8be8dbc621..051bf9a4bd 100644
--- a/scm-ui/src/users/components/navLinks/EditUserNavLink.js
+++ b/scm-ui/src/users/components/navLinks/EditUserNavLink.js
@@ -1,28 +1,28 @@
//@flow
import React from "react";
-import { translate } from "react-i18next";
import type { User } from "@scm-manager/ui-types";
import { NavLink } from "@scm-manager/ui-components";
+import { translate } from "react-i18next";
type Props = {
- t: string => string,
user: User,
- editUrl: String
+ editUrl: String,
+ t: string => string
};
class EditUserNavLink extends React.Component {
+ isEditable = () => {
+ return this.props.user._links.update;
+ };
+
render() {
const { t, editUrl } = this.props;
if (!this.isEditable()) {
return null;
}
- return ;
+ return ;
}
-
- isEditable = () => {
- return this.props.user._links.update;
- };
}
export default translate("users")(EditUserNavLink);
diff --git a/scm-ui/src/users/components/navLinks/SetPasswordNavLink.js b/scm-ui/src/users/components/navLinks/SetPasswordNavLink.js
index 46e931e788..79234308aa 100644
--- a/scm-ui/src/users/components/navLinks/SetPasswordNavLink.js
+++ b/scm-ui/src/users/components/navLinks/SetPasswordNavLink.js
@@ -17,7 +17,7 @@ class ChangePasswordNavLink extends React.Component {
if (!this.hasPermissionToSetPassword()) {
return null;
}
- return ;
+ return ;
}
hasPermissionToSetPassword = () => {
diff --git a/scm-ui/src/users/components/navLinks/SetPermissionsNavLink.js b/scm-ui/src/users/components/navLinks/SetPermissionsNavLink.js
index 3c593d9427..84b0f9da76 100644
--- a/scm-ui/src/users/components/navLinks/SetPermissionsNavLink.js
+++ b/scm-ui/src/users/components/navLinks/SetPermissionsNavLink.js
@@ -17,7 +17,7 @@ class ChangePermissionNavLink extends React.Component {
if (!this.hasPermissionToSetPermission()) {
return null;
}
- return ;
+ return ;
}
hasPermissionToSetPermission = () => {
diff --git a/scm-ui/src/users/components/navLinks/index.js b/scm-ui/src/users/components/navLinks/index.js
index eb39bb6726..cb97c57e3f 100644
--- a/scm-ui/src/users/components/navLinks/index.js
+++ b/scm-ui/src/users/components/navLinks/index.js
@@ -1,4 +1,3 @@
-export { default as DeleteUserNavLink } from "./DeleteUserNavLink";
export { default as EditUserNavLink } from "./EditUserNavLink";
export { default as SetPasswordNavLink } from "./SetPasswordNavLink";
export { default as SetPermissionsNavLink } from "./SetPermissionsNavLink";
diff --git a/scm-ui/src/users/containers/AddUser.js b/scm-ui/src/users/containers/AddUser.js
index f19f974265..069df04187 100644
--- a/scm-ui/src/users/containers/AddUser.js
+++ b/scm-ui/src/users/containers/AddUser.js
@@ -49,8 +49,8 @@ class AddUser extends React.Component {
return (
diff --git a/scm-ui/src/users/containers/DeleteUser.js b/scm-ui/src/users/containers/DeleteUser.js
new file mode 100644
index 0000000000..b8b42fd9e8
--- /dev/null
+++ b/scm-ui/src/users/containers/DeleteUser.js
@@ -0,0 +1,113 @@
+// @flow
+import React from "react";
+import { translate } from "react-i18next";
+import type { User } from "@scm-manager/ui-types";
+import {
+ Subtitle,
+ DeleteButton,
+ confirmAlert,
+ ErrorNotification
+} from "@scm-manager/ui-components";
+import {
+ deleteUser,
+ getDeleteUserFailure,
+ isDeleteUserPending
+} from "../modules/users";
+import { connect } from "react-redux";
+import { withRouter } from "react-router-dom";
+import type { History } from "history";
+
+type Props = {
+ loading: boolean,
+ error: Error,
+ user: User,
+ confirmDialog?: boolean,
+ deleteUser: (user: User, callback?: () => void) => void,
+
+ // context props
+ history: History,
+ t: string => string
+};
+
+class DeleteUser extends React.Component {
+ static defaultProps = {
+ confirmDialog: true
+ };
+
+ userDeleted = () => {
+ this.props.history.push("/users");
+ };
+
+ deleteUser = () => {
+ this.props.deleteUser(this.props.user, this.userDeleted);
+ };
+
+ confirmDelete = () => {
+ const { t } = this.props;
+ confirmAlert({
+ title: t("deleteUser.confirmAlert.title"),
+ message: t("deleteUser.confirmAlert.message"),
+ buttons: [
+ {
+ label: t("deleteUser.confirmAlert.submit"),
+ onClick: () => this.deleteUser()
+ },
+ {
+ label: t("deleteUser.confirmAlert.cancel"),
+ onClick: () => null
+ }
+ ]
+ });
+ };
+
+ isDeletable = () => {
+ return this.props.user._links.delete;
+ };
+
+ render() {
+ const { loading, error, confirmDialog, t } = this.props;
+ const action = confirmDialog ? this.confirmDelete : this.deleteUser;
+
+ if (!this.isDeletable()) {
+ return null;
+ }
+
+ return (
+ <>
+
+
+
+ >
+ );
+ }
+}
+
+const mapStateToProps = (state, ownProps) => {
+ const loading = isDeleteUserPending(state, ownProps.user.name);
+ const error = getDeleteUserFailure(state, ownProps.user.name);
+ return {
+ loading,
+ error
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ deleteUser: (user: User, callback?: () => void) => {
+ dispatch(deleteUser(user, callback));
+ }
+ };
+};
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(withRouter(translate("users")(DeleteUser)));
diff --git a/scm-ui/src/users/containers/EditUser.js b/scm-ui/src/users/containers/EditUser.js
index 55062ecb5b..942d5182e7 100644
--- a/scm-ui/src/users/containers/EditUser.js
+++ b/scm-ui/src/users/containers/EditUser.js
@@ -2,7 +2,8 @@
import React from "react";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
-import UserForm from "./../components/UserForm";
+import UserForm from "../components/UserForm";
+import DeleteUser from "./DeleteUser";
import type { User } from "@scm-manager/ui-types";
import {
modifyUser,
@@ -31,6 +32,7 @@ class EditUser extends React.Component {
const { modifyUserReset, user } = this.props;
modifyUserReset(user);
}
+
userModified = (user: User) => () => {
this.props.history.push(`/user/${user.name}`);
};
@@ -49,11 +51,22 @@ class EditUser extends React.Component {
user={user}
loading={loading}
/>
+
+
);
}
}
+const mapStateToProps = (state, ownProps) => {
+ const loading = isModifyUserPending(state, ownProps.user.name);
+ const error = getModifyUserFailure(state, ownProps.user.name);
+ return {
+ loading,
+ error
+ };
+};
+
const mapDispatchToProps = dispatch => {
return {
modifyUser: (user: User, callback?: () => void) => {
@@ -65,15 +78,6 @@ const mapDispatchToProps = dispatch => {
};
};
-const mapStateToProps = (state, ownProps) => {
- const loading = isModifyUserPending(state, ownProps.user.name);
- const error = getModifyUserFailure(state, ownProps.user.name);
- return {
- loading,
- error
- };
-};
-
export default connect(
mapStateToProps,
mapDispatchToProps
diff --git a/scm-ui/src/users/containers/SingleUser.js b/scm-ui/src/users/containers/SingleUser.js
index 4a827ee75a..9a1633a162 100644
--- a/scm-ui/src/users/containers/SingleUser.js
+++ b/scm-ui/src/users/containers/SingleUser.js
@@ -5,6 +5,7 @@ import {
Page,
Loading,
Navigation,
+ SubNavigation,
Section,
NavLink,
ErrorPage
@@ -16,24 +17,16 @@ import type { User } from "@scm-manager/ui-types";
import type { History } from "history";
import {
fetchUserByName,
- deleteUser,
getUserByName,
isFetchUserPending,
- getFetchUserFailure,
- isDeleteUserPending,
- getDeleteUserFailure
+ getFetchUserFailure
} from "../modules/users";
-
-import {
- DeleteUserNavLink,
- EditUserNavLink,
- SetPasswordNavLink,
- SetPermissionsNavLink
-} from "./../components/navLinks";
+import { EditUserNavLink, SetPasswordNavLink, SetPermissionsNavLink } from "./../components/navLinks";
import { translate } from "react-i18next";
import { getUsersLink } from "../../modules/indexResource";
import SetUserPassword from "../components/SetUserPassword";
import SetPermissions from "../../permissions/components/SetPermissions";
+import {ExtensionPoint} from "@scm-manager/ui-extensions";
type Props = {
name: string,
@@ -42,8 +35,7 @@ type Props = {
error: Error,
usersLink: string,
- // dispatcher functions
- deleteUser: (user: User, callback?: () => void) => void,
+ // dispatcher function
fetchUserByName: (string, string) => void,
// context objects
@@ -57,14 +49,6 @@ class SingleUser extends React.Component