Skip to content

Commit

Permalink
Revert type vs. kind
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller committed Jun 28, 2024
1 parent 88add97 commit 0f2da20
Show file tree
Hide file tree
Showing 39 changed files with 165 additions and 161 deletions.
6 changes: 3 additions & 3 deletions src/analysis/analysisVisitors/selectorAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { guessUsefulness } from "@/utils/detectRandomString";
import type { Schema } from "@/types/schemaTypes";
import { isObject } from "@/utils/objectUtils";
import { assertNotNullish } from "@/utils/nullishUtils";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

// `jQuery` selector extension: https://api.jquery.com/category/selectors/jquery-selector-extensions/
const jQueryExtensions = new Set([
Expand Down Expand Up @@ -91,12 +91,12 @@ class SelectorAnalysis extends AnalysisVisitorWithResolvedBricksABC {

override async run(component: ModComponentFormState): Promise<void> {
switch (component.type) {
case StarterBrickKinds.BUTTON: {
case StarterBrickTypes.BUTTON: {
this.checkAction(component);
break;
}

case StarterBrickKinds.TRIGGER: {
case StarterBrickTypes.TRIGGER: {
this.checkTrigger(component);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/background/deploymentUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { packageConfigDetailFactory } from "@/testUtils/factories/brickFactories
import { type RegistryPackage } from "@/types/contract";
import { resetMeApiMocks } from "@/testUtils/userMock";
import { TEST_deleteFeatureFlagsCache } from "@/auth/featureFlagStorage";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

TEST_setContext("background");

Expand Down Expand Up @@ -439,7 +439,7 @@ describe("syncDeployments", () => {
});

let editorState = initialEditorState;
const element = (await ADAPTERS.get(StarterBrickKinds.BUTTON).fromExtension(
const element = (await ADAPTERS.get(StarterBrickTypes.BUTTON).fromExtension(
modComponent,
)) as ActionFormState;
editorState = editorSlice.reducer(
Expand Down
4 changes: 2 additions & 2 deletions src/background/starterMods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
import produce from "immer";
import { type StarterBrickDefinitionProp } from "@/starterBricks/types";
import { type ModDefinition } from "@/types/modDefinitionTypes";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import {
PIXIEBRIX_INTEGRATION_ID,
PIXIEBRIX_INTEGRATION_CONFIG_ID,
Expand Down Expand Up @@ -93,7 +93,7 @@ beforeEach(async () => {
describe("debouncedActivateStarterMods", () => {
function overrideStarterBrickType(
modDefinition: ModDefinition,
type: StarterBrickKind,
type: StarterBrickType,
) {
return produce(modDefinition, (draft) => {
(
Expand Down
8 changes: 4 additions & 4 deletions src/bricks/PipelineVisitor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
pipelineFactory,
} from "@/testUtils/factories/brickFactories";
import { toExpression } from "@/utils/expressionUtils";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

test("should invoke the callback for the pipeline bricks", () => {
const pipeline = pipelineFactory();
Expand All @@ -46,7 +46,7 @@ test("should invoke the callback for the pipeline bricks", () => {

const visitor = new Visitor();
visitor.visitRootPipeline(pipeline, {
extensionPointType: StarterBrickKinds.BUTTON,
extensionPointType: StarterBrickTypes.BUTTON,
});

expect(visitBlock).toHaveBeenCalledTimes(pipeline.length);
Expand Down Expand Up @@ -104,7 +104,7 @@ test("should invoke the callback for the sub pipeline bricks", () => {
}
const visitor = new Visitor();
visitor.visitRootPipeline(pipeline, {
extensionPointType: StarterBrickKinds.BUTTON,
extensionPointType: StarterBrickTypes.BUTTON,
});

expect(visitBlock).toHaveBeenCalledTimes(
Expand Down Expand Up @@ -186,7 +186,7 @@ test("should invoke the callback for the Document button pipeline", () => {
}
const visitor = new Visitor();
visitor.visitRootPipeline(pipeline, {
extensionPointType: StarterBrickKinds.INLINE_PANEL,
extensionPointType: StarterBrickTypes.INLINE_PANEL,
});

expect(visitBlock).toHaveBeenCalledTimes(2); // One Document brick and one brick in the pipeline
Expand Down
4 changes: 2 additions & 2 deletions src/bricks/PipelineVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
getRootPipelineFlavor,
getSubPipelineFlavor,
} from "@/bricks/brickFilterHelpers";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts";
import { isPipelineExpression } from "@/utils/expressionUtils";
import { joinPathParts } from "@/utils/formUtils";
Expand Down Expand Up @@ -79,7 +79,7 @@ export type VisitPipelineExtra = {
pipelinePropName?: string | undefined;
};
type VisitRootPipelineExtra = {
extensionPointType: StarterBrickKind;
extensionPointType: StarterBrickType;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/bricks/brickFilterHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { type TypedBrickPair } from "@/bricks/registry";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { stubTrue } from "lodash";
import { DocumentRenderer } from "@/bricks/renderers/document";
import { type BrickType, BrickTypes } from "@/runtime/runtimeTypes";
Expand All @@ -39,7 +39,7 @@ const ALWAYS_SHOW = new Set([

export type IsBrickAllowedPredicate = (block: TypedBrickPair) => boolean;

export function getRootPipelineFlavor(starterBrickType: StarterBrickKind) {
export function getRootPipelineFlavor(starterBrickType: StarterBrickType) {
if (PANEL_TYPES.includes(starterBrickType)) {
return PipelineFlavor.NoEffect;
}
Expand Down
4 changes: 2 additions & 2 deletions src/contentScript/pageEditor/insertButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { findContainer } from "@/utils/inference/selectorInference";
import { PRIVATE_ATTRIBUTES_SELECTOR } from "@/domConstants";
import { type ButtonSelectionResult } from "@/contentScript/pageEditor/types";
import { inferButtonHTML } from "@/utils/inference/markupInference";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

const DEFAULT_ACTION_CAPTION = "Action";

Expand Down Expand Up @@ -75,7 +75,7 @@ export async function insertButton(
caption: DEFAULT_ACTION_CAPTION,
},
menu: {
type: StarterBrickKinds.BUTTON,
type: StarterBrickTypes.BUTTON,
containerSelector: containerSelectors[0],
template: beautifyHTML(inferButtonHTML(container, selected), {
indent_handlebars: true,
Expand Down
4 changes: 2 additions & 2 deletions src/contentScript/pageEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
type StarterBrickDefinitionLike,
type StarterBrickDefinitionProp,
} from "@/starterBricks/types";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { type Except } from "type-fest";
import {
type PanelConfig,
Expand All @@ -40,7 +40,7 @@ export interface DraftModComponent<
StarterBrickDefinitionProp = StarterBrickDefinitionProp,
TExtension extends UnknownObject = UnknownObject,
> {
type: StarterBrickKind;
type: StarterBrickType;
extensionPointConfig: StarterBrickDefinitionLike<TExtensionPoint>;
extension: ModComponentBase<TExtension>;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ import { shouldAutoRun } from "@/pageEditor/toolbar/ReloadToolbar";
import ReduxPersistenceContext, {
type ReduxPersistenceContextType,
} from "@/store/ReduxPersistenceContext";
import type { StarterBrickKind } from "@/types/starterBrickTypes";
import type { StarterBrickType } from "@/types/starterBrickTypes";
import type { EditorState } from "@/pageEditor/pageEditorTypes";
import DimensionGate from "@/pageEditor/components/DimensionGate";
import { allFramesInInspectedTab } from "@/pageEditor/context/connection";
import DatabaseUnresponsiveBanner from "@/components/DatabaseUnresponsiveBanner";

const STARTER_BRICKS_TO_EXCLUDE_FROM_CLEANUP: StarterBrickKind[] = [
const STARTER_BRICKS_TO_EXCLUDE_FROM_CLEANUP: StarterBrickType[] = [
"actionPanel",
"panel",
];
Expand Down
6 changes: 3 additions & 3 deletions src/pageEditor/baseFormStateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "@/integrations/integrationTypes";
import { type ApiVersion, type OptionsArgs } from "@/types/runtimeTypes";
import { type UUID } from "@/types/stringTypes";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { type Permissions } from "webextension-polyfill";
import { type ModComponentBase } from "@/types/modComponentTypes";
import { type ModOptionsDefinition } from "@/types/modDefinitionTypes";
Expand All @@ -43,7 +43,7 @@ export type SingleLayerReaderConfig =
export type BaseExtensionPointState = {
metadata: Metadata;
definition: {
type: StarterBrickKind;
type: StarterBrickType;
// We're currently not allowing users to modify readers in the page editor
reader: SingleLayerReaderConfig;
isAvailable: NormalizedAvailability;
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface BaseFormStateV1<
/**
* The type of the extensionPoint
*/
readonly type: StarterBrickKind;
readonly type: StarterBrickType;

/**
* True if the extensionPoint exists in the registry
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/exampleStarterBrickConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { type BrickPipeline } from "@/bricks/types";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { validateRegistryId } from "@/types/helpers";
import {
createNewConfiguredBrick,
Expand All @@ -29,7 +29,7 @@ const documentBrickId = validateRegistryId("@pixiebrix/document");
const quickbarActionId = validateRegistryId("@pixiebrix/quickbar/add");
const tourStepBrickId = validateRegistryId("@pixiebrix/tour/step");

export function getExampleBrickPipeline(type: StarterBrickKind): BrickPipeline {
export function getExampleBrickPipeline(type: StarterBrickType): BrickPipeline {
if (type === "actionPanel") {
const documentBuilderBlock = createNewConfiguredBrick(documentBrickId);
return [documentBuilderBlock];
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/pageEditorTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { type ModComponentsRootState } from "@/store/extensionsTypes";
import { type SavingExtensionState } from "@/pageEditor/panes/save/savingExtensionSlice";
import { type SettingsRootState } from "@/store/settings/settingsTypes";
import { type RuntimeRootState } from "@/pageEditor/slices/runtimeSliceTypes";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { type UUID } from "@/types/stringTypes";
import { type Metadata, type RegistryId } from "@/types/registryTypes";
import { type BrickConfig, type PipelineFlavor } from "@/bricks/types";
Expand Down Expand Up @@ -86,7 +86,7 @@ export type EditorStateV1 = {
/**
* The element type, if the page editor is in "insertion-mode"
*/
inserting: StarterBrickKind | null;
inserting: StarterBrickType | null;

/**
* The uuid of the active element, if an extension is selected
Expand Down
10 changes: 5 additions & 5 deletions src/pageEditor/panes/insert/InsertPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import React, { useCallback } from "react";
import {
type StarterBrickKind,
StarterBrickKinds,
type StarterBrickType,
StarterBrickTypes,
} from "@/types/starterBrickTypes";
import InsertMenuItemPane from "@/pageEditor/panes/insert/InsertMenuItemPane";
import InsertPanelPane from "@/pageEditor/panes/insert/InsertPanelPane";
Expand All @@ -29,7 +29,7 @@ import useAutoInsert from "@/pageEditor/panes/insert/useAutoInsert";
import { inspectedTab } from "@/pageEditor/context/connection";
import { cancelSelect } from "@/contentScript/messenger/api";

const InsertPane: React.FC<{ inserting: StarterBrickKind }> = ({
const InsertPane: React.FC<{ inserting: StarterBrickType }> = ({
inserting,
}) => {
// Auto-insert if the StarterBrickType supports it
Expand All @@ -46,11 +46,11 @@ const InsertPane: React.FC<{ inserting: StarterBrickKind }> = ({
useEscapeHandler(cancelInsert, inserting != null);

switch (inserting) {
case StarterBrickKinds.BUTTON: {
case StarterBrickTypes.BUTTON: {
return <InsertMenuItemPane cancel={cancelInsert} />;
}

case StarterBrickKinds.INLINE_PANEL: {
case StarterBrickTypes.INLINE_PANEL: {
return <InsertPanelPane cancel={cancelInsert} />;
}

Expand Down
10 changes: 5 additions & 5 deletions src/pageEditor/panes/insert/useAutoInsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { openSidePanel } from "@/utils/sidePanelUtils";
import reportEvent from "@/telemetry/reportEvent";
import { Events } from "@/telemetry/events";
import {
type StarterBrickKind,
StarterBrickKinds,
type StarterBrickType,
StarterBrickTypes,
} from "@/types/starterBrickTypes";
import { ADAPTERS } from "@/pageEditor/starterBricks/adapter";
import notify from "@/utils/notify";
Expand All @@ -22,14 +22,14 @@ import {

const { addModComponentFormState, toggleInsert } = actions;

function useAutoInsert(type: StarterBrickKind): void {
function useAutoInsert(type: StarterBrickType): void {
const dispatch = useDispatch();

useAsyncEffect(async () => {
// These have their own UI, so don't auto-insert
if (
type === StarterBrickKinds.BUTTON ||
type === StarterBrickKinds.INLINE_PANEL ||
type === StarterBrickTypes.BUTTON ||
type === StarterBrickTypes.INLINE_PANEL ||
type == null
) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/sidebar/ActivatedModComponentListItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import { formStateFactory } from "@/testUtils/factories/pageEditorFactories";
import { screen, waitFor } from "@testing-library/react";
import { disableOverlay, enableOverlay } from "@/contentScript/messenger/api";
import userEvent from "@testing-library/user-event";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

jest.mock("@/pageEditor/starterBricks/adapter", () => {
const actual = jest.requireActual("@/pageEditor/starterBricks/adapter");
return {
...actual,
selectType: jest.fn(async () => StarterBrickKinds.BUTTON),
selectType: jest.fn(async () => StarterBrickTypes.BUTTON),
};
});

Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/sidebar/ActivatedModComponentListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { emptyModOptionsDefinitionFactory } from "@/utils/modUtils";
import { type Schema } from "@/types/schemaTypes";
import useAsyncState from "@/hooks/useAsyncState";
import { inspectedTab } from "@/pageEditor/context/connection";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

/**
* A sidebar menu entry corresponding to an untouched mod component
Expand Down Expand Up @@ -136,7 +136,7 @@ const ActivatedModComponentListItem: React.FunctionComponent<{
[sessionId, dispatch, type, getModDefinition],
);

const isButton = type === StarterBrickKinds.BUTTON;
const isButton = type === StarterBrickTypes.BUTTON;

const showOverlay = useCallback(async (uuid: UUID) => {
await enableOverlay(inspectedTab, `[data-pb-uuid="${uuid}"]`);
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/sidebar/DraftModComponentListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
import useSaveMod from "@/pageEditor/hooks/useSaveMod";
import { selectIsModComponentSavedOnCloud } from "@/store/extensionsSelectors";
import { inspectedTab } from "@/pageEditor/context/connection";
import { StarterBrickKinds } from "@/types/starterBrickTypes";
import { StarterBrickTypes } from "@/types/starterBrickTypes";

type DraftModComponentListItemProps = {
modComponentFormState: ModComponentFormState;
Expand Down Expand Up @@ -94,7 +94,7 @@ const DraftModComponentListItem: React.FunctionComponent<
selectIsModComponentSavedOnCloud(modComponentFormState.uuid),
);
const removeModComponentFromStorage = useRemoveModComponentFromStorage();
const isButton = modComponentFormState.type === StarterBrickKinds.BUTTON;
const isButton = modComponentFormState.type === StarterBrickTypes.BUTTON;

const showOverlay = useCallback(async (uuid: UUID) => {
await enableOverlay(inspectedTab, `[data-pb-uuid="${uuid}"]`);
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/sidebar/ExtensionIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import {
faEyeSlash,
faPuzzlePiece,
} from "@fortawesome/free-solid-svg-icons";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import Icon from "@/icons/Icon";

export const ExtensionIcon: React.FunctionComponent<{
type: StarterBrickKind;
type: StarterBrickType;
}> = ({ type }) => (
<FontAwesomeIcon
fixedWidth
Expand Down
4 changes: 2 additions & 2 deletions src/pageEditor/slices/editorSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { clearExtensionTraces } from "@/telemetry/trace";
import { FOUNDATION_NODE_ID } from "@/pageEditor/uiState/uiState";
import { type BrickConfig } from "@/bricks/types";
import { type StarterBrickKind } from "@/types/starterBrickTypes";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import {
type AddBrickLocation,
type EditorRootState,
Expand Down Expand Up @@ -313,7 +313,7 @@ export const editorSlice = createSlice({
resetEditor() {
return initialState;
},
toggleInsert(state, action: PayloadAction<StarterBrickKind | null>) {
toggleInsert(state, action: PayloadAction<StarterBrickType | null>) {
state.inserting = action.payload;
state.beta = false;
state.error = null;
Expand Down
Loading

0 comments on commit 0f2da20

Please sign in to comment.