mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
renamed navlink to simple delete
This commit is contained in:
@@ -7,19 +7,18 @@ import type { Repository } from "@scm-manager/ui-types";
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
confirmDialog?: boolean,
|
||||
delete: Repository => void,
|
||||
|
||||
// context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class DeleteNavAction extends React.Component<Props> {
|
||||
class DeleteRepo extends React.Component<Props> {
|
||||
static defaultProps = {
|
||||
confirmDialog: true
|
||||
};
|
||||
|
||||
delete = () => {
|
||||
this.props.delete(this.props.repository);
|
||||
//this.props.delete(this.props.repository);
|
||||
};
|
||||
|
||||
confirmDelete = () => {
|
||||
@@ -68,4 +67,4 @@ class DeleteNavAction extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("repos")(DeleteNavAction);
|
||||
export default translate("repos")(DeleteRepo);
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { mount, shallow } from "enzyme";
|
||||
import "../../tests/enzyme";
|
||||
import "../../tests/i18n";
|
||||
import DeleteNavAction from "./DeleteNavAction";
|
||||
import DeleteRepo from "./DeleteRepo";
|
||||
|
||||
import { confirmAlert } from "@scm-manager/ui-components";
|
||||
jest.mock("@scm-manager/ui-components", () => ({
|
||||
@@ -10,14 +10,14 @@ jest.mock("@scm-manager/ui-components", () => ({
|
||||
NavAction: require.requireActual("@scm-manager/ui-components").NavAction
|
||||
}));
|
||||
|
||||
describe("DeleteNavAction", () => {
|
||||
describe("DeleteRepo", () => {
|
||||
it("should render nothing, if the delete link is missing", () => {
|
||||
const repository = {
|
||||
_links: {}
|
||||
};
|
||||
|
||||
const navLink = shallow(
|
||||
<DeleteNavAction repository={repository} delete={() => {}} />
|
||||
<DeleteRepo repository={repository} delete={() => {}} />
|
||||
);
|
||||
expect(navLink.text()).toBe("");
|
||||
});
|
||||
@@ -32,7 +32,7 @@ describe("DeleteNavAction", () => {
|
||||
};
|
||||
|
||||
const navLink = mount(
|
||||
<DeleteNavAction repository={repository} delete={() => {}} />
|
||||
<DeleteRepo repository={repository} delete={() => {}} />
|
||||
);
|
||||
expect(navLink.text()).not.toBe("");
|
||||
});
|
||||
@@ -47,7 +47,7 @@ describe("DeleteNavAction", () => {
|
||||
};
|
||||
|
||||
const navLink = mount(
|
||||
<DeleteNavAction repository={repository} delete={() => {}} />
|
||||
<DeleteRepo repository={repository} delete={() => {}} />
|
||||
);
|
||||
navLink.find("a").simulate("click");
|
||||
|
||||
@@ -69,7 +69,7 @@ describe("DeleteNavAction", () => {
|
||||
}
|
||||
|
||||
const navLink = mount(
|
||||
<DeleteNavAction
|
||||
<DeleteRepo
|
||||
repository={repository}
|
||||
confirmDialog={false}
|
||||
delete={capture}
|
||||
@@ -1,8 +1,9 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import RepositoryForm from "../components/form";
|
||||
import DeleteRepo from "../components/DeleteRepo";
|
||||
import type { Repository } from "@scm-manager/ui-types";
|
||||
import {
|
||||
modifyRepo,
|
||||
@@ -10,23 +11,22 @@ import {
|
||||
getModifyRepoFailure,
|
||||
modifyRepoReset
|
||||
} from "../modules/repos";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import type { History } from "history";
|
||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
modifyRepo: (Repository, () => void) => void,
|
||||
modifyRepoReset: Repository => void,
|
||||
loading: boolean,
|
||||
error: Error,
|
||||
|
||||
modifyRepo: (Repository, () => void) => void,
|
||||
modifyRepoReset: Repository => void,
|
||||
|
||||
// context props
|
||||
t: string => string,
|
||||
repository: Repository,
|
||||
history: History
|
||||
};
|
||||
|
||||
class Edit extends React.Component<Props> {
|
||||
class GeneralRepo extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
const { modifyRepoReset, repository } = this.props;
|
||||
modifyRepoReset(repository);
|
||||
@@ -37,7 +37,7 @@ class Edit extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { loading, error } = this.props;
|
||||
const { loading, error, repository } = this.props;
|
||||
return (
|
||||
<div>
|
||||
<ErrorNotification error={error} />
|
||||
@@ -49,7 +49,7 @@ class Edit extends React.Component<Props> {
|
||||
}}
|
||||
/>
|
||||
<hr />
|
||||
<p>TODO: DeleteRepo hier einbinden. Aktuell heißt es noch DeleteNavAction</p>
|
||||
<DeleteRepo repository={repository} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -79,4 +79,4 @@ const mapDispatchToProps = dispatch => {
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("repos")(withRouter(Edit)));
|
||||
)(withRouter(GeneralRepo));
|
||||
@@ -9,12 +9,10 @@ import type {Repository} from "@scm-manager/ui-types";
|
||||
import {ErrorPage, Loading, Navigation, SubNavigation, NavLink, Page, Section} from "@scm-manager/ui-components";
|
||||
import {translate} from "react-i18next";
|
||||
import RepositoryDetails from "../components/RepositoryDetails";
|
||||
import DeleteNavAction from "../components/DeleteNavAction";
|
||||
import Edit from "../containers/Edit";
|
||||
import GeneralRepo from "./GeneralRepo";
|
||||
import Permissions from "../permissions/containers/Permissions";
|
||||
|
||||
import type {History} from "history";
|
||||
import EditNavLink from "../components/EditNavLink";
|
||||
|
||||
import BranchRoot from "./ChangesetsRoot";
|
||||
import ChangesetView from "./ChangesetView";
|
||||
@@ -110,7 +108,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/settings/general`}
|
||||
component={() => <Edit repository={repository} />}
|
||||
component={() => <GeneralRepo repository={repository} />}
|
||||
/>
|
||||
<Route
|
||||
path={`${url}/settings/permissions`}
|
||||
@@ -189,7 +187,7 @@ class RepositoryRoot extends React.Component<Props> {
|
||||
to={`${url}/settings/general`}
|
||||
label={t("repository-root.menu.settingsNavLink")}
|
||||
>
|
||||
<EditNavLink repository={repository} editUrl={`${url}/settings/general`} />
|
||||
<NavLink repository={repository} editUrl={`${url}/settings/general`} />
|
||||
<PermissionsNavLink
|
||||
permissionUrl={`${url}/settings/permissions`}
|
||||
repository={repository}
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Subtitle, DeleteButton, confirmAlert } from "@scm-manager/ui-components";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import {
|
||||
Subtitle,
|
||||
DeleteButton,
|
||||
confirmAlert
|
||||
} from "@scm-manager/ui-components";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
deleteUser,
|
||||
fetchUserByName,
|
||||
getDeleteUserFailure,
|
||||
getUserByName,
|
||||
isDeleteUserPending
|
||||
} from "../modules/users";
|
||||
import type { History } from "history";
|
||||
|
||||
type Props = {
|
||||
@@ -31,6 +19,10 @@ type Props = {
|
||||
};
|
||||
|
||||
class DeleteUser extends React.Component<Props> {
|
||||
static defaultProps = {
|
||||
confirmDialog: true
|
||||
};
|
||||
|
||||
userDeleted = () => {
|
||||
this.props.history.push("/users");
|
||||
};
|
||||
@@ -39,10 +31,6 @@ class DeleteUser extends React.Component<Props> {
|
||||
this.props.deleteUser(user, this.userDeleted);
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
confirmDialog: true
|
||||
};
|
||||
|
||||
deleteUser = () => {
|
||||
this.props.deleteUser(this.props.user);
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import UserForm from "./../components/UserForm";
|
||||
import DeleteUser from "./../components/DeleteUser";
|
||||
import UserForm from "../components/UserForm";
|
||||
import DeleteUser from "../components/DeleteUser";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import {
|
||||
modifyUser,
|
||||
@@ -57,6 +57,15 @@ class GeneralUser extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
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) => {
|
||||
@@ -68,15 +77,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
|
||||
|
||||
Reference in New Issue
Block a user