Skip to content

Commit

Permalink
[web] Drop Sidebar.OpenButton component
Browse files Browse the repository at this point in the history
Because the use case [1] for which it was introduced was already gone:
to provide a link for directly opening the sidebar from a text teaching
the user where to find page related actions.

We can bring back the component if needed, but let's get rid of it now.

This commit "reverts" f1a56eb, df85b3c, and f39f65d

[1] #500
  • Loading branch information
dgdavid committed Apr 24, 2023
1 parent d80381b commit 301b3de
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions web/src/components/core/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ import React, { useEffect, useRef, useState } from "react";
import { Button, Text } from "@patternfly/react-core";
import { Icon, AppActions } from "~/components/layout";

// FIXME: look for a better way to allow opening the Sidebar from outside
let openButtonRef = {};

/**
* Agama sidebar navigation
* @component
*
* @param {object} props
* @param {React.ReactElement} props.children
*/
const Sidebar = ({ children }) => {
export default function Sidebar ({ children }) {
const [isOpen, setIsOpen] = useState(false);
openButtonRef = useRef(null);
const closeButtonRef = useRef(null);

const open = () => setIsOpen(true);
Expand Down Expand Up @@ -91,7 +87,6 @@ const Sidebar = ({ children }) => {
<>
<AppActions>
<button
ref={openButtonRef}
onClick={open}
className="plain-control"
aria-label="Show navigation and other options"
Expand Down Expand Up @@ -134,23 +129,4 @@ const Sidebar = ({ children }) => {
</nav>
</>
);
};

/**
* Button for opening the sidebar
* @component
*
* @param {object} props
* @param {onClickFn} [props.onClick] - On click callback
* @param {React.ReactElement} props.children
*/
Sidebar.OpenButton = ({ onClick: onClickProp, children }) => {
const onClick = () => {
if (onClickProp !== undefined) onClickProp();
openButtonRef.current.click();
};

return <Button variant="link" isInline onClick={onClick}>{children}</Button>;
};

export default Sidebar;
}

0 comments on commit 301b3de

Please sign in to comment.