Skip to content

Commit

Permalink
fix merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford committed Jul 8, 2024
1 parent 8dd5290 commit d452a0b
Show file tree
Hide file tree
Showing 22 changed files with 81 additions and 62 deletions.
6 changes: 3 additions & 3 deletions src/__snapshots__/Storyshots.test.js.snap

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

2 changes: 1 addition & 1 deletion src/background/removeModComponentForEveryTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export async function removeModComponentForEveryTab(
});
await uninstallContextMenu({ extensionId: modComponentId });
await clearModComponentTraces(modComponentId);
await clearLog({ modComponentId: modComponentId });
await clearLog({ modComponentId });
}
8 changes: 4 additions & 4 deletions src/bricks/effects/AddDynamicTextSnippet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe("AddDynamicTextSnippet", () => {
componentId: extensionId,
context: {
...logger.context,
blockId: brick.id,
blockVersion: expect.toBeString(),
brickId: brick.id,
brickVersion: expect.toBeString(),
label: brick.name,
},
},
Expand Down Expand Up @@ -127,8 +127,8 @@ describe("AddDynamicTextSnippet", () => {
componentId: extensionId,
context: {
...logger.context,
blockId: brick.id,
blockVersion: expect.toBeString(),
brickId: brick.id,
brickVersion: expect.toBeString(),
label: brick.name,
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/bricks/effects/assignModVariable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const modId = validateRegistryId("test/123");
const brick = new AssignModVariable();

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

const brickOptions = brickOptionsFactory({ logger });
Expand Down
2 changes: 1 addition & 1 deletion src/bricks/effects/assignModVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class AssignModVariable extends EffectABC {
}>,
{ logger }: BrickOptions,
): Promise<void> {
const { modId: modId, modComponentId: modComponentId } = logger.context;
const { modId, modComponentId } = logger.context;

setState({
namespace: StateNamespaces.MOD,
Expand Down
2 changes: 1 addition & 1 deletion src/bricks/effects/pageState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class GetPageState extends TransformerABC {
}: BrickArgs<{ namespace?: StateNamespace }>,
{ logger, platform }: BrickOptions,
): Promise<JsonObject> {
const { modId: modId, modComponentId: modComponentId } = logger.context;
const { modId, modComponentId } = logger.context;

return platform.state.getState({
namespace,
Expand Down
5 changes: 4 additions & 1 deletion src/bricks/effects/tourEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ export class TourEffect extends EffectABC {
);
}

assertNotNullish(modComponentId, "extensionId is required to run a tour");
assertNotNullish(
modComponentId,
"modComponentId is required to run a tour",
);

const tour = introJs()
.setOptions({
Expand Down
2 changes: 1 addition & 1 deletion src/bricks/renderers/customForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class CustomFormRenderer extends RendererABC {
{ logger, runPipeline, platform }: BrickOptions,
): Promise<ComponentRef> {
if (logger.context.modComponentId == null) {
throw new Error("extensionId is required");
throw new Error("modComponentId is required");
}

// Redundant with the JSON Schema input validation for `required`. But keeping here for clarity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,12 @@ describe("DisplayTemporaryInfo", () => {
const options = {
...testOptions("v3"),
logger: new ConsoleLogger(
modComponentRefFactory({
extensionId,
blueprintId: null,
}),
mapModComponentRefToMessageContext(
modComponentRefFactory({
extensionId,
blueprintId: null,
}),
),
),
};

Expand Down
7 changes: 5 additions & 2 deletions src/bricks/transformers/temporaryInfo/EphemeralPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { type PanelButton } from "@/types/sidebarTypes";
import { ClosePanelAction } from "@/bricks/errors";
import styles from "./EphemeralPanel.module.scss";
import useReportError from "@/hooks/useReportError";
import { mapModComponentRefToMessageContext } from "@/utils/modUtils";

type Mode = "modal" | "popover";

Expand Down Expand Up @@ -174,7 +175,9 @@ const EphemeralPanel: React.FC = () => {
<PanelBody
isRootPanel={false}
payload={entry.payload}
context={entry.modComponentRef}
context={mapModComponentRefToMessageContext(
entry.modComponentRef,
)}
onAction={(action) => {
resolveTemporaryPanel(target, panelNonce, action);
}}
Expand Down Expand Up @@ -216,7 +219,7 @@ const EphemeralPanel: React.FC = () => {
<PanelBody
isRootPanel={false}
payload={entry.payload}
context={entry.modComponentRef}
context={mapModComponentRefToMessageContext(entry.modComponentRef)}
onAction={(action) => {
resolveTemporaryPanel(target, panelNonce, action);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,20 @@ function clearIntegrationSelection(

const NO_AUTH_OPTIONS = freeze<AuthOption[]>([]);

type SelectedEventPayload = {
integration_id?: RegistryId;
is_user_action?: boolean;
auth_label?: string;
auth_sharing_type?: string;
auth_is_local?: boolean;
};

// The only reason these inputs are optional is for tests, need to investigate better mocking instead
// @see BotOptions.test.ts
const makeSelectedEventPayload = (
authOption?: AuthOption,
isUserAction?: boolean,
) => {
): SelectedEventPayload => {
if (!authOption) {
return {};
}
Expand Down

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

4 changes: 2 additions & 2 deletions src/mods/hooks/useDeactivateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null {
await deactivateMod(modId, modComponentsFromMod, dispatch);

reportEvent(Events.MOD_REMOVE, {
blueprintId: modId,
modId,
});
} else {
await deactivateModComponents(
Expand All @@ -72,7 +72,7 @@ function useDeactivateAction(modViewItem: ModViewItem): (() => void) | null {

for (const modComponent of modComponentsFromMod) {
reportEvent(Events.MOD_COMPONENT_REMOVE, {
extensionId: modComponent.id,
modComponentId: modComponent.id,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pageEditor/hooks/useDeactivateMod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function useDeactivateMod(): (useDeactivateConfig: Config) => Promise<void> {
);

void clearLog({
modId: modId,
modId,
});

dispatch(actions.removeModData(modId));
Expand Down
4 changes: 3 additions & 1 deletion src/sidebar/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ const Tabs: React.FC = () => {
isRootPanel
payload={panel.payload}
onAction={permanentSidebarPanelAction}
context={panel.modComponentRef}
context={mapModComponentRefToMessageContext(
panel.modComponentRef,
)}
/>
</ErrorBoundary>
</Tab.Pane>
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/TemporaryPanelTabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const TemporaryPanelTabPane: React.FC<{
<PanelBody
isRootPanel={false}
payload={payload}
context={modComponentRef}
context={mapModComponentRefToMessageContext(modComponentRef)}
onAction={onAction}
/>
</ErrorBoundary>
Expand Down
2 changes: 1 addition & 1 deletion src/starterBricks/trigger/triggerStarterBrick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ describe("triggerStarterBrick", () => {

// Does not report successful event only once
expect(reportEventMock).toHaveBeenCalledExactlyOnceWith("TriggerRun", {
extensionId: modComponent.id,
modComponentId: modComponent.id,
});

// Reports an error once
Expand Down
18 changes: 9 additions & 9 deletions src/telemetry/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ describe("logging", () => {
await expect(count()).resolves.toBe(0);
});

test("clearLog by blueprint id", async () => {
const blueprintId = registryIdFactory();
test("clearLog by mod id", async () => {
const modId = registryIdFactory();

await appendEntry(
logEntryFactory({
context: messageContextFactory({ modId: blueprintId }),
context: messageContextFactory({ modId }),
}),
);

await appendEntry(logEntryFactory());

await clearLog({ modId: blueprintId });
await clearLog({ modId });

await expect(count()).resolves.toBe(1);
});
Expand All @@ -119,20 +119,20 @@ describe("logging", () => {
// Increase timeout so test isn't flakey on CI due to slow append operation
}, 20_000);

test("getLogEntries by blueprintId", async () => {
const blueprintId = registryIdFactory();
test("getLogEntries by modId", async () => {
const modId = registryIdFactory();

await appendEntry(
logEntryFactory({
context: messageContextFactory({ modId: blueprintId }),
context: messageContextFactory({ modId }),
}),
);

await appendEntry(logEntryFactory());

await expect(getLogEntries({ modId: blueprintId })).resolves.toStrictEqual([
await expect(getLogEntries({ modId })).resolves.toStrictEqual([
expect.objectContaining({
context: expect.objectContaining({ blueprintId }),
context: expect.objectContaining({ modId }),
}),
]);
});
Expand Down
12 changes: 6 additions & 6 deletions src/telemetry/telemetryHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe("mapModComponentRefToEventData", () => {
it("maps fields", () => {
const value = modComponentRefFactory();
expect(mapModComponentRefToMessageContext(value)).toStrictEqual({
extensionId: value.extensionId,
blueprintId: value.blueprintId,
extensionPointId: value.extensionPointId,
modComponentId: value.extensionId,
modId: value.blueprintId,
starterBrickId: value.extensionPointId,
});
});

Expand All @@ -56,9 +56,9 @@ describe("mapModComponentRefToEventData", () => {
blueprintId: null,
});
expect(mapModComponentRefToMessageContext(value)).toStrictEqual({
extensionId: value.extensionId,
blueprintId: undefined,
extensionPointId: value.extensionPointId,
modComponentId: value.extensionId,
modId: undefined,
starterBrickId: value.extensionPointId,
});
});

Expand Down
5 changes: 3 additions & 2 deletions src/testUtils/factories/runtimeFactories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ export const brickOptionsFactory = define<BrickOptions>({
},
platform: (_i: number) => contentScriptPlatform,
logger(_i: number) {
const { blueprintId, ...rest } = modComponentRefFactory();
const { blueprintId, extensionId, ...rest } = modComponentRefFactory();
// MessageContext expects undefined instead of null for blueprintId
return new ConsoleLogger({
...rest,
blueprintId: blueprintId ?? undefined,
modComponentId: extensionId,
modId: blueprintId ?? undefined,
});
},
root: (_i: number) => document,
Expand Down
1 change: 0 additions & 1 deletion src/types/sidebarTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export function isRendererErrorPayload(
*/
export type PanelContext = MessageContext & {
modComponentId: UUID;
modId: RegistryId | null;
};

/**
Expand Down
Loading

0 comments on commit d452a0b

Please sign in to comment.