Skip to content

Commit

Permalink
Rename context menu and tour starter bricks
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller committed Jun 21, 2024
1 parent ebc39a7 commit 80fe216
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 127 deletions.
2 changes: 1 addition & 1 deletion src/activation/useActivateRecipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { renderHook } from "@/pageEditor/testHelpers";
import useActivateRecipe from "./useActivateRecipe";
import { validateRegistryId } from "@/types/helpers";
import { type StarterBrickDefinitionLike } from "@/starterBricks/types";
import { type ContextMenuDefinition } from "@/starterBricks/contextMenu/types";
import { type ContextMenuDefinition } from "@/starterBricks/contextMenu/contextMenuTypes";
import { uninstallRecipe } from "@/store/uninstallUtils";
import { type ModDefinition } from "@/types/modDefinitionTypes";
import extensionsSlice from "@/store/extensionsSlice";
Expand Down
4 changes: 2 additions & 2 deletions src/background/contextMenus/initContextMenus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import extensionPointRegistry from "@/starterBricks/registry";
import { fromJS } from "@/starterBricks/contextMenu/contextMenu";
import { fromJS } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import * as backgroundApi from "@/background/messenger/api";
import { type StarterBrickDefinitionLike } from "@/starterBricks/types";
import { type ModComponentBase } from "@/types/modComponentTypes";
Expand All @@ -28,7 +28,7 @@ import { getPlatform } from "@/platform/platformContext";
import {
type ContextMenuDefinition,
type ContextMenuConfig,
} from "@/starterBricks/contextMenu/types";
} from "@/starterBricks/contextMenu/contextMenuTypes";
import { ensureContextMenu } from "@/background/contextMenus/ensureContextMenu";
import { preloadContextMenus } from "@/background/contextMenus/preloadContextMenus";

Expand Down
4 changes: 2 additions & 2 deletions src/background/contextMenus/preloadContextMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import { ContextError } from "@/errors/genericErrors";
import { resolveExtensionInnerDefinitions } from "@/registry/internal";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenu";
import { type ContextMenuConfig } from "@/starterBricks/contextMenu/types";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import { type ContextMenuConfig } from "@/starterBricks/contextMenu/contextMenuTypes";
import { selectEventData } from "@/telemetry/deployments";
import {
type ModComponentBase,
Expand Down
2 changes: 1 addition & 1 deletion src/components/BrickIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import { TriggerStarterBrickABC } from "@/starterBricks/trigger/triggerStarterBrick";
import { MenuItemStarterBrickABC } from "@/starterBricks/menuItem/menuItemStarterBrick";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenu";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import { PanelStarterBrickABC } from "@/starterBricks/panel/panelStarterBrick";
import { SidebarStarterBrickABC } from "@/starterBricks/sidebar/sidebarStarterBrick";
import getType from "@/runtime/getType";
Expand Down
2 changes: 1 addition & 1 deletion src/contentScript/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
} from "@/utils/promiseUtils";
import { $safeFind } from "@/utils/domUtils";
import { onContextInvalidated } from "webext-events";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenu";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import { ReusableAbortController } from "abort-utils";
import { isLoadedInIframe } from "@/utils/iframeUtils";
import { notifyNavigationComplete } from "@/contentScript/sidebarController";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
activateExtensionPanel,
showSidebar,
} from "@/contentScript/sidebarController";
import { type TourDefinition } from "@/starterBricks/tour/types";
import { type TourDefinition } from "@/starterBricks/tour/tourTypes";
import { isLoadedInIframe } from "@/utils/iframeUtils";

export async function updateDraftModComponent({
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/starterBricks/contextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
selectStarterBrickAvailability,
} from "@/pageEditor/starterBricks/base";
import { type StarterBrickDefinitionLike } from "@/starterBricks/types";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenu";
import { ContextMenuStarterBrickABC } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import { faBars } from "@fortawesome/free-solid-svg-icons";
import { type ModComponentFormStateAdapter } from "@/pageEditor/starterBricks/modComponentFormStateAdapter";
import ContextMenuConfiguration from "@/pageEditor/tabs/contextMenu/ContextMenuConfiguration";
Expand All @@ -42,7 +42,7 @@ import { type SingleLayerReaderConfig } from "@/pageEditor/baseFormStateTypes";
import {
type ContextMenuDefinition,
type ContextMenuConfig,
} from "@/starterBricks/contextMenu/types";
} from "@/starterBricks/contextMenu/contextMenuTypes";
import { assertNotNullish } from "@/utils/nullishUtils";

function fromNativeElement(
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/starterBricks/formStateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
type ContextMenuConfig,
type ContextMenuTargetMode,
type MenuDefaultOptions as ContextMenuDefaultOptions,
} from "@/starterBricks/contextMenu/types";
} from "@/starterBricks/contextMenu/contextMenuTypes";
import {
type MenuItemStarterBrickConfig,
type MenuPosition,
Expand Down Expand Up @@ -52,7 +52,7 @@ import {
type QuickBarProviderConfig,
type QuickBarProviderDefaultOptions,
} from "@/starterBricks/quickBarProvider/quickBarProviderTypes";
import { type TourDefinition } from "@/starterBricks/tour/types";
import { type TourDefinition } from "@/starterBricks/tour/tourTypes";
import {
type BaseExtensionPointState,
type BaseExtensionState,
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/starterBricks/tour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ import { faMapSigns } from "@fortawesome/free-solid-svg-icons";
import { type ModComponentFormStateAdapter } from "@/pageEditor/starterBricks/modComponentFormStateAdapter";
import type { DraftModComponent } from "@/contentScript/pageEditor/types";
import { type TourFormState } from "./formStateTypes";
import { TourStarterBrickABC } from "@/starterBricks/tour/tourExtension";
import { TourStarterBrickABC } from "@/starterBricks/tour/tourStarterBrick";
import TourConfiguration from "@/pageEditor/tabs/tour/TourConfiguration";
import { type ModComponentBase } from "@/types/modComponentTypes";
import {
type TourDefinition,
type TourConfig,
} from "@/starterBricks/tour/types";
} from "@/starterBricks/tour/tourTypes";
import { assertNotNullish } from "@/utils/nullishUtils";

function fromNativeElement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { type Metadata } from "@/types/registryTypes";
import { type BrickPipeline } from "@/bricks/types";
import { RootReader } from "@/starterBricks/starterBrickTestUtils";
import blockRegistry from "@/bricks/registry";
import { fromJS } from "@/starterBricks/contextMenu/contextMenu";
import { fromJS } from "@/starterBricks/contextMenu/contextMenuStarterBrick";
import { type ResolvedModComponent } from "@/types/modComponentTypes";
import { uuidSequence } from "@/testUtils/factories/stringFactories";
import { RunReason } from "@/types/runtimeTypes";
Expand All @@ -34,14 +34,14 @@ import { getPlatform } from "@/platform/platformContext";
import {
type ContextMenuDefinition,
type ContextMenuConfig,
} from "@/starterBricks/contextMenu/types";
} from "@/starterBricks/contextMenu/contextMenuTypes";

const uninstallContextMenuMock = jest.mocked(uninstallContextMenu);
const ensureContextMenuMock = jest.mocked(ensureContextMenu);

const rootReader = new RootReader();

const extensionPointFactory = (definitionOverrides: UnknownObject = {}) =>
const starterBrickFactory = (definitionOverrides: UnknownObject = {}) =>
define<StarterBrickDefinitionLike<ContextMenuDefinition>>({
apiVersion: "v3",
kind: "extensionPoint",
Expand All @@ -62,7 +62,7 @@ const extensionPointFactory = (definitionOverrides: UnknownObject = {}) =>
}),
});

const extensionFactory = define<ResolvedModComponent<ContextMenuConfig>>({
const modComponentFactory = define<ResolvedModComponent<ContextMenuConfig>>({
apiVersion: "v3",
_resolvedModComponentBrand: undefined as never,
id: uuidSequence,
Expand All @@ -86,10 +86,10 @@ beforeEach(() => {
jest.resetAllMocks();
});

describe("contextMenu", () => {
describe("contextMenuStarterBrick", () => {
it("should add extension once", async () => {
const starterBrick = fromJS(getPlatform(), extensionPointFactory()());
const modComponent = extensionFactory();
const starterBrick = fromJS(getPlatform(), starterBrickFactory()());
const modComponent = modComponentFactory();

starterBrick.registerModComponent(modComponent);
starterBrick.registerModComponent(modComponent);
Expand All @@ -98,21 +98,21 @@ describe("contextMenu", () => {
});

it("should include context menu props in schema", async () => {
const starterBrick = fromJS(getPlatform(), extensionPointFactory()());
const starterBrick = fromJS(getPlatform(), starterBrickFactory()());
const reader = await starterBrick.defaultReader();
expect(reader.outputSchema.properties).toHaveProperty("selectionText");
});

it("should include context menu props in preview", async () => {
const starterBrick = fromJS(getPlatform(), extensionPointFactory()());
const starterBrick = fromJS(getPlatform(), starterBrickFactory()());
const reader = await starterBrick.previewReader();
const value = await reader.read(document);
expect(value).toHaveProperty("selectionText");
});

it("should register context menu on run", async () => {
const starterBrick = fromJS(getPlatform(), extensionPointFactory()());
const modComponent = extensionFactory();
const starterBrick = fromJS(getPlatform(), starterBrickFactory()());
const modComponent = modComponentFactory();

starterBrick.registerModComponent(modComponent);

Expand All @@ -131,8 +131,8 @@ describe("contextMenu", () => {
});

it("should remove from UI from all tabs on sync", async () => {
const starterBrick = fromJS(getPlatform(), extensionPointFactory()());
const modComponent = extensionFactory();
const starterBrick = fromJS(getPlatform(), starterBrickFactory()());
const modComponent = modComponentFactory();
starterBrick.registerModComponent(modComponent);

await starterBrick.install();
Expand Down
Loading

0 comments on commit 80fe216

Please sign in to comment.