mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
moved edit and delete funcs
This commit is contained in:
@@ -5,18 +5,27 @@ import type { Group } from "@scm-manager/ui-types";
|
|||||||
import {
|
import {
|
||||||
Subtitle,
|
Subtitle,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
confirmAlert
|
confirmAlert,
|
||||||
|
ErrorNotification
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import { getDeleteGroupFailure, isDeleteGroupPending } from "../modules/groups";
|
import {
|
||||||
|
deleteGroup,
|
||||||
|
getDeleteGroupFailure,
|
||||||
|
isDeleteGroupPending,
|
||||||
|
} from "../modules/groups";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
import {withRouter} from "react-router-dom";
|
||||||
|
import type {History} from "history";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
error: Error,
|
||||||
group: Group,
|
group: Group,
|
||||||
confirmDialog?: boolean,
|
confirmDialog?: boolean,
|
||||||
deleteGroup: (group: Group) => void,
|
deleteGroup: (group: Group, callback?: () => void) => void,
|
||||||
|
|
||||||
|
// context props
|
||||||
|
history: History,
|
||||||
t: string => string
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,7 +35,11 @@ export class DeleteGroup extends React.Component<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
deleteGroup = () => {
|
deleteGroup = () => {
|
||||||
this.props.deleteGroup(this.props.group);
|
this.props.deleteGroup(this.props.group, this.groupDeleted);
|
||||||
|
};
|
||||||
|
|
||||||
|
groupDeleted = () => {
|
||||||
|
this.props.history.push("/groups");
|
||||||
};
|
};
|
||||||
|
|
||||||
confirmDelete = () => {
|
confirmDelete = () => {
|
||||||
@@ -86,4 +99,12 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(translate("groups")(DeleteGroup));
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
deleteGroup: (group: Group, callback?: () => void) => {
|
||||||
|
dispatch(deleteGroup(group, callback));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(translate("groups")(DeleteGroup)));
|
||||||
@@ -4,7 +4,6 @@ import { connect } from "react-redux";
|
|||||||
import GroupForm from "../components/GroupForm";
|
import GroupForm from "../components/GroupForm";
|
||||||
import {
|
import {
|
||||||
modifyGroup,
|
modifyGroup,
|
||||||
deleteGroup,
|
|
||||||
getModifyGroupFailure,
|
getModifyGroupFailure,
|
||||||
isModifyGroupPending,
|
isModifyGroupPending,
|
||||||
modifyGroupReset
|
modifyGroupReset
|
||||||
@@ -14,14 +13,13 @@ import { withRouter } from "react-router-dom";
|
|||||||
import type { Group } from "@scm-manager/ui-types";
|
import type { Group } from "@scm-manager/ui-types";
|
||||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||||
import { getUserAutoCompleteLink } from "../../modules/indexResource";
|
import { getUserAutoCompleteLink } from "../../modules/indexResource";
|
||||||
import DeleteGroup from "../components/DeleteGroup";
|
import DeleteGroup from "./DeleteGroup";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
group: Group,
|
group: Group,
|
||||||
fetchGroup: (name: string) => void,
|
fetchGroup: (name: string) => void,
|
||||||
modifyGroup: (group: Group, callback?: () => void) => void,
|
modifyGroup: (group: Group, callback?: () => void) => void,
|
||||||
modifyGroupReset: Group => void,
|
modifyGroupReset: Group => void,
|
||||||
deleteGroup: (group: Group, callback?: () => void) => void,
|
|
||||||
autocompleteLink: string,
|
autocompleteLink: string,
|
||||||
history: History,
|
history: History,
|
||||||
loading?: boolean,
|
loading?: boolean,
|
||||||
@@ -42,14 +40,6 @@ class EditGroup extends React.Component<Props> {
|
|||||||
this.props.modifyGroup(group, this.groupModified(group));
|
this.props.modifyGroup(group, this.groupModified(group));
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteGroup = (group: Group) => {
|
|
||||||
this.props.deleteGroup(group, this.groupDeleted);
|
|
||||||
};
|
|
||||||
|
|
||||||
groupDeleted = () => {
|
|
||||||
this.props.history.push("/groups");
|
|
||||||
};
|
|
||||||
|
|
||||||
loadUserAutocompletion = (inputValue: string) => {
|
loadUserAutocompletion = (inputValue: string) => {
|
||||||
const url = this.props.autocompleteLink + "?q=";
|
const url = this.props.autocompleteLink + "?q=";
|
||||||
return fetch(url + inputValue)
|
return fetch(url + inputValue)
|
||||||
@@ -78,7 +68,7 @@ class EditGroup extends React.Component<Props> {
|
|||||||
loadUserSuggestions={this.loadUserAutocompletion}
|
loadUserSuggestions={this.loadUserAutocompletion}
|
||||||
/>
|
/>
|
||||||
<hr />
|
<hr />
|
||||||
<DeleteGroup group={group} deleteGroup={this.deleteGroup} />
|
<DeleteGroup group={group} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -102,9 +92,6 @@ const mapDispatchToProps = dispatch => {
|
|||||||
},
|
},
|
||||||
modifyGroupReset: (group: Group) => {
|
modifyGroupReset: (group: Group) => {
|
||||||
dispatch(modifyGroupReset(group));
|
dispatch(modifyGroupReset(group));
|
||||||
},
|
|
||||||
deleteGroup: (group: Group, callback?: () => void) => {
|
|
||||||
dispatch(deleteGroup(group, callback));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,19 +8,24 @@ import {
|
|||||||
confirmAlert,
|
confirmAlert,
|
||||||
ErrorNotification
|
ErrorNotification
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import { getDeleteRepoFailure, isDeleteRepoPending } from "../modules/repos";
|
import {
|
||||||
|
deleteRepo,
|
||||||
|
getDeleteRepoFailure,
|
||||||
|
isDeleteRepoPending,
|
||||||
|
} from "../modules/repos";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import {withRouter} from "react-router-dom";
|
||||||
|
import type {History} from "history";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
error: Error,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
confirmDialog?: boolean,
|
confirmDialog?: boolean,
|
||||||
|
deleteRepo: (Repository, () => void) => void,
|
||||||
// dispatcher functions
|
|
||||||
delete: Repository => void,
|
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
|
history: History,
|
||||||
t: string => string
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,8 +34,12 @@ class DeleteRepo extends React.Component<Props> {
|
|||||||
confirmDialog: true
|
confirmDialog: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deleted = () => {
|
||||||
|
this.props.history.push("/repos");
|
||||||
|
};
|
||||||
|
|
||||||
deleteRepo = () => {
|
deleteRepo = () => {
|
||||||
this.props.delete(this.props.repository);
|
this.props.deleteRepo(this.props.repository, this.deleted);
|
||||||
};
|
};
|
||||||
|
|
||||||
confirmDelete = () => {
|
confirmDelete = () => {
|
||||||
@@ -91,4 +100,15 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(translate("repos")(DeleteRepo));
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
deleteRepo: (repo: Repository, callback: () => void) => {
|
||||||
|
dispatch(deleteRepo(repo, callback));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(withRouter(translate("repos")(DeleteRepo)));
|
||||||
@@ -32,7 +32,7 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} store={store} />
|
<DeleteRepo repository={repository} store={store} />
|
||||||
);
|
);
|
||||||
expect(navLink.text()).toBeNull();
|
expect(navLink.text()).toBeNull();
|
||||||
});
|
});
|
||||||
@@ -47,7 +47,7 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} store={store} />,
|
<DeleteRepo repository={repository} store={store} />,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
expect(navLink.text()).not.toBe("");
|
expect(navLink.text()).not.toBe("");
|
||||||
@@ -63,7 +63,7 @@ describe("DeleteRepo", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo repository={repository} delete={() => {}} store={store} />,
|
<DeleteRepo repository={repository} store={store} />,
|
||||||
options.get()
|
options.get()
|
||||||
);
|
);
|
||||||
navLink.find("button").simulate("click");
|
navLink.find("button").simulate("click");
|
||||||
@@ -80,16 +80,10 @@ describe("DeleteRepo", () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let calledUrl = null;
|
|
||||||
function capture(repository) {
|
|
||||||
calledUrl = repository._links.delete.href;
|
|
||||||
}
|
|
||||||
|
|
||||||
const navLink = mount(
|
const navLink = mount(
|
||||||
<DeleteRepo
|
<DeleteRepo
|
||||||
repository={repository}
|
repository={repository}
|
||||||
confirmDialog={false}
|
confirmDialog={false}
|
||||||
delete={capture}
|
|
||||||
store={store}
|
store={store}
|
||||||
/>,
|
/>,
|
||||||
options.get()
|
options.get()
|
||||||
@@ -3,11 +3,10 @@ import React from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import RepositoryForm from "../components/form";
|
import RepositoryForm from "../components/form";
|
||||||
import DeleteRepo from "../components/DeleteRepo";
|
import DeleteRepo from "./DeleteRepo";
|
||||||
import type { Repository } from "@scm-manager/ui-types";
|
import type { Repository } from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
modifyRepo,
|
modifyRepo,
|
||||||
deleteRepo,
|
|
||||||
isModifyRepoPending,
|
isModifyRepoPending,
|
||||||
getModifyRepoFailure,
|
getModifyRepoFailure,
|
||||||
modifyRepoReset
|
modifyRepoReset
|
||||||
@@ -22,7 +21,6 @@ type Props = {
|
|||||||
|
|
||||||
modifyRepo: (Repository, () => void) => void,
|
modifyRepo: (Repository, () => void) => void,
|
||||||
modifyRepoReset: Repository => void,
|
modifyRepoReset: Repository => void,
|
||||||
deleteRepo: (Repository, () => void) => void,
|
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
@@ -41,14 +39,6 @@ class EditRepo extends React.Component<Props> {
|
|||||||
history.push(`/repo/${repository.namespace}/${repository.name}`);
|
history.push(`/repo/${repository.namespace}/${repository.name}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
deleted = () => {
|
|
||||||
this.props.history.push("/repos");
|
|
||||||
};
|
|
||||||
|
|
||||||
delete = (repository: Repository) => {
|
|
||||||
this.props.deleteRepo(repository, this.deleted);
|
|
||||||
};
|
|
||||||
|
|
||||||
stripEndingSlash = (url: string) => {
|
stripEndingSlash = (url: string) => {
|
||||||
if (url.endsWith("/")) {
|
if (url.endsWith("/")) {
|
||||||
return url.substring(0, url.length - 2);
|
return url.substring(0, url.length - 2);
|
||||||
@@ -86,7 +76,7 @@ class EditRepo extends React.Component<Props> {
|
|||||||
props={extensionProps}
|
props={extensionProps}
|
||||||
renderAll={true}
|
renderAll={true}
|
||||||
/>
|
/>
|
||||||
<DeleteRepo repository={repository} delete={this.delete} />
|
<DeleteRepo repository={repository} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -109,9 +99,6 @@ const mapDispatchToProps = dispatch => {
|
|||||||
},
|
},
|
||||||
modifyRepoReset: (repo: Repository) => {
|
modifyRepoReset: (repo: Repository) => {
|
||||||
dispatch(modifyRepoReset(repo));
|
dispatch(modifyRepoReset(repo));
|
||||||
},
|
|
||||||
deleteRepo: (repo: Repository, callback: () => void) => {
|
|
||||||
dispatch(deleteRepo(repo, callback));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,22 +5,23 @@ import type { User } from "@scm-manager/ui-types";
|
|||||||
import {
|
import {
|
||||||
Subtitle,
|
Subtitle,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
confirmAlert
|
confirmAlert,
|
||||||
|
ErrorNotification
|
||||||
} from "@scm-manager/ui-components";
|
} from "@scm-manager/ui-components";
|
||||||
import { getDeleteUserFailure, isDeleteUserPending } from "../modules/users";
|
import {deleteUser, getDeleteUserFailure, isDeleteUserPending} from "../modules/users";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
import {withRouter} from "react-router-dom";
|
||||||
|
import type {History} from "history";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
loading: boolean,
|
loading: boolean,
|
||||||
error: Error,
|
error: Error,
|
||||||
user: User,
|
user: User,
|
||||||
confirmDialog?: boolean,
|
confirmDialog?: boolean,
|
||||||
|
deleteUser: (user: User, callback?: () => void) => void,
|
||||||
|
|
||||||
// dispatcher functions
|
// context props
|
||||||
deleteUser: (user: User) => void,
|
history: History,
|
||||||
|
|
||||||
// context objects
|
|
||||||
t: string => string
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,8 +30,12 @@ class DeleteUser extends React.Component<Props> {
|
|||||||
confirmDialog: true
|
confirmDialog: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
userDeleted = () => {
|
||||||
|
this.props.history.push("/users");
|
||||||
|
};
|
||||||
|
|
||||||
deleteUser = () => {
|
deleteUser = () => {
|
||||||
this.props.deleteUser(this.props.user);
|
this.props.deleteUser(this.props.user, this.userDeleted);
|
||||||
};
|
};
|
||||||
|
|
||||||
confirmDelete = () => {
|
confirmDelete = () => {
|
||||||
@@ -90,4 +95,12 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(translate("users")(DeleteUser));
|
const mapDispatchToProps = dispatch => {
|
||||||
|
return {
|
||||||
|
deleteUser: (user: User, callback?: () => void) => {
|
||||||
|
dispatch(deleteUser(user, callback));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(translate("users")(DeleteUser)));
|
||||||
@@ -3,16 +3,13 @@ import React from "react";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import UserForm from "../components/UserForm";
|
import UserForm from "../components/UserForm";
|
||||||
import DeleteUser from "../components/DeleteUser";
|
import DeleteUser from "./DeleteUser";
|
||||||
import type { User } from "@scm-manager/ui-types";
|
import type { User } from "@scm-manager/ui-types";
|
||||||
import {
|
import {
|
||||||
modifyUser,
|
modifyUser,
|
||||||
deleteUser,
|
|
||||||
isModifyUserPending,
|
isModifyUserPending,
|
||||||
getModifyUserFailure,
|
getModifyUserFailure,
|
||||||
modifyUserReset,
|
modifyUserReset,
|
||||||
isDeleteUserPending,
|
|
||||||
getDeleteUserFailure
|
|
||||||
} from "../modules/users";
|
} from "../modules/users";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { ErrorNotification } from "@scm-manager/ui-components";
|
import { ErrorNotification } from "@scm-manager/ui-components";
|
||||||
@@ -24,7 +21,6 @@ type Props = {
|
|||||||
// dispatch functions
|
// dispatch functions
|
||||||
modifyUser: (user: User, callback?: () => void) => void,
|
modifyUser: (user: User, callback?: () => void) => void,
|
||||||
modifyUserReset: User => void,
|
modifyUserReset: User => void,
|
||||||
deleteUser: (user: User, callback?: () => void) => void,
|
|
||||||
|
|
||||||
// context objects
|
// context objects
|
||||||
user: User,
|
user: User,
|
||||||
@@ -45,14 +41,6 @@ class EditUser extends React.Component<Props> {
|
|||||||
this.props.modifyUser(user, this.userModified(user));
|
this.props.modifyUser(user, this.userModified(user));
|
||||||
};
|
};
|
||||||
|
|
||||||
userDeleted = () => {
|
|
||||||
this.props.history.push("/users");
|
|
||||||
};
|
|
||||||
|
|
||||||
deleteUser = (user: User) => {
|
|
||||||
this.props.deleteUser(user, this.userDeleted);
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { user, loading, error } = this.props;
|
const { user, loading, error } = this.props;
|
||||||
return (
|
return (
|
||||||
@@ -64,7 +52,7 @@ class EditUser extends React.Component<Props> {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
/>
|
/>
|
||||||
<hr />
|
<hr />
|
||||||
<DeleteUser user={user} deleteUser={this.deleteUser} />
|
<DeleteUser user={user} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -86,9 +74,6 @@ const mapDispatchToProps = dispatch => {
|
|||||||
},
|
},
|
||||||
modifyUserReset: (user: User) => {
|
modifyUserReset: (user: User) => {
|
||||||
dispatch(modifyUserReset(user));
|
dispatch(modifyUserReset(user));
|
||||||
},
|
|
||||||
deleteUser: (user: User, callback?: () => void) => {
|
|
||||||
dispatch(deleteUser(user, callback));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user