Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure hidden section not appearing in sidebar #1038

Merged
merged 10 commits into from
Aug 22, 2024
9 changes: 7 additions & 2 deletions library/src/containers/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const SidebarContext = React.createContext<{
export const Sidebar: React.FunctionComponent = () => {
const [showSidebar, setShowSidebar] = useState(false);
const asyncapi = useSpec();
const config = useConfig();

const info = asyncapi.info();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand All @@ -23,6 +24,9 @@ export const Sidebar: React.FunctionComponent = () => {
const schemas = components?.schemas().all();
const hasOperations = asyncapi.operations().length > 0;

const showMessages = config.show?.messages;
const showSchemas = config.show?.schemas;

const messagesList = messages?.length > 0 && (
<li className="mb-3 mt-9">
<a
Expand Down Expand Up @@ -75,6 +79,7 @@ export const Sidebar: React.FunctionComponent = () => {

const operationList = hasOperations && (
<>
<h1>Testing</h1>
derberg marked this conversation as resolved.
Show resolved Hide resolved
<li className="mb-3 mt-9">
<a
className="text-xs uppercase text-gray-700 mt-10 mb-4 font-thin hover:text-gray-900"
Expand All @@ -85,8 +90,8 @@ export const Sidebar: React.FunctionComponent = () => {
</a>
<OperationsList />
</li>
{messagesList}
{schemasList}
{showMessages && messagesList}
{showSchemas && schemasList}
</>
);

Expand Down
Loading