diff --git a/scm-ui/src/repos/containers/Create.js b/scm-ui/src/repos/containers/Create.js index 2d41811723..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 @@ -45,8 +49,8 @@ class Create extends React.Component { repoCreated = (repo: Repository) => { const { history } = this.props; - //TODO: Problem: repo name can be set in history, but repo namespace is not known without fetching anything - history.push("/repos"); + + history.push("/repo/" + repo.namespace + "/" + repo.name); }; render() { @@ -71,7 +75,9 @@ class Create extends React.Component { repositoryTypes={repositoryTypes} loading={createLoading} submitForm={repo => { - createRepo(repoLink, repo, () => this.repoCreated(repo)); + 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 => {