fix redirect url / use hal links in legacy plugin

This commit is contained in:
Eduard Heimbuch
2019-07-08 12:59:37 +02:00
parent 35683543a7
commit 4e5d2d3302
2 changed files with 6 additions and 9 deletions

View File

@@ -10,9 +10,11 @@ import {
ErrorBoundary ErrorBoundary
} from "@scm-manager/ui-components"; } from "@scm-manager/ui-components";
import DummyComponent from "./DummyComponent"; import DummyComponent from "./DummyComponent";
import type {Links} from "@scm-manager/ui-types";
type Props = { type Props = {
authenticated?: boolean, authenticated?: boolean,
links: Links,
//context objects //context objects
history: History history: History
@@ -35,14 +37,14 @@ class LegacyRepositoryRedirect extends React.Component<Props, State> {
}; };
redirectLegacyRepository() { redirectLegacyRepository() {
const { history } = this.props; const { history, links } = this.props;
if (location.href && location.href.includes("#diffPanel;")) { if (location.href && location.href.includes("#diffPanel;")) {
let splittedUrl = location.href.split(";"); let splittedUrl = location.href.split(";");
let repoId = splittedUrl[1]; let repoId = splittedUrl[1];
let changeSetId = splittedUrl[2]; let changeSetId = splittedUrl[2];
apiClient apiClient
.get("/legacy/repository/" + repoId) .get(links.nameAndNamespace.href.replace("{id}", repoId))
.then(response => response.json()) .then(response => response.json())
.then(payload => .then(payload =>
history.push( history.push(
@@ -50,7 +52,7 @@ class LegacyRepositoryRedirect extends React.Component<Props, State> {
payload.namespace + payload.namespace +
"/" + "/" +
payload.name + payload.name +
"/changesets/" + "/changeset/" +
changeSetId changeSetId
) )
) )
@@ -90,4 +92,4 @@ class LegacyRepositoryRedirect extends React.Component<Props, State> {
} }
} }
binder.bind("legacy.redirectRepository", withRouter(LegacyRepositoryRedirect)); binder.bind("main.route", withRouter(LegacyRepositoryRedirect));

View File

@@ -122,11 +122,6 @@ class Main extends React.Component<Props> {
component={Profile} component={Profile}
authenticated={authenticated} authenticated={authenticated}
/> />
<ExtensionPoint
name="legacy.redirectRepository"
renderAll={true}
props={{ authenticated }}
/>
<ExtensionPoint <ExtensionPoint
name="main.route" name="main.route"
renderAll={true} renderAll={true}