Skip to content

Commit

Permalink
documentBuilderBranch -> documentBuilderSubtree
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford committed Jul 2, 2024
1 parent 4e46ac6 commit 1082f05
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/bricks/renderers/documentView/DocumentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import "@/vendors/bootstrapWithoutRem.css";
import "@/sidebar/sidebarBootstrapOverrides.scss";
import { buildDocumentBuilderBranch } from "@/pageEditor/documentBuilder/documentTree";
import { buildDocumentBuilderSubtree } from "@/pageEditor/documentBuilder/documentTree";
import React from "react";
import { type DocumentViewProps } from "./DocumentViewProps";
import DocumentContext from "@/pageEditor/documentBuilder/render/DocumentContext";
Expand Down Expand Up @@ -56,7 +56,7 @@ const DocumentView: React.FC<DocumentViewProps> = ({
<StylesheetsContext.Provider value={{ stylesheets }}>
<Stylesheets href={stylesheets}>
{body.map((documentElement, index) => {
const documentBuilderBranch = buildDocumentBuilderBranch(
const documentBuilderSubtree = buildDocumentBuilderSubtree(
documentElement,
{
staticId: joinPathParts("body", "children"),
Expand All @@ -65,11 +65,11 @@ const DocumentView: React.FC<DocumentViewProps> = ({
},
);

if (documentBuilderBranch == null) {
if (documentBuilderSubtree == null) {
return null;
}

const { Component, props } = documentBuilderBranch;
const { Component, props } = documentBuilderSubtree;
// eslint-disable-next-line react/no-array-index-key -- They have no other unique identifier
return <Component key={index} {...props} />;
})}
Expand Down
2 changes: 1 addition & 1 deletion src/pageEditor/documentBuilder/documentBuilderTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export type DynamicPath = {
}>;
};

export type BuildDocumentBuilderBranch = (
export type BuildDocumentBuilderSubtree = (
root: DocumentBuilderElement,
tracePath: DynamicPath,
) => DocumentBuilderComponent | null;
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/documentBuilder/documentTree.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import blockRegistry from "@/bricks/registry";
import MarkdownRenderer from "@/bricks/renderers/MarkdownRenderer";
import * as contentScriptAPI from "@/contentScript/messenger/api";
import { uuidv4 } from "@/types/helpers";
import { buildDocumentBuilderBranch } from "./documentTree";
import { buildDocumentBuilderSubtree } from "./documentTree";
import {
type DocumentBuilderElement,
type DocumentBuilderElementType,
Expand All @@ -46,7 +46,7 @@ describe("When rendered in panel", () => {
});

const renderDocument = (config: DocumentBuilderElement) => {
const branch = buildDocumentBuilderBranch(config, {
const branch = buildDocumentBuilderSubtree(config, {
staticId: "body",
branches: [],
});
Expand Down
12 changes: 6 additions & 6 deletions src/pageEditor/documentBuilder/documentTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import BlockElement from "@/pageEditor/documentBuilder/render/BlockElement";
import { get } from "lodash";
import { Col, Container, Row, Image } from "react-bootstrap";
import {
type BuildDocumentBuilderBranch,
type BuildDocumentBuilderSubtree,
type ButtonElementConfig,
type DocumentBuilderComponent,
type DocumentBuilderElement,
Expand Down Expand Up @@ -59,7 +59,7 @@ const UnknownType: React.FC<{ componentType: string }> = ({
<div className="text-danger">Unknown component type: {componentType}</div>
);

export const buildDocumentBuilderBranch: BuildDocumentBuilderBranch = (
export const buildDocumentBuilderSubtree: BuildDocumentBuilderSubtree = (
root,
tracePath,
) => {
Expand All @@ -84,16 +84,16 @@ export const buildDocumentBuilderBranch: BuildDocumentBuilderBranch = (
) {
documentBuilderComponent.props.children = root.children.map(
(child, index) => {
const branch = buildDocumentBuilderBranch(child, {
const subtree = buildDocumentBuilderSubtree(child, {
staticId: joinPathParts(staticId, root.type, "children"),
branches: [...branches, { staticId, index }],
});

if (branch == null) {
if (subtree == null) {
return null;
}

const { Component, props } = branch;
const { Component, props } = subtree;
// eslint-disable-next-line react/no-array-index-key -- They have no other unique identifier
return <Component key={index} {...props} />;
},
Expand Down Expand Up @@ -265,7 +265,7 @@ export function getDocumentBuilderComponent(
elementKey: config.elementKey,
config: config.element,
tracePath,
buildDocumentBuilderBranch,
buildDocumentBuilderSubtree,
};

return {
Expand Down
8 changes: 4 additions & 4 deletions src/pageEditor/documentBuilder/render/ListElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import DocumentContext from "./DocumentContext";
import { type Args } from "@/runtime/mapArgs";
import Loader from "@/components/Loader";
import {
type BuildDocumentBuilderBranch,
type BuildDocumentBuilderSubtree,
type DocumentBuilderElement,
type DynamicPath,
} from "@/pageEditor/documentBuilder/documentBuilderTypes";
Expand All @@ -41,7 +41,7 @@ type DocumentListProps = {
array: UnknownObject[];
elementKey?: string;
config: Args;
buildDocumentBuilderBranch: BuildDocumentBuilderBranch;
buildDocumentBuilderSubtree: BuildDocumentBuilderSubtree;
tracePath: DynamicPath;
};

Expand All @@ -51,7 +51,7 @@ const ListElementInternal: React.FC<DocumentListProps> = ({
array = DEFAULT_ARRAY,
elementKey,
config,
buildDocumentBuilderBranch,
buildDocumentBuilderSubtree,
tracePath,
}) => {
const { staticId, branches } = tracePath;
Expand Down Expand Up @@ -138,7 +138,7 @@ const ListElementInternal: React.FC<DocumentListProps> = ({
<>
{rootDefinitions?.map(({ documentElement, elementContext }, index) => {
const { Component, props } =
buildDocumentBuilderBranch(
buildDocumentBuilderSubtree(
documentElement as DocumentBuilderElement,
{
staticId: joinPathParts(staticId, "list", "children"),
Expand Down
10 changes: 5 additions & 5 deletions src/pageEditor/exampleStarterBrickConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ const quickbarActionId = validateRegistryId("@pixiebrix/quickbar/add");

export function getExampleBrickPipeline(type: StarterBrickType): BrickPipeline {
if (type === "actionPanel") {
const documentBuilderBlock = createNewConfiguredBrick(documentBrickId);
return [documentBuilderBlock];
const documentBuilderBrick = createNewConfiguredBrick(documentBrickId);
return [documentBuilderBrick];
}

if (type === "quickBarProvider") {
const quickbarActionBlock = createNewConfiguredBrick(quickbarActionId);
quickbarActionBlock.config = {
const quickbarActionBrick = createNewConfiguredBrick(quickbarActionId);
quickbarActionBrick.config = {
title: "Example Action",
action: toExpression("pipeline", []),
};
return [quickbarActionBlock];
return [quickbarActionBrick];
}

return [];
Expand Down

0 comments on commit 1082f05

Please sign in to comment.