Skip to content

Commit

Permalink
Remove history and add BrowserRouter.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nelson <minelson@vmware.com>
  • Loading branch information
absoludity committed Aug 2, 2023
1 parent 1bd24a0 commit 6aae8f6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 82 deletions.
1 change: 0 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"axios": "^1.3.5",
"fast-json-patch": "^3.1.1",
"google-protobuf": "^3.21.2",
"history": "^4.10.1",
"jsonwebtoken": "^9.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/ConfigLoader/ConfigLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ConfigLoader({ ...otherProps }: IConfigLoaderProps) {
const intl = useIntl();
React.useEffect(() => {
dispatch(actions.config.getConfig());
});
}, [dispatch]);
const kubeappsTitle = intl.formatMessage({ id: "Kubeapps", defaultMessage: "Kubeapps" });

const {
Expand Down
12 changes: 6 additions & 6 deletions dashboard/src/components/DeploymentForm/DeploymentForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from "gen/kubeappsapis/core/packages/v1alpha1/packages_pb";
import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins_pb";
import { GetServiceAccountNamesResponse } from "gen/kubeappsapis/plugins/resources/v1alpha1/resources_pb";
import { createMemoryHistory } from "history";
import * as ReactRedux from "react-redux";
import * as ReactRouter from "react-router";
import { MemoryRouter, Route, Routes } from "react-router-dom";
Expand Down Expand Up @@ -53,15 +52,16 @@ const defaultSelectedPkg = {
const routePathParam = `/c/${defaultProps.cluster}/ns/${defaultProps.namespace}/apps/new/${defaultProps.plugin.name}/${defaultProps.plugin.version}/${defaultProps.packageCluster}/${defaultProps.packageNamespace}/${defaultProps.pkgName}/versions/${defaultProps.version}`;
const routePath =
"/c/:cluster/ns/:namespace/apps/new/:pluginName/:pluginVersion/:packageCluster/:packageNamespace/:packageId/versions/:packageVersion";
const history = createMemoryHistory({ initialEntries: [routePathParam] });

let spyOnUseDispatch: jest.SpyInstance;
let spyOnUseNavigate: jest.SpyInstance;
let mockNavigate: jest.Func;

beforeEach(() => {
const mockDispatch = jest.fn();
const mockDispatch = jest.fn().mockReturnValue(true);
spyOnUseDispatch = jest.spyOn(ReactRedux, "useDispatch").mockReturnValue(mockDispatch);
spyOnUseNavigate = jest.spyOn(ReactRouter, "useNavigate").mockReturnValue(jest.fn());
mockNavigate = jest.fn();
spyOnUseNavigate = jest.spyOn(ReactRouter, "useNavigate").mockReturnValue(mockNavigate);
// mock the window.matchMedia for selecting the theme
Object.defineProperty(window, "matchMedia", {
writable: true,
Expand Down Expand Up @@ -411,8 +411,8 @@ describe("renders an error", () => {
{} as ReconciliationOptions,
);

expect(history.location.pathname).toBe(
`/c/${defaultProps.cluster}/ns/${defaultProps.namespace}/apps/new/my.plugin/0.0.1/${defaultProps.packageCluster}/${defaultProps.packageNamespace}/foo/versions/0.0.1`,
expect(navigate).toHaveBeenCalledWith(
`/c/${defaultProps.cluster}/ns/${defaultProps.namespace}/apps/my.plugin/0.0.1/${defaultProps.releaseName}`,
);
});
});

This file was deleted.

6 changes: 0 additions & 6 deletions dashboard/src/containers/ConfigLoaderContainer/index.ts

This file was deleted.

17 changes: 10 additions & 7 deletions dashboard/src/containers/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import I18n, { ISupportedLangs } from "shared/I18n";
import store from "../store";
import Routes from "./RoutesContainer";
import ConfigLoader from "components/ConfigLoader";
import { BrowserRouter } from "react-router-dom";

async function initLocale() {
const fullLang = (navigator.languages && navigator.languages[0]) || navigator.language;
Expand All @@ -34,13 +35,15 @@ function Root() {
defaultLocale="en"
>
<ConfigLoader>
<Suspense fallback={null}>
<HeadManager>
<Layout headerComponent={Header}>
<Routes />
</Layout>
</HeadManager>
</Suspense>
<BrowserRouter>
<Suspense fallback={null}>
<HeadManager>
<Layout headerComponent={Header}>
<Routes />
</Layout>
</HeadManager>
</Suspense>
</BrowserRouter>
</ConfigLoader>
</IntlProvider>
</Provider>
Expand Down
4 changes: 0 additions & 4 deletions dashboard/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// Copyright 2018-2023 the Kubeapps contributors.
// SPDX-License-Identifier: Apache-2.0

import { createHashHistory } from "history";
import { applyMiddleware, createStore } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import thunkMiddleware from "redux-thunk";
import createRootReducer from "../reducers";

// Use Hash based routing to support deploying Kubeapps in arbitrary URL subpaths
export const history = createHashHistory();

export default createStore(
createRootReducer(),
composeWithDevTools(applyMiddleware(thunkMiddleware)),
Expand Down
36 changes: 2 additions & 34 deletions dashboard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@
core-js-pure "^3.30.2"
regenerator-runtime "^0.13.11"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.22.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438"
integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==
Expand Down Expand Up @@ -7374,18 +7374,6 @@ highlight.js@^10.4.1, highlight.js@~10.7.0:
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.7.3.tgz#697272e3991356e40c3cac566a74eef681756531"
integrity sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==

history@^4.10.1:
version "4.10.1"
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==
dependencies:
"@babel/runtime" "^7.1.2"
loose-envify "^1.2.0"
resolve-pathname "^3.0.0"
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"
value-equal "^1.0.1"

hmac-drbg@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
Expand Down Expand Up @@ -9429,7 +9417,7 @@ longest-streak@^3.0.0:
resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-3.1.0.tgz#62fa67cd958742a1574af9f39866364102d90cd4"
integrity sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.4.0:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
Expand Down Expand Up @@ -12679,11 +12667,6 @@ resolve-from@^5.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==

resolve-pathname@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==

resolve-pkg-maps@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz#616b3dc2c57056b5588c31cdf4b3d64db133720f"
Expand Down Expand Up @@ -14130,16 +14113,6 @@ timers-browserify@^2.0.12:
dependencies:
setimmediate "^1.0.4"

tiny-invariant@^1.0.2:
version "1.3.1"
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.1.tgz#8560808c916ef02ecfd55e66090df23a4b7aa642"
integrity sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==

tiny-warning@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==

titleize@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53"
Expand Down Expand Up @@ -14806,11 +14779,6 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

value-equal@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==

vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
Expand Down

0 comments on commit 6aae8f6

Please sign in to comment.