diff --git a/pom.xml b/pom.xml index e04a47ef41..5b300fb634 100644 --- a/pom.xml +++ b/pom.xml @@ -386,7 +386,7 @@ com.github.sdorra buildfrontend-maven-plugin - 2.1.1 + 2.2.0 org.apache.maven.plugins @@ -817,6 +817,10 @@ **/*StoreFactory.java,**/*UserPassword.js + 8.11.4 + ./scm-ui/target/frontend/buildfrontend-node/node-v${node.version}-linux-x64/bin/node + + diff --git a/scm-ui/src/groups/containers/AddGroup.js b/scm-ui/src/groups/containers/AddGroup.js index c19f6156d1..69c1171ea9 100644 --- a/scm-ui/src/groups/containers/AddGroup.js +++ b/scm-ui/src/groups/containers/AddGroup.js @@ -68,11 +68,13 @@ class AddGroup extends React.Component { }); }); }; - groupCreated = () => { - this.props.history.push("/groups"); + groupCreated = (group: Group) => { + this.props.history.push("/group/" + group.name); }; createGroup = (group: Group) => { - this.props.createGroup(this.props.createLink, group, this.groupCreated); + this.props.createGroup(this.props.createLink, group, () => + this.groupCreated(group) + ); }; } diff --git a/scm-ui/src/repos/containers/Create.js b/scm-ui/src/repos/containers/Create.js index 4cf8d468de..2cdd61fbbd 100644 --- a/scm-ui/src/repos/containers/Create.js +++ b/scm-ui/src/repos/containers/Create.js @@ -29,7 +29,11 @@ type Props = { // dispatch functions fetchRepositoryTypesIfNeeded: () => void, - createRepo: (link: string, Repository, callback: () => void) => void, + createRepo: ( + link: string, + Repository, + callback: (repo: Repository) => void + ) => void, resetForm: () => void, // context props @@ -43,9 +47,10 @@ class Create extends React.Component { this.props.fetchRepositoryTypesIfNeeded(); } - repoCreated = () => { + repoCreated = (repo: Repository) => { const { history } = this.props; - history.push("/repos"); + + history.push("/repo/" + repo.namespace + "/" + repo.name); }; render() { @@ -70,7 +75,9 @@ class Create extends React.Component { repositoryTypes={repositoryTypes} loading={createLoading} submitForm={repo => { - createRepo(repoLink, repo, this.repoCreated); + createRepo(repoLink, repo, (repo: Repository) => + this.repoCreated(repo) + ); }} /> diff --git a/scm-ui/src/repos/modules/repos.js b/scm-ui/src/repos/modules/repos.js index 3e574aa938..aa77b4553b 100644 --- a/scm-ui/src/repos/modules/repos.js +++ b/scm-ui/src/repos/modules/repos.js @@ -164,16 +164,21 @@ export function fetchRepoFailure( export function createRepo( link: string, repository: Repository, - callback?: () => void + callback?: (repo: Repository) => void ) { return function(dispatch: any) { dispatch(createRepoPending()); return apiClient .post(link, repository, CONTENT_TYPE) - .then(() => { + .then(response => { + const location = response.headers.get("Location"); dispatch(createRepoSuccess()); + return apiClient.get(location); + }) + .then(response => response.json()) + .then(response => { if (callback) { - callback(); + callback(response); } }) .catch(err => { diff --git a/scm-ui/src/repos/modules/repos.test.js b/scm-ui/src/repos/modules/repos.test.js index e8d9873e99..ca4b6802b8 100644 --- a/scm-ui/src/repos/modules/repos.test.js +++ b/scm-ui/src/repos/modules/repos.test.js @@ -415,9 +415,14 @@ describe("repos fetch", () => { it("should successfully create repo slarti/fjords", () => { fetchMock.postOnce(REPOS_URL, { - status: 201 + status: 201, + headers: { + location: "repositories/slarti/fjords" + } }); + fetchMock.getOnce(REPOS_URL + "/slarti/fjords", slartiFjords); + const expectedActions = [ { type: CREATE_REPO_PENDING @@ -435,12 +440,19 @@ describe("repos fetch", () => { it("should successfully create repo slarti/fjords and call the callback", () => { fetchMock.postOnce(REPOS_URL, { - status: 201 + status: 201, + headers: { + location: "repositories/slarti/fjords" + } }); + + fetchMock.getOnce(REPOS_URL + "/slarti/fjords", slartiFjords); + let callMe = "not yet"; - const callback = () => { + const callback = (r: any) => { + expect(r).toEqual(slartiFjords); callMe = "yeah"; }; diff --git a/scm-ui/src/users/containers/AddUser.js b/scm-ui/src/users/containers/AddUser.js index 1ee6fc759d..f19f974265 100644 --- a/scm-ui/src/users/containers/AddUser.js +++ b/scm-ui/src/users/containers/AddUser.js @@ -12,7 +12,7 @@ import { } from "../modules/users"; import { Page } from "@scm-manager/ui-components"; import { translate } from "react-i18next"; -import {getUsersLink} from "../../modules/indexResource"; +import { getUsersLink } from "../../modules/indexResource"; type Props = { loading?: boolean, @@ -33,13 +33,15 @@ class AddUser extends React.Component { this.props.resetForm(); } - userCreated = () => { + userCreated = (user: User) => { const { history } = this.props; - history.push("/users"); + history.push("/user/" + user.name); }; createUser = (user: User) => { - this.props.addUser(this.props.usersLink, user, this.userCreated); + this.props.addUser(this.props.usersLink, user, () => + this.userCreated(user) + ); }; render() {