mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
updates users structure
This commit is contained in:
@@ -9,6 +9,7 @@ import Loading from "../../components/Loading";
|
|||||||
type Props = {
|
type Props = {
|
||||||
submitForm: User => void,
|
submitForm: User => void,
|
||||||
user?: User,
|
user?: User,
|
||||||
|
loading?: boolean,
|
||||||
t: string => string
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,49 +39,49 @@ class UserForm extends React.Component<Props, User> {
|
|||||||
render() {
|
render() {
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
const user = this.state;
|
const user = this.state;
|
||||||
|
if (user) {
|
||||||
let nameField = null;
|
return (
|
||||||
if (!this.props.user) {
|
<form onSubmit={this.submit}>
|
||||||
nameField = (
|
<InputField
|
||||||
<InputField
|
label={t("user.name")}
|
||||||
label={t("user.name")}
|
onChange={this.handleUsernameChange}
|
||||||
onChange={this.handleUsernameChange}
|
value={user ? user.name : ""}
|
||||||
value={user ? user.name : ""}
|
/>
|
||||||
/>
|
<InputField
|
||||||
|
label={t("user.displayName")}
|
||||||
|
onChange={this.handleDisplayNameChange}
|
||||||
|
value={user ? user.displayName : ""}
|
||||||
|
/>
|
||||||
|
<InputField
|
||||||
|
label={t("user.mail")}
|
||||||
|
onChange={this.handleEmailChange}
|
||||||
|
value={user ? user.mail : ""}
|
||||||
|
/>
|
||||||
|
<InputField
|
||||||
|
label={t("user.password")}
|
||||||
|
type="password"
|
||||||
|
onChange={this.handlePasswordChange}
|
||||||
|
value={user ? user.password : ""}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
label={t("user.admin")}
|
||||||
|
onChange={this.handleAdminChange}
|
||||||
|
checked={user ? user.admin : false}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
label={t("user.active")}
|
||||||
|
onChange={this.handleActiveChange}
|
||||||
|
checked={user ? user.active : false}
|
||||||
|
/>
|
||||||
|
<SubmitButton
|
||||||
|
label={t("user-form.submit")}
|
||||||
|
loading={this.props.loading}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return <Loading />;
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
<form onSubmit={this.submit}>
|
|
||||||
{nameField}
|
|
||||||
<InputField
|
|
||||||
label={t("user.displayName")}
|
|
||||||
onChange={this.handleDisplayNameChange}
|
|
||||||
value={user ? user.displayName : ""}
|
|
||||||
/>
|
|
||||||
<InputField
|
|
||||||
label={t("user.mail")}
|
|
||||||
onChange={this.handleEmailChange}
|
|
||||||
value={user ? user.mail : ""}
|
|
||||||
/>
|
|
||||||
<InputField
|
|
||||||
label={t("user.password")}
|
|
||||||
type="password"
|
|
||||||
onChange={this.handlePasswordChange}
|
|
||||||
value={user ? user.password : ""}
|
|
||||||
/>
|
|
||||||
<Checkbox
|
|
||||||
label={t("user.admin")}
|
|
||||||
onChange={this.handleAdminChange}
|
|
||||||
checked={user ? user.admin : false}
|
|
||||||
/>
|
|
||||||
<Checkbox
|
|
||||||
label={t("user.active")}
|
|
||||||
onChange={this.handleActiveChange}
|
|
||||||
checked={user ? user.active : false}
|
|
||||||
/>
|
|
||||||
<SubmitButton label={t("user-form.submit")} />
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleUsernameChange = (name: string) => {
|
handleUsernameChange = (name: string) => {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../../types/User";
|
||||||
import { confirmAlert } from "../../components/modals/ConfirmAlert";
|
import { confirmAlert } from "../../../components/modals/ConfirmAlert";
|
||||||
import { NavAction } from "../../components/navigation";
|
import { NavAction } from "../../../components/navigation";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: User,
|
user: User,
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, shallow } from "enzyme";
|
import { mount, shallow } from "enzyme";
|
||||||
import "../../tests/enzyme";
|
import "../../../tests/enzyme";
|
||||||
import "../../tests/i18n";
|
import "../../../tests/i18n";
|
||||||
import DeleteUserButton from "./DeleteUserButton";
|
import DeleteUserButton from "./DeleteUserButton";
|
||||||
|
|
||||||
import { confirmAlert } from "../../components/modals/ConfirmAlert";
|
import { confirmAlert } from "../../../components/modals/ConfirmAlert";
|
||||||
jest.mock("../../components/modals/ConfirmAlert");
|
jest.mock("../../../components/modals/ConfirmAlert");
|
||||||
|
|
||||||
describe("DeleteUserButton", () => {
|
describe("DeleteUserButton", () => {
|
||||||
it("should render nothing, if the delete link is missing", () => {
|
it("should render nothing, if the delete link is missing", () => {
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { EditButton } from "../../components/buttons";
|
import { EditButton } from "../../../components/buttons";
|
||||||
import type { UserEntry } from "../types/UserEntry";
|
import type { UserEntry } from "../../types/UserEntry";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
t: string => string,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import "../../tests/enzyme";
|
import "../../../tests/enzyme";
|
||||||
import "../../tests/i18n";
|
import "../../../tests/i18n";
|
||||||
import EditUserButton from "./EditUserButton";
|
import EditUserButton from "./EditUserButton";
|
||||||
|
|
||||||
it("should render nothing, if the edit link is missing", () => {
|
it("should render nothing, if the edit link is missing", () => {
|
||||||
2
scm-ui/src/users/components/buttons/index.js
Normal file
2
scm-ui/src/users/components/buttons/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export { default as DeleteUserButton } from "./DeleteUserButton";
|
||||||
|
export { default as EditUserButton } from "./EditUserButton";
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../../types/User";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Checkbox } from "../../components/forms";
|
import { Checkbox } from "../../../components/forms";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: User,
|
user: User,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../../types/User";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: User
|
user: User
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import UserRow from "./UserRow";
|
import UserRow from "./UserRow";
|
||||||
import type { UserEntry } from "../types/UserEntry";
|
import type { UserEntry } from "../../types/UserEntry";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
t: string => string,
|
t: string => string,
|
||||||
3
scm-ui/src/users/components/table/index.js
Normal file
3
scm-ui/src/users/components/table/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export { default as Details } from "./Details";
|
||||||
|
export { default as UserRow } from "./UserRow";
|
||||||
|
export { default as UserTable } from "./UserTable";
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import UserForm from "./UserForm";
|
import UserForm from "./../components/UserForm";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../types/User";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { createUser } from "../modules/users";
|
import { createUser } from "../modules/users";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import UserForm from "./UserForm";
|
import UserForm from "./../components/UserForm";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../types/User";
|
||||||
import { modifyUser } from "../modules/users";
|
import { modifyUser } from "../modules/users";
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Page } from "../../components/layout";
|
import { Page } from "../../components/layout";
|
||||||
import { Route } from "react-router";
|
import { Route } from "react-router";
|
||||||
import Details from "./Details";
|
import { Details } from "./../components/table";
|
||||||
import EditUser from "./EditUser";
|
import EditUser from "./EditUser";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../types/User";
|
||||||
import type { UserEntry } from "../types/UserEntry";
|
import type { UserEntry } from "../types/UserEntry";
|
||||||
@@ -11,7 +11,7 @@ import { fetchUser, deleteUser } from "../modules/users";
|
|||||||
import Loading from "../../components/Loading";
|
import Loading from "../../components/Loading";
|
||||||
|
|
||||||
import { Navigation, Section, NavLink } from "../../components/navigation";
|
import { Navigation, Section, NavLink } from "../../components/navigation";
|
||||||
import DeleteUserButton from "./DeleteUserButton";
|
import { DeleteUserButton } from "./../components/buttons";
|
||||||
import ErrorPage from "../../components/ErrorPage";
|
import ErrorPage from "../../components/ErrorPage";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { translate } from "react-i18next";
|
|||||||
|
|
||||||
import { fetchUsers, getUsersFromState } from "../modules/users";
|
import { fetchUsers, getUsersFromState } from "../modules/users";
|
||||||
import { Page } from "../../components/layout";
|
import { Page } from "../../components/layout";
|
||||||
import UserTable from "./UserTable";
|
import { UserTable } from "./../components/table";
|
||||||
import type { User } from "../types/User";
|
import type { User } from "../types/User";
|
||||||
import { AddButton } from "../../components/buttons";
|
import { AddButton } from "../../components/buttons";
|
||||||
import type { UserEntry } from "../types/UserEntry";
|
import type { UserEntry } from "../types/UserEntry";
|
||||||
|
|||||||
Reference in New Issue
Block a user