call new LegacyRepository-Endpoint on Main.js

This commit is contained in:
Eduard Heimbuch
2019-07-03 15:06:46 +02:00
parent d1b167677b
commit 7211d657f2
3 changed files with 24 additions and 3 deletions

View File

@@ -21,6 +21,12 @@
<version>${servlet.version}</version> <version>${servlet.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>

View File

@@ -9,6 +9,8 @@ import sonia.scm.repository.RepositoryManager;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("v2/legacy/repository") @Path("v2/legacy/repository")
public class LegacyRepositoryService { public class LegacyRepositoryService {
@@ -22,6 +24,7 @@ public class LegacyRepositoryService {
@GET @GET
@Path("{id}") @Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
@StatusCodes({ @StatusCodes({
@ResponseCode(code = 200, condition = "success"), @ResponseCode(code = 200, condition = "success"),
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"), @ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),

View File

@@ -9,7 +9,7 @@ import Users from "../users/containers/Users";
import Login from "../containers/Login"; import Login from "../containers/Login";
import Logout from "../containers/Logout"; import Logout from "../containers/Logout";
import { ProtectedRoute } from "@scm-manager/ui-components"; import { ProtectedRoute, apiClient } from "@scm-manager/ui-components";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions"; import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import CreateUser from "../users/containers/CreateUser"; import CreateUser from "../users/containers/CreateUser";
@@ -27,7 +27,10 @@ import Profile from "./Profile";
type Props = { type Props = {
authenticated?: boolean, authenticated?: boolean,
links: Links links: Links,
//context objects
history: History
}; };
class Main extends React.Component<Props> { class Main extends React.Component<Props> {
@@ -35,6 +38,15 @@ class Main extends React.Component<Props> {
const { authenticated, links } = this.props; const { authenticated, links } = this.props;
const redirectUrlFactory = binder.getExtension("main.redirect", this.props); const redirectUrlFactory = binder.getExtension("main.redirect", this.props);
let url = "/repos"; let url = "/repos";
if (location.href && location.href.includes("#diffPanel;")) {
let repoId = location.href.substring(location.href.search("#diffPanel;") + 11, location.href.search("#diffPanel;") + 21);
console.log("RepoId:");
console.log(repoId);
apiClient.get("/legacy/repository/" + repoId).then(response =>
console.log(JSON.parse(response))
// this.props.history.push("/repo/" + response.responseBody.namespace + "/" + response.responseBody.name)
);
}
if (redirectUrlFactory) { if (redirectUrlFactory) {
url = redirectUrlFactory(this.props); url = redirectUrlFactory(this.props);
} }