Skip to content

Commit

Permalink
fix: update dashboard to network discovery url (#5220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Topher authored Nov 24, 2023
1 parent da8d558 commit ee016c4
Show file tree
Hide file tree
Showing 49 changed files with 144 additions and 131 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/with-users/dashboard/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { generateMAASURL } from "../../utils";

context("Dashboard", () => {
context("Network Discovery", () => {
beforeEach(() => {
cy.login();
cy.visit(generateMAASURL("/dashboard"));
cy.visit(generateMAASURL("/network-discovery"));
});

it("renders the correct heading", () => {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/with-users/machines/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ context("Machine listing", () => {
});

it("replaces the URL when selecting filters", () => {
// visit the dashboard first to have a page to go back to
const intialPage = generateMAASURL("/dashboard");
// visit network discovery first to have a page to go back to
const intialPage = generateMAASURL("/network-discovery");
cy.visit(intialPage);
cy.visit(generateMAASURL("/machines"));

Expand Down
2 changes: 1 addition & 1 deletion sitespeed.io/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = async function (context, commands) {
name: "skipintro",
value: "true",
});
await commands.navigate(constructURL(context, "/dashboard"));
await commands.navigate(constructURL(context, "/network-discovery"));
await commands.wait.bySelector("input[name='username']", TIMEOUT);
await commands.addText.byName("admin", "username");
await commands.addText.byName("test", "password");
Expand Down
4 changes: 2 additions & 2 deletions src/app/Routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ const routes: { title: string; path: string }[] = [
path: urls.zones.details({ id: 1 }),
},
{
title: "Dashboard",
path: urls.dashboard.index,
title: "Network Discovery",
path: urls.networkDiscovery.index,
},
];

Expand Down
14 changes: 11 additions & 3 deletions src/app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import urls from "app/base/urls";
import NotFound from "app/base/views/NotFound";
import ControllerDetails from "app/controllers/views/ControllerDetails";
import ControllerList from "app/controllers/views/ControllerList";
import Dashboard from "app/dashboard/views/Dashboard";
import DeviceDetails from "app/devices/views/DeviceDetails";
import DeviceList from "app/devices/views/DeviceList";
import DomainDetails from "app/domains/views/DomainDetails";
Expand All @@ -16,6 +15,7 @@ import Intro from "app/intro/views/Intro";
import KVM from "app/kvm/views/KVM";
import MachineDetails from "app/machines/views/MachineDetails";
import Machines from "app/machines/views/Machines";
import NetworkDiscovery from "app/networkDiscovery/views/NetworkDiscovery";
import Pools from "app/pools/views/Pools";
import Preferences from "app/preferences/views/Preferences";
import Settings from "app/settings/views/Settings";
Expand Down Expand Up @@ -58,10 +58,18 @@ const Routes = (): JSX.Element => (
<Route
element={
<ErrorBoundary>
<Dashboard />
<NetworkDiscovery />
</ErrorBoundary>
}
path={`${urls.dashboard.index}/*`}
path={`${urls.networkDiscovery.index}/*`}
/>
<Route
element={<Redirect to={urls.networkDiscovery.index} />}
path={urls.networkDiscovery.legacyIndex}
/>
<Route
element={<Redirect to={urls.networkDiscovery.configuration} />}
path={urls.networkDiscovery.legacyConfiguration}
/>
<Route
element={
Expand Down
2 changes: 1 addition & 1 deletion src/app/base/components/AppSideNavigation/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const navGroups: NavGroup[] = [
},
{
label: "Network discovery",
url: urls.dashboard.index,
url: urls.networkDiscovery.index,
},
],
},
Expand Down
12 changes: 6 additions & 6 deletions src/app/base/side-panel-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { createContext, useCallback, useContext, useState } from "react";

import { ControllerSidePanelViews } from "app/controllers/constants";
import type { ControllerSidePanelContent } from "app/controllers/types";
import {
DashboardSidePanelViews,
type DashboardSidePanelContent,
} from "app/dashboard/views/constants";
import { DeviceSidePanelViews } from "app/devices/constants";
import type { DeviceSidePanelContent } from "app/devices/types";
import {
Expand All @@ -21,6 +17,10 @@ import { KVMSidePanelViews } from "app/kvm/constants";
import type { KVMSidePanelContent } from "app/kvm/types";
import { MachineSidePanelViews } from "app/machines/constants";
import type { MachineSidePanelContent } from "app/machines/types";
import {
NetworkDiscoverySidePanelViews,
type NetworkDiscoverySidePanelContent,
} from "app/networkDiscovery/views/constants";
import {
SubnetSidePanelViews,
type SubnetSidePanelContent,
Expand Down Expand Up @@ -58,7 +58,7 @@ export type SidePanelContent =
| SubnetSidePanelContent
| DomainDetailsSidePanelContent
| DomainListSidePanelContent
| DashboardSidePanelContent
| NetworkDiscoverySidePanelContent
| VLANDetailsSidePanelContent
| FabricDetailsSidePanelContent
| SubnetDetailsSidePanelContent
Expand Down Expand Up @@ -86,7 +86,7 @@ export const SidePanelViews = {
...SubnetSidePanelViews,
...DomainDetailsSidePanelViews,
...DomainListSidePanelViews,
...DashboardSidePanelViews,
...NetworkDiscoverySidePanelViews,
...VLANDetailsSidePanelViews,
...FabricDetailsSidePanelViews,
...SubnetDetailsSidePanelViews,
Expand Down
4 changes: 2 additions & 2 deletions src/app/base/urls.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { default as controllers } from "app/controllers/urls";
import { default as dashboard } from "app/dashboard/urls";
import { default as devices } from "app/devices/urls";
import { default as domains } from "app/domains/urls";
import { default as images } from "app/images/urls";
import { default as intro } from "app/intro/urls";
import { default as kvm } from "app/kvm/urls";
import { default as machines } from "app/machines/urls";
import { default as networkDiscovery } from "app/networkDiscovery/urls";
import { default as pools } from "app/pools/urls";
import { default as preferences } from "app/preferences/urls";
import { default as settings } from "app/settings/urls";
Expand All @@ -16,7 +16,7 @@ import { default as zones } from "app/zones/urls";
const urls = {
index: "/",
controllers,
dashboard,
networkDiscovery,
devices,
domains,
images,
Expand Down
6 changes: 0 additions & 6 deletions src/app/dashboard/urls.ts

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/app/dashboard/views/DashboardHeader/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/app/intro/components/IntroSection/IntroSection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe("IntroSection", () => {
</Router>,
{ state }
);
expect(history.location.pathname).toBe(urls.dashboard.index);
expect(history.location.pathname).toBe(urls.machines.index);
});

it("redirects to the dashboard for admins", () => {
it("redirects to the machine list for admins", () => {
state.user = userStateFactory({
auth: authStateFactory({
user: userFactory({ completed_intro: true, is_superuser: true }),
Expand All @@ -69,7 +69,7 @@ describe("IntroSection", () => {
<IntroSection shouldExitIntro={true}>Intro content</IntroSection>,
{ route: "/intro/user", state }
);
expect(window.location.pathname).toBe(urls.dashboard.index);
expect(window.location.pathname).toBe(urls.machines.index);
});

it("redirects to the machine list for non-admins", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/intro/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("hooks", () => {
const { result } = renderHook(() => useExitURL(), {
wrapper: generateWrapper(store),
});
expect(result.current).toBe(urls.dashboard.index);
expect(result.current).toBe(urls.machines.index);
});

it("gets the exit URL for a non-admin", () => {
Expand Down
6 changes: 1 addition & 5 deletions src/app/intro/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { useSelector } from "react-redux";

import urls from "app/base/urls";
import authSelectors from "app/store/auth/selectors";

/**
* Get the URL to redirect to when the intro closes.
* @returns The URL to redirect to.
*/
export const useExitURL = (): string => {
const authUser = useSelector(authSelectors.get);
return authUser?.is_superuser ? urls.dashboard.index : urls.machines.index;
return urls.machines.index;
};
2 changes: 1 addition & 1 deletion src/app/intro/views/Intro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("Intro", () => {
route: "/intro",
state,
});
expect(window.location.pathname).toBe(urls.dashboard.index);
expect(window.location.pathname).toBe(urls.machines.index);
});

it("returns to the start when loading the user intro and the main intro is incomplete", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("MaasIntroSuccess", () => {
).toHaveProperty("href", `http://example.com${urls.intro.user}`);
});

it("links to the dashboard if an admin that has completed the user intro", () => {
it("links to the machine list if an admin that has completed the user intro", () => {
state.user.auth = authStateFactory({
user: userFactory({ completed_intro: true, is_superuser: true }),
});
Expand All @@ -67,7 +67,7 @@ describe("MaasIntroSuccess", () => {
});
expect(
screen.getByRole("link", { name: MaasIntroSuccessLabels.FinishSetup })
).toHaveProperty("href", `http://example.com${urls.dashboard.index}`);
).toHaveProperty("href", `http://example.com${urls.machines.index}`);
});

it("links to the machine list if a non-admin that has completed the user intro", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/intro/views/UserIntro/UserIntro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("UserIntro", () => {
route: "/intro/user",
state,
});
expect(window.location.pathname).toBe(urls.dashboard.index);
expect(window.location.pathname).toBe(urls.machines.index);
});

it("disables the continue button if there are no ssh keys", () => {
Expand Down Expand Up @@ -153,7 +153,7 @@ describe("UserIntro", () => {
route: "/intro/user",
state,
});
expect(window.location.pathname).toBe(urls.dashboard.index);
expect(window.location.pathname).toBe(urls.machines.index);
});

it("can skip the user setup", async () => {
Expand Down
8 changes: 8 additions & 0 deletions src/app/networkDiscovery/urls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const urls = {
configuration: "/network-discovery/configuration",
index: "/network-discovery",
legacyIndex: "/dashboard",
legacyConfiguration: "/dashboard/configuration",
};

export default urls;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from "testing/utils";

const mockStore = configureStore<RootState, {}>();
const route = "/dashboard";
const route = "/network-discovery";
describe("DiscoveriesList", () => {
let state: RootState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const DiscoveriesList = (): JSX.Element => {
const saving = useSelector(discoverySelectors.saving);
const saved = useSelector(discoverySelectors.saved);

useWindowTitle("Dashboard");
useWindowTitle("Network Discovery");

useFetchActions([discoveryActions.fetch]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);
const expectedActions = [
"device/fetch",
Expand All @@ -164,7 +164,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);
expect(screen.getByText("Loading")).toBeInTheDocument();
});
Expand All @@ -173,7 +173,7 @@ describe("DiscoveryAddForm", () => {
// Render the form with default state.
const { rerender } = renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", state }
{ route: "/network-discovery", state }
);
const error = "Name is invalid";
// Change the device state to included the errors (as if it has changed via an API response).
Expand All @@ -192,7 +192,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);

await userEvent.selectOptions(
Expand Down Expand Up @@ -251,7 +251,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);

await userEvent.selectOptions(
Expand Down Expand Up @@ -310,7 +310,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);

await userEvent.click(
Expand All @@ -329,7 +329,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);

await userEvent.clear(
Expand All @@ -353,7 +353,7 @@ describe("DiscoveryAddForm", () => {
const store = mockStore(state);
const { rerender } = renderWithBrowserRouter(
<DiscoveryAddForm discovery={discovery} onClose={jest.fn()} />,
{ route: "/dashboard", store }
{ route: "/network-discovery", store }
);

await userEvent.selectOptions(
Expand Down
Loading

0 comments on commit ee016c4

Please sign in to comment.