From d1b167677b15317374f44ee996796884b68621c4 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 3 Jul 2019 13:21:34 +0200 Subject: [PATCH 1/8] add LegacyPlugin Endpoint to get the repository name + namespace --- .../scm/legacy/LegacyIndexHalEnricher.java | 38 +++++++++++++++++++ .../scm/legacy/LegacyRepositoryService.java | 38 +++++++++++++++++++ .../sonia/scm/legacy/NamespaceAndNameDto.java | 11 ++++++ 3 files changed, 87 insertions(+) create mode 100644 scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyIndexHalEnricher.java create mode 100644 scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java create mode 100644 scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/NamespaceAndNameDto.java diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyIndexHalEnricher.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyIndexHalEnricher.java new file mode 100644 index 0000000000..0914f92e25 --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyIndexHalEnricher.java @@ -0,0 +1,38 @@ +package sonia.scm.legacy; + +import com.google.inject.Inject; +import sonia.scm.api.v2.resources.Enrich; +import sonia.scm.api.v2.resources.HalAppender; +import sonia.scm.api.v2.resources.HalEnricher; +import sonia.scm.api.v2.resources.HalEnricherContext; +import sonia.scm.api.v2.resources.Index; +import sonia.scm.api.v2.resources.LinkBuilder; +import sonia.scm.api.v2.resources.ScmPathInfoStore; +import sonia.scm.plugin.Extension; + +import javax.inject.Provider; + +@Extension +@Enrich(Index.class) +public class LegacyIndexHalEnricher implements HalEnricher { + + private Provider scmPathInfoStoreProvider; + + @Inject + public LegacyIndexHalEnricher(Provider scmPathInfoStoreProvider) { + this.scmPathInfoStoreProvider = scmPathInfoStoreProvider; + } + + private String createLink() { + return new LinkBuilder(scmPathInfoStoreProvider.get().get(), LegacyRepositoryService.class) + .method("getNameAndNamespaceForRepositoryId") + .parameters("REPOID") + .href() + .replace("REPOID", "{id}"); + } + + @Override + public void enrich(HalEnricherContext context, HalAppender appender) { + appender.appendLink("nameAndNamespace", createLink()); + } +} diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java new file mode 100644 index 0000000000..69356ca6fa --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java @@ -0,0 +1,38 @@ +package sonia.scm.legacy; + +import com.google.inject.Inject; +import com.webcohesion.enunciate.metadata.rs.ResponseCode; +import com.webcohesion.enunciate.metadata.rs.StatusCodes; +import sonia.scm.repository.Repository; +import sonia.scm.repository.RepositoryManager; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +@Path("v2/legacy/repository") +public class LegacyRepositoryService { + + private RepositoryManager repositoryManager; + + @Inject + public LegacyRepositoryService(RepositoryManager repositoryManager) { + this.repositoryManager = repositoryManager; + } + + @GET + @Path("{id}") + @StatusCodes({ + @ResponseCode(code = 200, condition = "success"), + @ResponseCode(code = 401, condition = "not authenticated / invalid credentials"), + @ResponseCode(code = 403, condition = "not authorized, the current user does not have the \"repository:read:global\" privilege"), + @ResponseCode(code = 500, condition = "internal server error") + }) + public NamespaceAndNameDto getNameAndNamespaceForRepositoryId(@PathParam("id") String repositoryId) { + Repository repo = repositoryManager.get(repositoryId); + return new NamespaceAndNameDto(repo.getName(), repo.getNamespace()); + + } + +} + diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/NamespaceAndNameDto.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/NamespaceAndNameDto.java new file mode 100644 index 0000000000..2f7aae2dae --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/NamespaceAndNameDto.java @@ -0,0 +1,11 @@ +package sonia.scm.legacy; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public class NamespaceAndNameDto { + private String name; + private String namespace; +} From 7211d657f2c5c4a7e8ff6c71ff98416a20296cf1 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Wed, 3 Jul 2019 15:06:46 +0200 Subject: [PATCH 2/8] call new LegacyRepository-Endpoint on Main.js --- scm-plugins/scm-legacy-plugin/pom.xml | 8 +++++++- .../scm/legacy/LegacyRepositoryService.java | 3 +++ scm-ui/src/containers/Main.js | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scm-plugins/scm-legacy-plugin/pom.xml b/scm-plugins/scm-legacy-plugin/pom.xml index 52aff51dd2..6cfa74ea61 100644 --- a/scm-plugins/scm-legacy-plugin/pom.xml +++ b/scm-plugins/scm-legacy-plugin/pom.xml @@ -21,7 +21,13 @@ ${servlet.version} provided - + + javax.ws.rs + jsr311-api + 1.1.1 + compile + + diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java index 69356ca6fa..9e27c736ea 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java @@ -9,6 +9,8 @@ import sonia.scm.repository.RepositoryManager; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; @Path("v2/legacy/repository") public class LegacyRepositoryService { @@ -22,6 +24,7 @@ public class LegacyRepositoryService { @GET @Path("{id}") + @Produces(MediaType.APPLICATION_JSON) @StatusCodes({ @ResponseCode(code = 200, condition = "success"), @ResponseCode(code = 401, condition = "not authenticated / invalid credentials"), diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index 8681f2457b..129b11f5ba 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -9,7 +9,7 @@ import Users from "../users/containers/Users"; import Login from "../containers/Login"; 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 CreateUser from "../users/containers/CreateUser"; @@ -27,7 +27,10 @@ import Profile from "./Profile"; type Props = { authenticated?: boolean, - links: Links + links: Links, + + //context objects + history: History }; class Main extends React.Component { @@ -35,6 +38,15 @@ class Main extends React.Component { const { authenticated, links } = this.props; const redirectUrlFactory = binder.getExtension("main.redirect", this.props); 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) { url = redirectUrlFactory(this.props); } From 4f1ac2af09fb4d898e2ff46525b81cacbb2c6f6c Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Thu, 4 Jul 2019 12:13:45 +0200 Subject: [PATCH 3/8] move redirect logic to legacy plugin / bind Extensionpoint in Main.js --- scm-plugins/scm-legacy-plugin/package.json | 20 +++++++ .../src/main/js/DummyComponent.js | 15 +++++ .../scm-legacy-plugin/src/main/js/index.js | 55 +++++++++++++++++++ scm-ui/src/containers/Main.js | 15 ++--- 4 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 scm-plugins/scm-legacy-plugin/package.json create mode 100644 scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js create mode 100644 scm-plugins/scm-legacy-plugin/src/main/js/index.js diff --git a/scm-plugins/scm-legacy-plugin/package.json b/scm-plugins/scm-legacy-plugin/package.json new file mode 100644 index 0000000000..84f78f419a --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/package.json @@ -0,0 +1,20 @@ +{ + "name": "@scm-manager/legacy-plugin", + "license": "BSD-3-Clause", + "main": "src/main/js/index.js", + "scripts": { + "build": "ui-bundler plugin", + "watch": "ui-bundler plugin -w", + "lint": "ui-bundler lint", + "flow": "flow check" + }, + "dependencies": { + "@scm-manager/ui-components": "latest", + "@scm-manager/ui-extensions": "^0.1.1", + "react-redux": "^5.0.7", + "@scm-manager/ui-types": "latest" + }, + "devDependencies": { + "@scm-manager/ui-bundler": "^0.0.25" + } +} diff --git a/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js b/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js new file mode 100644 index 0000000000..fd87f8e330 --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js @@ -0,0 +1,15 @@ +//@flow +import React from "react"; +import { withRouter } from "react-router-dom"; + +class DummyComponent extends React.Component { + + render() { + return ( + <> + + ); + } +} + +export default withRouter(DummyComponent); diff --git a/scm-plugins/scm-legacy-plugin/src/main/js/index.js b/scm-plugins/scm-legacy-plugin/src/main/js/index.js new file mode 100644 index 0000000000..4ddb7a0b04 --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/main/js/index.js @@ -0,0 +1,55 @@ +// @flow + +import React from "react"; +import { withRouter } from "react-router-dom"; +import { binder } from "@scm-manager/ui-extensions"; +import { ProtectedRoute, apiClient } from "@scm-manager/ui-components"; +import DummyComponent from "./DummyComponent"; + +type Props = { + authenticated?: boolean, + + //context objects + history: History +}; + +class LegacyRepositoryRedirect extends React.Component { + constructor(props: Props) { + super(props); + } + + redirectLegacyRepository() { + const { history } = this.props; + if (location.href && location.href.includes("#diffPanel;")) { + let splittedUrl = location.href.split(";"); + let repoId = splittedUrl[1]; + let changeSetId = splittedUrl[2]; + + apiClient.get("/legacy/repository/" + repoId) + .then(response => response.json()) + .then(payload => history.push("/repo/" + payload.namespace + "/" + payload.name + "/changesets/" + changeSetId) + ); + } + } + + render() { + const { authenticated } = this.props; + + return ( + <> + { + authenticated? + this.redirectLegacyRepository(): + + } + + ); + } +} + +binder.bind("legacyRepository.redirect", withRouter(LegacyRepositoryRedirect)); + diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index 129b11f5ba..59cd248e07 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -38,15 +38,6 @@ class Main extends React.Component { const { authenticated, links } = this.props; const redirectUrlFactory = binder.getExtension("main.redirect", this.props); 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) { url = redirectUrlFactory(this.props); } @@ -134,7 +125,11 @@ class Main extends React.Component { component={Profile} authenticated={authenticated} /> - + Date: Fri, 5 Jul 2019 10:08:27 +0200 Subject: [PATCH 4/8] add ErrorHandling and show ErrorNotification --- .../scm/legacy/LegacyRepositoryService.java | 5 +- .../scm-legacy-plugin/src/main/js/index.js | 74 ++++++++++++++----- scm-ui/src/containers/Main.js | 4 +- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java index 9e27c736ea..8cac590135 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java @@ -3,6 +3,7 @@ package sonia.scm.legacy; import com.google.inject.Inject; import com.webcohesion.enunciate.metadata.rs.ResponseCode; import com.webcohesion.enunciate.metadata.rs.StatusCodes; +import sonia.scm.NotFoundException; import sonia.scm.repository.Repository; import sonia.scm.repository.RepositoryManager; @@ -33,8 +34,10 @@ public class LegacyRepositoryService { }) public NamespaceAndNameDto getNameAndNamespaceForRepositoryId(@PathParam("id") String repositoryId) { Repository repo = repositoryManager.get(repositoryId); + if (repo == null) { + throw new NotFoundException(Repository.class, repositoryId); + } return new NamespaceAndNameDto(repo.getName(), repo.getNamespace()); - } } diff --git a/scm-plugins/scm-legacy-plugin/src/main/js/index.js b/scm-plugins/scm-legacy-plugin/src/main/js/index.js index 4ddb7a0b04..22e20eced7 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/js/index.js +++ b/scm-plugins/scm-legacy-plugin/src/main/js/index.js @@ -3,7 +3,12 @@ import React from "react"; import { withRouter } from "react-router-dom"; import { binder } from "@scm-manager/ui-extensions"; -import { ProtectedRoute, apiClient } from "@scm-manager/ui-components"; +import { + ProtectedRoute, + apiClient, + ErrorNotification, + ErrorBoundary +} from "@scm-manager/ui-components"; import DummyComponent from "./DummyComponent"; type Props = { @@ -13,11 +18,22 @@ type Props = { history: History }; -class LegacyRepositoryRedirect extends React.Component { - constructor(props: Props) { - super(props); +type State = { + error?: Error +}; + +class LegacyRepositoryRedirect extends React.Component { + constructor(props: Props, state: State) { + super(props, state); + this.state = { error: null }; } + handleError = (error: Error) => { + this.setState({ + error + }); + }; + redirectLegacyRepository() { const { history } = this.props; if (location.href && location.href.includes("#diffPanel;")) { @@ -25,31 +41,53 @@ class LegacyRepositoryRedirect extends React.Component { let repoId = splittedUrl[1]; let changeSetId = splittedUrl[2]; - apiClient.get("/legacy/repository/" + repoId) + apiClient + .get("/legacy/repository/" + repoId) .then(response => response.json()) - .then(payload => history.push("/repo/" + payload.namespace + "/" + payload.name + "/changesets/" + changeSetId) - ); + .then(payload => + history.push( + "/repo/" + + payload.namespace + + "/" + + payload.name + + "/changesets/" + + changeSetId + ) + ) + .catch(this.handleError); } } render() { const { authenticated } = this.props; + const { error } = this.state; + + if (error) { + return ( +
+
+ + + +
+
+ ); + } return ( <> - { - authenticated? - this.redirectLegacyRepository(): - - } + {authenticated ? ( + this.redirectLegacyRepository() + ) : ( + + )} ); } } -binder.bind("legacyRepository.redirect", withRouter(LegacyRepositoryRedirect)); - +binder.bind("legacy.redirectRepository", withRouter(LegacyRepositoryRedirect)); diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index 59cd248e07..a56f6b767c 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -9,7 +9,7 @@ import Users from "../users/containers/Users"; import Login from "../containers/Login"; import Logout from "../containers/Logout"; -import { ProtectedRoute, apiClient } from "@scm-manager/ui-components"; +import { ProtectedRoute } from "@scm-manager/ui-components"; import { binder, ExtensionPoint } from "@scm-manager/ui-extensions"; import CreateUser from "../users/containers/CreateUser"; @@ -126,7 +126,7 @@ class Main extends React.Component { authenticated={authenticated} /> From 22d323367f918616754cc31dcf82072e5d4b83a1 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 5 Jul 2019 10:57:21 +0200 Subject: [PATCH 5/8] add Tests for LegacyRepositoryService --- .../legacy/LegacyRepositoryServiceTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scm-plugins/scm-legacy-plugin/src/test/java/sonia/scm/legacy/LegacyRepositoryServiceTest.java diff --git a/scm-plugins/scm-legacy-plugin/src/test/java/sonia/scm/legacy/LegacyRepositoryServiceTest.java b/scm-plugins/scm-legacy-plugin/src/test/java/sonia/scm/legacy/LegacyRepositoryServiceTest.java new file mode 100644 index 0000000000..169c80eae2 --- /dev/null +++ b/scm-plugins/scm-legacy-plugin/src/test/java/sonia/scm/legacy/LegacyRepositoryServiceTest.java @@ -0,0 +1,43 @@ +package sonia.scm.legacy; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import sonia.scm.NotFoundException; +import sonia.scm.repository.Repository; +import sonia.scm.repository.RepositoryManager; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class LegacyRepositoryServiceTest { + + @Mock + private RepositoryManager repositoryManager; + + private LegacyRepositoryService legacyRepositoryService; + private final Repository repository = new Repository("abc123", "git", "space", "repo"); + + @Before + public void init() { + legacyRepositoryService = new LegacyRepositoryService(repositoryManager); + } + + @Test + public void findRepositoryNameSpaceAndNameForRepositoryId() { + when(repositoryManager.get(any(String.class))).thenReturn(repository); + NamespaceAndNameDto namespaceAndName = legacyRepositoryService.getNameAndNamespaceForRepositoryId("abc123"); + assertThat(namespaceAndName.getName()).isEqualToIgnoringCase("repo"); + assertThat(namespaceAndName.getNamespace()).isEqualToIgnoringCase("space"); + } + + @Test(expected = NotFoundException.class) + public void shouldGetNotFoundExceptionIfRepositoryNotExists() throws NotFoundException { + when(repositoryManager.get(any(String.class))).thenReturn(null); + legacyRepositoryService.getNameAndNamespaceForRepositoryId("456def"); + } +} From 35683543a7998a21ab2780926d6e8045f9b2b9e0 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 5 Jul 2019 11:35:40 +0200 Subject: [PATCH 6/8] cleanup --- .../main/java/sonia/scm/legacy/LegacyRepositoryService.java | 1 - scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js | 1 - scm-ui/src/containers/Main.js | 5 +---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java index 8cac590135..d6b923a927 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java +++ b/scm-plugins/scm-legacy-plugin/src/main/java/sonia/scm/legacy/LegacyRepositoryService.java @@ -39,6 +39,5 @@ public class LegacyRepositoryService { } return new NamespaceAndNameDto(repo.getName(), repo.getNamespace()); } - } diff --git a/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js b/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js index fd87f8e330..396558f852 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js +++ b/scm-plugins/scm-legacy-plugin/src/main/js/DummyComponent.js @@ -3,7 +3,6 @@ import React from "react"; import { withRouter } from "react-router-dom"; class DummyComponent extends React.Component { - render() { return ( <> diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index a56f6b767c..deec951b41 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -27,10 +27,7 @@ import Profile from "./Profile"; type Props = { authenticated?: boolean, - links: Links, - - //context objects - history: History + links: Links }; class Main extends React.Component { From 4e5d2d330238f34960afe7bee8e263fddc83e72d Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Mon, 8 Jul 2019 12:59:37 +0200 Subject: [PATCH 7/8] fix redirect url / use hal links in legacy plugin --- scm-plugins/scm-legacy-plugin/src/main/js/index.js | 10 ++++++---- scm-ui/src/containers/Main.js | 5 ----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/scm-plugins/scm-legacy-plugin/src/main/js/index.js b/scm-plugins/scm-legacy-plugin/src/main/js/index.js index 22e20eced7..97c3eb7e32 100644 --- a/scm-plugins/scm-legacy-plugin/src/main/js/index.js +++ b/scm-plugins/scm-legacy-plugin/src/main/js/index.js @@ -10,9 +10,11 @@ import { ErrorBoundary } from "@scm-manager/ui-components"; import DummyComponent from "./DummyComponent"; +import type {Links} from "@scm-manager/ui-types"; type Props = { authenticated?: boolean, + links: Links, //context objects history: History @@ -35,14 +37,14 @@ class LegacyRepositoryRedirect extends React.Component { }; redirectLegacyRepository() { - const { history } = this.props; + const { history, links } = this.props; if (location.href && location.href.includes("#diffPanel;")) { let splittedUrl = location.href.split(";"); let repoId = splittedUrl[1]; let changeSetId = splittedUrl[2]; apiClient - .get("/legacy/repository/" + repoId) + .get(links.nameAndNamespace.href.replace("{id}", repoId)) .then(response => response.json()) .then(payload => history.push( @@ -50,7 +52,7 @@ class LegacyRepositoryRedirect extends React.Component { payload.namespace + "/" + payload.name + - "/changesets/" + + "/changeset/" + changeSetId ) ) @@ -90,4 +92,4 @@ class LegacyRepositoryRedirect extends React.Component { } } -binder.bind("legacy.redirectRepository", withRouter(LegacyRepositoryRedirect)); +binder.bind("main.route", withRouter(LegacyRepositoryRedirect)); diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index deec951b41..1d358ecc87 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -122,11 +122,6 @@ class Main extends React.Component { component={Profile} authenticated={authenticated} /> - Date: Mon, 8 Jul 2019 14:17:24 +0000 Subject: [PATCH 8/8] Close branch feature/redirect_issuetracker_links