Skip to content

Commit

Permalink
feat: Allow DebugPanel to be visible when flag__debug=true
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Oct 6, 2023
1 parent 804276d commit c309e6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
18 changes: 7 additions & 11 deletions app/components/debug-panel/DebugPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ DESCRIBE <${configuratorState.dataSet ?? ""}>`
);
};

const DebugPanel = ({
configurator = false,
interactiveFilters = false,
}: {
export type DebugPanelProps = {
configurator?: Boolean;
interactiveFilters?: Boolean;
}) => {
};

const DebugPanel = (props: DebugPanelProps) => {
const { configurator = false, interactiveFilters = false } = props;

return (
<Box
sx={{
Expand All @@ -198,9 +199,4 @@ const DebugPanel = ({
);
};

const DebugPanelNull = () => null;

const ExportedDebugPanel =
process.env.NODE_ENV === "development" ? DebugPanel : DebugPanelNull;

export default ExportedDebugPanel;
export default DebugPanel;
30 changes: 21 additions & 9 deletions app/components/debug-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import { CircularProgress } from "@mui/material";
import dynamic from "next/dynamic";
import { Suspense } from "react";

const LazyDebugPanel = dynamic(() => import("./DebugPanel"));

export default process.env.NODE_ENV === "development"
? (props: React.ComponentProps<typeof LazyDebugPanel>) => (
<Suspense fallback={<CircularProgress />}>
<LazyDebugPanel {...props} />
</Suspense>
)
: () => null;
import { flag } from "@/flags";

import { DebugPanelProps } from "./DebugPanel";

const LazyDebugPanel = dynamic(() => import("./DebugPanel"), { ssr: false });

const DebugPanel = (props: DebugPanelProps) => {
const shouldShow = flag("debug") || process.env.NODE_ENV === "development";

if (!shouldShow) {
return null;
}

return (
<Suspense fallback={<CircularProgress />}>
<LazyDebugPanel {...props} />
</Suspense>
);
};

export default DebugPanel;

0 comments on commit c309e6d

Please sign in to comment.