Skip to content

Commit

Permalink
#8759: fix snapshots and panel names
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller committed Jul 6, 2024
1 parent 11ee187 commit 9424e13
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 556 deletions.
17 changes: 15 additions & 2 deletions src/pageEditor/panes/__snapshots__/EditorPane.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/pageEditor/tabs/editTab/EditTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import styles from "./EditTab.module.scss";
import ErrorBoundary from "@/components/ErrorBoundary";
import DataPanel from "@/pageEditor/tabs/editTab/dataPanel/DataPanel";
import useModComponentTrace from "@/pageEditor/hooks/useModComponentTrace";
import FoundationDataPanel from "@/pageEditor/tabs/editTab/dataPanel/FoundationDataPanel";
import StarterBrickDataPanel from "@/pageEditor/tabs/editTab/dataPanel/StarterBrickDataPanel";
import { useDispatch, useSelector } from "react-redux";
import { FOUNDATION_NODE_ID } from "@/pageEditor/store/editor/uiState";
import {
Expand Down Expand Up @@ -159,7 +159,7 @@ const EditTab: React.FC<{
<div className={styles.dataPanelWrapper}>
<div className={styles.dataPanel}>
{activeNodeId === FOUNDATION_NODE_ID ? (
<FoundationDataPanel />
<StarterBrickDataPanel />
) : (
<DataPanel key={activeNodeId} />
)}
Expand Down
10 changes: 6 additions & 4 deletions src/pageEditor/tabs/editTab/dataPanel/DataPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { DocumentRenderer } from "@/bricks/renderers/document";
import DocumentOutline from "@/pageEditor/documentBuilder/outline/DocumentOutline";
import useAllBricks from "@/bricks/hooks/useAllBricks";
import ModComponentFormStateTab from "./tabs/ModComponentFormStateTab";
import ConfigurationTab from "./tabs/ConfigurationTab";
import BrickConfigTab from "./tabs/BrickConfigTab";
import { contextAsPlainObject } from "@/runtime/extendModVariableContext";
import { joinPathParts } from "@/utils/formUtils";
import CommentsTab from "@/pageEditor/tabs/editTab/dataPanel/tabs/CommentsTab";
Expand Down Expand Up @@ -217,11 +217,13 @@ const DataPanel: React.FC = () => {
{showDeveloperTabs && (
<>
<Nav.Item className={dataPanelStyles.tabNav}>
<Nav.Link eventKey={DataPanelTabKey.State}>State</Nav.Link>
<Nav.Link eventKey={DataPanelTabKey.ModComponentFormState}>
Editor State
</Nav.Link>
</Nav.Item>
<Nav.Item className={dataPanelStyles.tabNav}>
<Nav.Link eventKey={DataPanelTabKey.BrickConfig}>
Raw Brick
Brick Config
</Nav.Link>
</Nav.Item>
</>
Expand Down Expand Up @@ -263,7 +265,7 @@ const DataPanel: React.FC = () => {
{showDeveloperTabs && (
<>
<ModComponentFormStateTab />
<ConfigurationTab config={brickConfig} />
<BrickConfigTab config={brickConfig} />
</>
)}
<DataTab eventKey={DataPanelTabKey.Rendered} isTraceEmpty={!record}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import { render } from "@/pageEditor/testHelpers";
import { actions as editorActions } from "@/pageEditor/store/editor/editorSlice";
import runtimeSlice from "@/pageEditor/store/runtime/runtimeSlice";
import { DataPanelTabKey } from "@/pageEditor/tabs/editTab/dataPanel/dataPanelTypes";
import FoundationDataPanel from "@/pageEditor/tabs/editTab/dataPanel/FoundationDataPanel";
import StarterBrickDataPanel from "@/pageEditor/tabs/editTab/dataPanel/StarterBrickDataPanel";
import { formStateWithTraceDataFactory } from "@/testUtils/factories/pageEditorFactories";

describe("FoundationDataPanel", () => {
test("it renders with form state and trace data", async () => {
const { formState, records } = formStateWithTraceDataFactory();
const modComponentId = formState.uuid;
const { instanceId } = formState.modComponent.brickPipeline[0];
const { asFragment } = render(<FoundationDataPanel />, {
const { asFragment } = render(<StarterBrickDataPanel />, {
initialValues: formState,
setupRedux(dispatch) {
dispatch(editorActions.addModComponentFormState(formState));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import ModVariablesTab from "./tabs/ModVariablesTab";
import { DataPanelTabKey } from "@/pageEditor/tabs/editTab/dataPanel/dataPanelTypes";
import DataTabJsonTree from "./DataTabJsonTree";
import ModComponentFormStateTab from "./tabs/ModComponentFormStateTab";
import ConfigurationTab from "./tabs/ConfigurationTab";
import BrickConfigTab from "./tabs/BrickConfigTab";
import { selectActiveModComponentFormState } from "@/pageEditor/store/editor/editorSelectors";

const FoundationDataPanel: React.FC = () => {
const StarterBrickDataPanel: React.FC = () => {
const { flagOn } = useFlags();
const showDeveloperTabs = flagOn("page-editor-developer");

Expand All @@ -41,14 +41,14 @@ const FoundationDataPanel: React.FC = () => {
modComponent: { brickPipeline },
starterBrick,
} = activeModComponentFormState;
const firstBlockInstanceId = brickPipeline[0]?.instanceId;
const firstBrickInstanceId = brickPipeline[0]?.instanceId;

const { record: firstBlockTraceRecord } = useSelector(
makeSelectBrickTrace(firstBlockInstanceId),
const { record: firstBrickTraceRecord } = useSelector(
makeSelectBrickTrace(firstBrickInstanceId),
);

const [activeTabKey, onSelectTab] = useDataPanelActiveTabKey(
firstBlockTraceRecord ? DataPanelTabKey.Output : DataPanelTabKey.Preview,
firstBrickTraceRecord ? DataPanelTabKey.Output : DataPanelTabKey.Preview,
);

return (
Expand All @@ -60,11 +60,13 @@ const FoundationDataPanel: React.FC = () => {
{showDeveloperTabs && (
<>
<Nav.Item className={dataPanelStyles.tabNav}>
<Nav.Link eventKey={DataPanelTabKey.State}>State</Nav.Link>
<Nav.Link eventKey={DataPanelTabKey.ModComponentFormState}>
Editor State
</Nav.Link>
</Nav.Item>
<Nav.Item className={dataPanelStyles.tabNav}>
<Nav.Link eventKey={DataPanelTabKey.BrickConfig}>
Raw Foundation
Brick Config
</Nav.Link>
</Nav.Item>
</>
Expand All @@ -80,7 +82,7 @@ const FoundationDataPanel: React.FC = () => {
</Nav.Item>
<Nav.Item className={dataPanelStyles.tabNav}>
<Nav.Link eventKey={DataPanelTabKey.ModVariables}>
Page State
Mod Variables
</Nav.Link>
</Nav.Item>
</Nav>
Expand All @@ -97,7 +99,7 @@ const FoundationDataPanel: React.FC = () => {
{showDeveloperTabs && (
<>
<ModComponentFormStateTab />
<ConfigurationTab config={starterBrick} />
<BrickConfigTab config={starterBrick} />
</>
)}
<Tab.Pane
Expand All @@ -115,9 +117,9 @@ const FoundationDataPanel: React.FC = () => {
mountOnEnter
unmountOnExit
>
{firstBlockTraceRecord ? (
{firstBrickTraceRecord ? (
<DataTabJsonTree
data={firstBlockTraceRecord.templateContext}
data={firstBrickTraceRecord.templateContext}
copyable
searchable
tabKey={DataPanelTabKey.Output}
Expand Down Expand Up @@ -146,4 +148,4 @@ const FoundationDataPanel: React.FC = () => {
);
};

export default FoundationDataPanel;
export default StarterBrickDataPanel;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/pageEditor/tabs/editTab/dataPanel/dataPanelTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
export enum DataPanelTabKey {
Context = "context",
ModVariables = "modVariables",
State = "state",
BrickConfig = "blockConfig",
Rendered = "rendered",
Output = "output",
Preview = "preview",
Outline = "outline",
Comments = "comments",

// Developer-only tabs
ModComponentFormState = "modComponentFormState",
BrickConfig = "brickConfig",
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { DataPanelTabKey } from "@/pageEditor/tabs/editTab/dataPanel/dataPanelTy
import DataTab from "@/pageEditor/tabs/editTab/dataPanel/DataTab";
import DataTabJsonTree from "@/pageEditor/tabs/editTab/dataPanel/DataTabJsonTree";

const ConfigurationTab: React.FC<{ config: unknown }> = ({ config }) => (
/**
* Developer-only data panel tab for viewing the underlying brick configuration JSON. Used to debug brick configuration
* UI issues.
*/
const BrickConfigTab: React.FC<{ config: unknown }> = ({ config }) => (
<DataTab eventKey={DataPanelTabKey.BrickConfig}>
<div className="text-info">
<FontAwesomeIcon icon={faInfoCircle} /> This tab is only visible to
Expand All @@ -36,4 +40,4 @@ const ConfigurationTab: React.FC<{ config: unknown }> = ({ config }) => (
</DataTab>
);

export default ConfigurationTab;
export default BrickConfigTab;
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ const ModComponentFormStateTab: React.FC = () => {
);

return (
<DataTab eventKey={DataPanelTabKey.State}>
<DataTab eventKey={DataPanelTabKey.ModComponentFormState}>
<div className="text-info">
<FontAwesomeIcon icon={faInfoCircle} /> This tab is only visible to
developers
</div>
<DataTabJsonTree
data={{ activeElement: activeModComponentFormState, annotations }}
searchable
tabKey={DataPanelTabKey.State}
label="Element State"
tabKey={DataPanelTabKey.ModComponentFormState}
label="Editor State"
/>
</DataTab>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type StateValues = {
Public: UnknownObject | string;
};

/**
* Data panel tab displaying mod variables, and private/public state.
*/
const ModVariablesTab: React.VFC = () => {
const activeModComponentFormState = useSelector(
selectActiveModComponentFormState,
Expand Down
Loading

0 comments on commit 9424e13

Please sign in to comment.