Skip to content

Commit

Permalink
Fix two hard-coded links to use url helper. (#1809)
Browse files Browse the repository at this point in the history
* Fix redirect after delete action to use new route.

* Switch hard-coded deploy link on app list page.
  • Loading branch information
absoludity committed Jun 23, 2020
1 parent d083020 commit e5c71fb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion dashboard/src/components/AppList/AppList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react";
import { Link } from "react-router-dom";

import { IAppOverview, IAppState, IClusterServiceVersion, IResource } from "../../shared/types";
import * as url from "../../shared/url";
import { escapeRegExp } from "../../shared/utils";
import { CardGrid } from "../Card";
import { ErrorSelector, MessageAlert } from "../ErrorAlert";
Expand Down Expand Up @@ -77,7 +78,7 @@ class AppList extends React.Component<IAppListProps, IAppListState> {
</div>
<div className="col-3 text-r align-center">
{!error && (
<Link to={`/ns/${namespace}/catalog`}>
<Link to={url.app.catalog(namespace)}>
<button className="deploy-button button button-accent">Deploy App</button>
</Link>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports[`when apps available matches the snapshot 1`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down Expand Up @@ -117,7 +117,7 @@ exports[`when custom resources available matches the snapshot 1`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down Expand Up @@ -277,7 +277,7 @@ exports[`when fetched but not apps available matches the snapshot 1`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down Expand Up @@ -348,7 +348,7 @@ exports[`while fetching apps loading spinner matches the snapshot 1`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down Expand Up @@ -419,7 +419,7 @@ exports[`while fetching apps loading spinner matches the snapshot 2`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down Expand Up @@ -490,7 +490,7 @@ exports[`while fetching apps matches the snapshot 1`] = `
className="col-3 text-r align-center"
>
<Link
to="/ns/default/catalog"
to="/c/default/ns/default/catalog"
>
<button
className="deploy-button button button-accent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Redirect } from "react-router";
import RollbackButtonContainer from "../../../containers/RollbackButtonContainer";
import { hapi } from "../../../shared/hapi/release";
import itBehavesLike from "../../../shared/specs";
import * as url from "../../../shared/url";
import ConfirmDialog from "../../ConfirmDialog";

import { IRelease } from "shared/types";
Expand Down Expand Up @@ -40,7 +41,7 @@ it("calls delete function when clicking the button", done => {
wrapper.update();
const redirect = wrapper.find(Redirect);
expect(redirect.props()).toMatchObject({
to: `/ns/${namespace}/apps`,
to: url.app.apps.list(namespace),
} as any);
done();
}, 1);
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/components/AppView/AppControls/AppControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Redirect } from "react-router";

import { IRelease } from "shared/types";
import RollbackButtonContainer from "../../../containers/RollbackButtonContainer";
import * as url from "../../../shared/url";
import ConfirmDialog from "../../ConfirmDialog";
import LoadingWrapper from "../../LoadingWrapper";
import "./AppControls.css";
Expand Down Expand Up @@ -83,7 +84,7 @@ class AppControls extends React.Component<IAppControlsProps, IAppControlsState>
)
}
/>
{this.state.redirectToAppList && <Redirect to={`/ns/${namespace}/apps`} />}
{this.state.redirectToAppList && <Redirect to={url.app.apps.list(namespace)} />}
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/reducers/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe("clusterReducer", () => {

describe("changes the current stored namespace if it is in the URL", () => {
const testCases = [
{ path: "/ns/cyberdyne/apps", current: "cyberdyne" },
{ path: "/c/default/ns/cyberdyne/apps", current: "cyberdyne" },
{ path: "/cyberdyne/apps", current: "initial-current" },
{ path: "/ns/T-600/charts", current: "T-600" },
{ path: "/c/barcluster/ns/T-600/charts", current: "T-600" },
];
testCases.forEach(tc => {
it(tc.path, () =>
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/reducers/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const clusterReducer = (
return { ...initialState };
case LOCATION_CHANGE:
const pathname = action.payload.location.pathname;
// looks for /ns/:namespace in URL
// looks for /ns/:namespace/ in URL
// TODO(absoludity): this should match on cluster also to set currentCluster.
const matches = pathname.match(/\/ns\/([^/]*)/);
if (matches) {
Expand Down

0 comments on commit e5c71fb

Please sign in to comment.