Skip to content

Commit

Permalink
Fix remaining relative links in react codebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb Ellis committed Jun 3, 2020
1 parent 971770e commit b263919
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import * as Yup from "yup";

import { generateLegacyURL } from "app/utils";
import { machine as machineActions } from "app/base/actions";
import {
machine as machineSelectors,
Expand All @@ -23,7 +24,7 @@ const generateFailedTestsMessage = (numFailedTests, selectedMachines) => {
numFailedTests
)}.`;
if (singleMachine) {
const url = `${process.env.REACT_APP_BASENAME}${process.env.REACT_APP_ANGULAR_BASENAME}/machine/${singleMachine.system_id}`;
const url = generateLegacyURL(`/machine/${singleMachine.system_id}`);
return (
<span>
Machine <strong>{singleMachine.hostname}</strong> has{" "}
Expand Down Expand Up @@ -160,7 +161,9 @@ export const OverrideTestForm = ({
<br />
{selectedMachines.length === 1 ? (
<a
href={`${process.env.REACT_APP_BASENAME}${process.env.REACT_APP_ANGULAR_BASENAME}/machine/${selectedMachines[0].system_id}`}
href={generateLegacyURL(
`/machine/${selectedMachines[0].system_id}`
)}
>
Machine > Hardware tests
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSelector } from "react-redux";
import React from "react";
import PropTypes from "prop-types";

import { generateLegacyURL } from "app/utils";
import { machine as machineSelectors } from "app/base/selectors";
import DoubleRow from "app/base/components/DoubleRow";
import Tooltip from "app/base/components/Tooltip";
Expand Down Expand Up @@ -101,7 +102,9 @@ export const NameColumn = ({ handleCheckbox, selected, showMAC, systemId }) => {
const machine = useSelector((state) =>
machineSelectors.getBySystemId(state, systemId)
);
const machineURL = `${process.env.REACT_APP_ANGULAR_BASENAME}/${machine.link_type}/${machine.system_id}`;
const machineURL = generateLegacyURL(
`/${machine.link_type}/${machine.system_id}`
);
const primaryRow = showMAC
? generateMAC(machine, machineURL)
: generateFQDN(machine, machineURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`NameColumn renders 1`] = `
id="abc123"
label={
<a
href="/l/undefined/abc123"
href="/MAAS/l/undefined/abc123"
onClick={[Function]}
>
<strong>
Expand Down Expand Up @@ -50,7 +50,7 @@ exports[`NameColumn renders 1`] = `
id="abc123"
label={
<a
href="/l/undefined/abc123"
href="/MAAS/l/undefined/abc123"
onClick={[Function]}
>
<strong>
Expand All @@ -71,7 +71,7 @@ exports[`NameColumn renders 1`] = `
forId="abc123"
label={
<a
href="/l/undefined/abc123"
href="/MAAS/l/undefined/abc123"
onClick={[Function]}
>
<strong>
Expand Down Expand Up @@ -105,7 +105,7 @@ exports[`NameColumn renders 1`] = `
htmlFor="abc123"
>
<a
href="/l/undefined/abc123"
href="/MAAS/l/undefined/abc123"
onClick={[Function]}
>
<strong>
Expand Down
6 changes: 2 additions & 4 deletions ui/src/app/settings/views/Dhcp/DhcpTarget/DhcpTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { Link, Spinner } from "@canonical/react-components";
import PropTypes from "prop-types";
import React from "react";

import { generateLegacyURL } from "app/utils";
import { useDhcpTarget } from "app/settings/hooks";

const generateURL = (url) =>
`${process.env.REACT_APP_BASENAME}${process.env.REACT_APP_ANGULAR_BASENAME}${url}`;

const DhcpTarget = ({ nodeId, subnetId }) => {
const { loading, loaded, target, type } = useDhcpTarget(nodeId, subnetId);

Expand All @@ -22,7 +20,7 @@ const DhcpTarget = ({ nodeId, subnetId }) => {
<small>.{target.domain.name}</small>
</>
);
const url = generateURL(`/${type}/${nodeId || subnetId}`);
const url = generateLegacyURL(`/${type}/${nodeId || subnetId}`);
return <Link href={url}>{name}</Link>;
};

Expand Down

0 comments on commit b263919

Please sign in to comment.