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

#8614: rename remaining instances of recipe in the page editor #8724

Merged
10 changes: 5 additions & 5 deletions src/__snapshots__/Storyshots.test.js.snap

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

30 changes: 21 additions & 9 deletions src/bricks/effects/assignModVariable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ import { autoUUIDSequence } from "@/testUtils/factories/stringFactories";
import { validateBrickInputOutput } from "@/validators/schemaValidator";
import { brickOptionsFactory } from "@/testUtils/factories/runtimeFactories";

const extensionId = autoUUIDSequence();
const blueprintId = validateRegistryId("test/123");
const modComponentId = autoUUIDSequence();
const modId = validateRegistryId("test/123");

const brick = new AssignModVariable();

const logger = new ConsoleLogger({
extensionId,
blueprintId,
extensionId: modComponentId,
blueprintId: modId,
});

const brickOptions = brickOptionsFactory({ logger });

beforeEach(() => {
setState({
namespace: StateNamespaces.MOD,
blueprintId,
extensionId,
modId,
modComponentId,
mergeStrategy: MergeStrategies.REPLACE,
data: {},
});
Expand All @@ -64,7 +64,11 @@ describe("@pixiebrix/state/assign", () => {
);

expect(
getState({ namespace: StateNamespaces.MOD, blueprintId, extensionId }),
getState({
namespace: StateNamespaces.MOD,
modId,
modComponentId,
}),
).toEqual({ foo: { bar: 42 } });
});

Expand Down Expand Up @@ -94,7 +98,11 @@ describe("@pixiebrix/state/assign", () => {
);

expect(
getState({ namespace: StateNamespaces.MOD, blueprintId, extensionId }),
getState({
namespace: StateNamespaces.MOD,
modId,
modComponentId,
}),
).toEqual({ foo: null });
});

Expand All @@ -110,7 +118,11 @@ describe("@pixiebrix/state/assign", () => {
);

expect(
getState({ namespace: StateNamespaces.MOD, blueprintId, extensionId }),
getState({
namespace: StateNamespaces.MOD,
modId,
modComponentId,
}),
).toEqual({ foo: 42, bar: 0 });
});

Expand Down
6 changes: 3 additions & 3 deletions src/bricks/effects/assignModVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ class AssignModVariable extends EffectABC {
}>,
{ logger }: BrickOptions,
): Promise<void> {
const { blueprintId, extensionId } = logger.context;
const { blueprintId: modId, extensionId: modComponentId } = logger.context;

setState({
namespace: StateNamespaces.MOD,
data: { [variableName]: value },
mergeStrategy: MergeStrategies.SHALLOW,
extensionId,
blueprintId,
modComponentId,
modId,
});
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/bricks/effects/pageState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export class SetPageState extends TransformerABC {
data,
mergeStrategy,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion -- TODO: https://github.com/pixiebrix/pixiebrix-extension/issues/7891
extensionId: extensionId!,
blueprintId,
modComponentId: extensionId!,
modId: blueprintId,
});
}
}
Expand Down Expand Up @@ -205,12 +205,12 @@ export class GetPageState extends TransformerABC {
}: BrickArgs<{ namespace?: StateNamespace }>,
{ logger, platform }: BrickOptions,
): Promise<JsonObject> {
const { blueprintId, extensionId } = logger.context;
const { blueprintId: modId, extensionId: modComponentId } = logger.context;

return platform.state.getState({
namespace,
blueprintId,
extensionId,
modId,
modComponentId,
});
}
}
4 changes: 2 additions & 2 deletions src/bricks/renderers/customForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ describe("CustomFormRenderer", () => {
expect(
getState({
namespace: StateNamespaces.MOD,
extensionId: options.logger.context.extensionId,
blueprintId: options.logger.context.blueprintId,
modComponentId: options.logger.context.extensionId,
modId: options.logger.context.blueprintId,
}),
).toStrictEqual({
name: value,
Expand Down
8 changes: 4 additions & 4 deletions src/bricks/renderers/customForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ async function getInitialData(
// is rendered in. And for the PixieBrix sidebar, target the top-level frame.
return getPageState(topLevelFrame, {
namespace,
blueprintId,
extensionId,
modId: blueprintId,
modComponentId: extensionId,
});
}

Expand Down Expand Up @@ -487,8 +487,8 @@ async function setData(
namespace: storage.namespace ?? StateNamespaces.MOD,
data: cleanValues,
mergeStrategy: MergeStrategies.SHALLOW,
extensionId,
blueprintId,
modComponentId: extensionId,
modId: blueprintId,
});
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const logger = new ConsoleLogger({
function expectPageState(expectedState: UnknownObject) {
const pageState = getState({
namespace: StateNamespaces.MOD,
extensionId,
blueprintId,
modComponentId: extensionId,
modId: blueprintId,
});

expect(pageState).toStrictEqual(expectedState);
Expand All @@ -90,8 +90,8 @@ describe("WithAsyncModVariable", () => {
setState({
namespace: StateNamespaces.MOD,
data: {},
blueprintId,
extensionId,
modId: blueprintId,
modComponentId: extensionId,
mergeStrategy: MergeStrategies.REPLACE,
});

Expand Down
8 changes: 4 additions & 4 deletions src/bricks/transformers/controlFlow/WithAsyncModVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export class WithAsyncModVariable extends TransformerABC {
// Using shallow will replace the state key, but keep other keys
mergeStrategy:
strategy === "put" ? MergeStrategies.SHALLOW : MergeStrategies.DEEP,
extensionId,
blueprintId,
modComponentId: extensionId,
modId: blueprintId,
});
};

Expand All @@ -214,8 +214,8 @@ export class WithAsyncModVariable extends TransformerABC {
// Get/set page state calls are synchronous from the content script, so safe to call sequentially
const currentState = getState({
namespace: StateNamespaces.MOD,
extensionId,
blueprintId,
modComponentId: extensionId,
modId: blueprintId,
});

// eslint-disable-next-line security/detect-object-injection -- user provided value that's readonly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ describe("DisplayTemporaryInfo", () => {
namespace: StateNamespaces.MOD,
data: { foo: 42 },
mergeStrategy: MergeStrategies.REPLACE,
extensionId,
blueprintId: null,
modComponentId: extensionId,
modId: null,
});

await tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ const VarMenu: React.FunctionComponent<VarMenuProps> = ({
async () =>
getPageState(inspectedTab, {
namespace: StateNamespaces.MOD,
extensionId: null,
blueprintId: activeModComponentFormState.recipe?.id,
modComponentId: null,
modId: activeModComponentFormState.recipe?.id,
}),
[],
);
Expand Down
6 changes: 3 additions & 3 deletions src/contentScript/pageEditor/runBrickPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export async function runBrickPreview({
blockConfig,
context,
apiVersion,
blueprintId,
modId,
rootSelector,
}: RunBrickArgs & {
blueprintId: Nullishable<RegistryId>;
modId: Nullishable<RegistryId>;
}): Promise<unknown> {
const versionOptions = apiVersionOptions(apiVersion);

Expand All @@ -54,7 +54,7 @@ export async function runBrickPreview({

const state: IntermediateState = {
context: extendModVariableContext(context, {
blueprintId,
modId,
update: true,
options: versionOptions,
}),
Expand Down
24 changes: 12 additions & 12 deletions src/contentScript/pageEditor/runRendererBrick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ type Location = "modal" | "panel";
* @see useDocumentPreviewRunBlock
*/
export async function runRendererBrick({
extensionId,
blueprintId,
modComponentId,
modId,
runId,
title,
args,
location,
}: {
extensionId: UUID;
blueprintId: RegistryId | null;
modComponentId: UUID;
modId: RegistryId | null;
runId: UUID;
title: string;
args: RunBrickArgs;
Expand All @@ -65,7 +65,7 @@ export async function runRendererBrick({

let payload: PanelPayload;
try {
await runBrickPreview({ ...args, blueprintId });
await runBrickPreview({ ...args, modId });
// We're expecting a HeadlessModeError (or other error) to be thrown in the line above
// noinspection ExceptionCaughtLocallyJS
throw new NoRendererError();
Expand All @@ -76,23 +76,23 @@ export async function runRendererBrick({
blockId: error.blockId,
args: error.args,
ctxt: error.ctxt,
extensionId,
extensionId: modComponentId,
runId,
};
} else {
payload = {
key: nonce,
error: serializeError(error),
extensionId,
extensionId: modComponentId,
runId,
};
}

if (location === "panel") {
await showTemporarySidebarPanel({
// Pass extension id so previous run is cancelled
extensionId,
blueprintId,
extensionId: modComponentId,
blueprintId: modId,
nonce,
heading: title,
payload,
Expand All @@ -107,10 +107,10 @@ export async function runRendererBrick({
await waitForTemporaryPanel({
nonce,
location,
extensionId,
extensionId: modComponentId,
entry: {
extensionId,
blueprintId,
extensionId: modComponentId,
blueprintId: modId,
nonce,
heading: title,
payload,
Expand Down
6 changes: 3 additions & 3 deletions src/contentScript/pipelineProtocol/runMapArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function runMapArgs({
config,
context,
options,
blueprintId,
modId,
}: {
config: Args;
context: UnknownObject;
Expand All @@ -51,12 +51,12 @@ export async function runMapArgs({
*/
extendModVariable: boolean;
};
blueprintId: Nullishable<RegistryId>;
modId: Nullishable<RegistryId>;
}): Promise<unknown> {
expectContext("contentScript");

const extendedContext = extendModVariableContext(context, {
blueprintId,
modId,
options,
// The mod variable is only update when running a brick in a pipeline. It's not updated for `defer` expressions,
// e.g., when rendering items for a ListElement in the Document Builder.
Expand Down
2 changes: 1 addition & 1 deletion src/pageEditor/ModComponentFormStateWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const WizardNavItem: React.FunctionComponent<{
/**
* @deprecated This will soon be split into a new business-logic component, decoupled with the layout, using EditTabLayout
* @see EditorTabLayout
* @see RecipePane
* @see EditorPane
*/
const ModComponentFormStateWizard: React.FunctionComponent<{
modComponentFormState: ModComponentFormState;
Expand Down
Loading
Loading