Merge with 2.0.0-m3

This commit is contained in:
René Pfeuffer
2019-04-04 11:00:20 +02:00
5 changed files with 10 additions and 18 deletions

View File

@@ -44,8 +44,6 @@
"subtitle": "Erstellen eines neuen Repository"
},
"branches": {
"errorTitle": "Fehler",
"errorSubtitle": "Unbekannter Branch Fehler",
"overview": {
"title": "Übersicht aller verfügbaren Branches",
"createButton": "Branch erstellen"

View File

@@ -47,8 +47,6 @@
"subtitle": "Create a new repository"
},
"branches": {
"errorTitle": "Error",
"errorSubtitle": "Unknown branch error",
"overview": {
"title": "Overview of all branches",
"createButton": "Create Branch"

View File

@@ -3,7 +3,6 @@ import React from "react";
import BranchView from "../components/BranchView";
import { connect } from "react-redux";
import { Redirect, Route, Switch, withRouter } from "react-router-dom";
import { translate } from "react-i18next";
import type { Repository, Branch } from "@scm-manager/ui-types";
import {
fetchBranch,
@@ -11,8 +10,9 @@ import {
getFetchBranchFailure,
isFetchBranchPending
} from "../modules/branches";
import { ErrorPage, Loading } from "@scm-manager/ui-components";
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
import type { History } from "history";
import { NotFoundError } from "@scm-manager/ui-components";
type Props = {
repository: Repository,
@@ -22,7 +22,6 @@ type Props = {
error?: Error,
// context props
t: string => string,
history: History,
match: any,
location: any,
@@ -55,7 +54,6 @@ class BranchRoot extends React.Component<Props> {
branch,
loading,
error,
t,
match,
location
} = this.props;
@@ -63,16 +61,12 @@ class BranchRoot extends React.Component<Props> {
const url = this.matchedUrl();
if (error) {
if(location.search.indexOf("?create=true") > -1) {
if(error instanceof NotFoundError && location.search.indexOf("?create=true") > -1) {
return <Redirect to={`/repo/${repository.namespace}/${repository.name}/branches/create?name=${match.params.branch}`} />;
}
return (
<ErrorPage
title={t("branches.errorTitle")}
subtitle={t("branches.errorSubtitle")}
error={error}
/>
<ErrorNotification error={error} />
);
}
@@ -121,5 +115,5 @@ export default withRouter(
connect(
mapStateToProps,
mapDispatchToProps
)(translate("repos")(BranchRoot))
)(BranchRoot)
);

View File

@@ -79,15 +79,16 @@ public class BranchRootResource {
@ResponseCode(code = 500, condition = "internal server error")
})
public Response get(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("branch") String branchName) throws IOException {
try (RepositoryService repositoryService = serviceFactory.create(new NamespaceAndName(namespace, name))) {
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, name);
try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) {
Branches branches = repositoryService.getBranchesCommand().getBranches();
return branches.getBranches()
.stream()
.filter(branch -> branchName.equals(branch.getName()))
.findFirst()
.map(branch -> branchToDtoMapper.map(branch, new NamespaceAndName(namespace, name)))
.map(branch -> branchToDtoMapper.map(branch, namespaceAndName))
.map(Response::ok)
.orElse(Response.status(Response.Status.NOT_FOUND))
.orElseThrow(() -> notFound(entity("branch", branchName).in(namespaceAndName)))
.build();
} catch (CommandNotSupportedException ex) {
return Response.status(Response.Status.BAD_REQUEST).build();

View File

@@ -129,6 +129,7 @@ public class BranchRootResourceTest extends RepositoryTestBase {
dispatcher.invoke(request, response);
assertEquals(404, response.getStatus());
assertEquals("application/vnd.scmm-error+json;v=2", response.getOutputHeaders().getFirst("Content-Type"));
}
@Test