mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
open repo page after repo is created
This commit is contained in:
@@ -29,7 +29,11 @@ type Props = {
|
|||||||
|
|
||||||
// dispatch functions
|
// dispatch functions
|
||||||
fetchRepositoryTypesIfNeeded: () => void,
|
fetchRepositoryTypesIfNeeded: () => void,
|
||||||
createRepo: (link: string, Repository, callback: () => void) => void,
|
createRepo: (
|
||||||
|
link: string,
|
||||||
|
Repository,
|
||||||
|
callback: (repo: Repository) => void
|
||||||
|
) => void,
|
||||||
resetForm: () => void,
|
resetForm: () => void,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
@@ -45,8 +49,8 @@ class Create extends React.Component<Props> {
|
|||||||
|
|
||||||
repoCreated = (repo: Repository) => {
|
repoCreated = (repo: Repository) => {
|
||||||
const { history } = this.props;
|
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() {
|
render() {
|
||||||
@@ -71,7 +75,9 @@ class Create extends React.Component<Props> {
|
|||||||
repositoryTypes={repositoryTypes}
|
repositoryTypes={repositoryTypes}
|
||||||
loading={createLoading}
|
loading={createLoading}
|
||||||
submitForm={repo => {
|
submitForm={repo => {
|
||||||
createRepo(repoLink, repo, () => this.repoCreated(repo));
|
createRepo(repoLink, repo, (repo: Repository) =>
|
||||||
|
this.repoCreated(repo)
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -164,16 +164,21 @@ export function fetchRepoFailure(
|
|||||||
export function createRepo(
|
export function createRepo(
|
||||||
link: string,
|
link: string,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
callback?: () => void
|
callback?: (repo: Repository) => void
|
||||||
) {
|
) {
|
||||||
return function(dispatch: any) {
|
return function(dispatch: any) {
|
||||||
dispatch(createRepoPending());
|
dispatch(createRepoPending());
|
||||||
return apiClient
|
return apiClient
|
||||||
.post(link, repository, CONTENT_TYPE)
|
.post(link, repository, CONTENT_TYPE)
|
||||||
.then(() => {
|
.then(response => {
|
||||||
|
const location = response.headers.get("Location");
|
||||||
dispatch(createRepoSuccess());
|
dispatch(createRepoSuccess());
|
||||||
|
return apiClient.get(location);
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback(response);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
Reference in New Issue
Block a user