Skip to content

Commit

Permalink
[web] Drop the PageOptions layout slot
Browse files Browse the repository at this point in the history
It'll become no longer needed
  • Loading branch information
dgdavid committed Apr 21, 2023
1 parent 1e79a2d commit dd0065b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
26 changes: 13 additions & 13 deletions web/src/components/core/Sidebar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,9 @@
import React from "react";
import { screen, within } from "@testing-library/react";
import { plainRender, mockComponent, mockLayout } from "~/test-utils";
import { PageOptions, Sidebar } from "~/components/core";
import { Sidebar } from "~/components/core";

jest.mock("~/components/layout/Layout", () => mockLayout());
jest.mock("~/components/core/PageOptions", () => mockComponent(
<>
<a href="#">Goes somewhere</a>
<a href="#" data-keep-sidebar-open="true">Keep it open!</a>
<button>Do something</button>
<button data-keep-sidebar-open="true">Keep it open!</button>
</>
));

it("renders the sidebar initially hidden", async () => {
plainRender(<Sidebar />);
Expand All @@ -41,7 +33,7 @@ it("renders the sidebar initially hidden", async () => {
});

it("renders a link for displaying the sidebar", async () => {
const { user } = plainRender(<Sidebar><PageOptions /></Sidebar>);
const { user } = plainRender(<Sidebar />);

const link = await screen.findByLabelText(/Show/i);
const nav = await screen.findByRole("navigation", { name: /options/i });
Expand All @@ -52,7 +44,7 @@ it("renders a link for displaying the sidebar", async () => {
});

it("renders a link for hiding the sidebar", async () => {
const { user } = plainRender(<Sidebar><PageOptions /></Sidebar>);
const { user } = plainRender(<Sidebar />);

const openLink = await screen.findByLabelText(/Show/i);
const closeLink = await screen.findByLabelText(/Hide/i);
Expand All @@ -66,7 +58,7 @@ it("renders a link for hiding the sidebar", async () => {
});

it("moves the focus to the close action after opening it", async () => {
const { user } = plainRender(<Sidebar><PageOptions /></Sidebar>);
const { user } = plainRender(<Sidebar />);

const openLink = await screen.findByLabelText(/Show/i);
const closeLink = await screen.findByLabelText(/Hide/i);
Expand All @@ -78,7 +70,15 @@ it("moves the focus to the close action after opening it", async () => {

describe("onClick bubbling", () => {
it("hides the sidebar only if the user clicked on a link or button w/o keepSidebarOpen attribute", async () => {
const { user } = plainRender(<Sidebar><PageOptions /></Sidebar>);
const { user } = plainRender(
<Sidebar>
<a href="#">Goes somewhere</a>
<a href="#" data-keep-sidebar-open="true">Keep it open!</a>
<button>Do something</button>
<button data-keep-sidebar-open="true">Keep it open!</button>
</Sidebar>
);

const openLink = screen.getByLabelText(/Show/i);
await user.click(openLink);
const nav = screen.getByRole("navigation", { name: /options/i });
Expand Down
15 changes: 0 additions & 15 deletions web/src/components/layout/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { ChangeProductLink } from "~/components/software";
import { About, Disclosure, LogsButton, Sidebar, ShowLogButton, ShowTerminalButton } from "~/components/core";

const PageTitle = createTeleporter();
const PageOptions = createTeleporter();
const PageActions = createTeleporter();
const HeaderActions = createTeleporter();
const HeaderIcon = createTeleporter();
Expand Down Expand Up @@ -86,8 +85,6 @@ function Layout({ children }) {

<Sidebar>
<>
<PageOptions.Target />

<ChangeProductLink />
<Disclosure label="Diagnostic tools" data-keep-sidebar-open>
<ShowLogButton />
Expand Down Expand Up @@ -187,16 +184,6 @@ const MainActions = FooterActions.Source;
*/
const AdditionalInfo = FooterInfoArea.Source;

/**
* Component for setting the slot to place related options, usually in the Sidebar
*/
const PageOptionsSlot = PageOptions.Target;

/**
* Component for teleport page related options to the PageOptions slot
*/
const PageOptionsContent = PageOptions.Source;

export {
Layout as default,
Title,
Expand All @@ -205,6 +192,4 @@ export {
ContextualActions,
MainActions,
AdditionalInfo,
PageOptionsSlot,
PageOptionsContent,
};
1 change: 0 additions & 1 deletion web/src/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ const mockLayout = () => ({
ContextualActions: ({ children }) => children,
MainActions: ({ children }) => children,
AdditionalInfo: ({ children }) => children,
PageOptionsContent: ({ children }) => children,
});

export {
Expand Down

0 comments on commit dd0065b

Please sign in to comment.