Skip to content

Commit

Permalink
Revert "#8783: update ModComponentRef property names (#8784)"
Browse files Browse the repository at this point in the history
This reverts commit e8f8e61.
  • Loading branch information
grahamlangford committed Jul 10, 2024
1 parent f577272 commit 3bd6a9b
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe("DisplayTemporaryInfo", () => {

expect(waitForTemporaryPanel).toHaveBeenCalledWith({
nonce: expect.toBeString(),
extensionId: modComponentRef.modComponentId,
extensionId: modComponentRef.extensionId,
location: "modal",
entry: expect.objectContaining({
modComponentRef,
Expand Down Expand Up @@ -354,8 +354,8 @@ describe("DisplayTemporaryInfo", () => {
logger: new ConsoleLogger(
mapModComponentRefToMessageContext(
modComponentRefFactory({
modComponentId: extensionId,
modId: null,
extensionId,
blueprintId: null,
}),
),
),
Expand Down
4 changes: 2 additions & 2 deletions src/components/quickBar/quickBarRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class QuickBarRegistry implements QuickBarProtocol {
removeStarterBrickActions(starterBrickId: RegistryId): void {
remove(
this.actions,
(x) => x.modComponentRef?.starterBrickId === starterBrickId,
(x) => x.modComponentRef?.extensionPointId === starterBrickId,
);
this.notifyListeners();
}
Expand All @@ -135,7 +135,7 @@ class QuickBarRegistry implements QuickBarProtocol {
remove(
this.actions,
(x) =>
x.modComponentRef?.modComponentId === modComponentId &&
x.modComponentRef?.extensionId === modComponentId &&
// Exclude the root action
!this.knownGeneratorRootIds.has(x.id),
);
Expand Down
10 changes: 5 additions & 5 deletions src/contentScript/ephemeralPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function ephemeralPanel({
registerEmptyTemporaryPanel({
nonce,
location,
extensionId: panelEntryMetadata.modComponentRef.modComponentId,
extensionId: panelEntryMetadata.modComponentRef.extensionId,
});

await showSidebar();
Expand All @@ -125,7 +125,7 @@ export async function ephemeralPanel({
nonce,
payload: {
key: uuidv4(),
extensionId: panelEntryMetadata.modComponentRef.modComponentId,
extensionId: panelEntryMetadata.modComponentRef.extensionId,
loadingMessage: "Loading",
},
});
Expand All @@ -141,14 +141,14 @@ export async function ephemeralPanel({
// Popover/modal location
// Clear existing to remove stale modals/popovers
await cancelTemporaryPanelsForExtension(
panelEntryMetadata.modComponentRef.modComponentId,
panelEntryMetadata.modComponentRef.extensionId,
);

// Register empty panel for "loading" state
registerEmptyTemporaryPanel({
nonce,
location,
extensionId: panelEntryMetadata.modComponentRef.modComponentId,
extensionId: panelEntryMetadata.modComponentRef.extensionId,
});

// Create a source URL for content that will be loaded in the panel iframe
Expand Down Expand Up @@ -235,7 +235,7 @@ export async function ephemeralPanel({
nonce,
location,
entry,
extensionId: entry.modComponentRef.modComponentId,
extensionId: entry.modComponentRef.extensionId,
onRegister: onReady,
});
return panelAction ?? {};
Expand Down
8 changes: 4 additions & 4 deletions src/contentScript/pageEditor/runRendererBrick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function runRendererBrick({

let payload: PanelPayload;
try {
await runBrickPreview({ ...args, modId: modComponentRef.modId });
await runBrickPreview({ ...args, modId: modComponentRef.blueprintId });
// We're expecting a HeadlessModeError (or other error) to be thrown in the line above
// noinspection ExceptionCaughtLocallyJS
throw new NoRendererError();
Expand All @@ -74,14 +74,14 @@ export async function runRendererBrick({
blockId: error.blockId,
args: error.args,
ctxt: error.ctxt,
extensionId: modComponentRef.modComponentId,
extensionId: modComponentRef.extensionId,
runId,
};
} else {
payload = {
key: nonce,
error: serializeError(error),
extensionId: modComponentRef.modComponentId,
extensionId: modComponentRef.extensionId,
runId,
};
}
Expand All @@ -104,7 +104,7 @@ export async function runRendererBrick({
await waitForTemporaryPanel({
nonce,
location,
extensionId: modComponentRef.modComponentId,
extensionId: modComponentRef.extensionId,
entry: {
modComponentRef,
nonce,
Expand Down
49 changes: 26 additions & 23 deletions src/contentScript/sidebarController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export function removeModComponents(modComponentIds: UUID[]): void {
const current = panels.splice(0);
panels.push(
...current.filter(
(x) => !modComponentIds.includes(x.modComponentRef.modComponentId),
(x) => !modComponentIds.includes(x.modComponentRef.extensionId),
),
);
void renderPanelsIfVisible();
Expand All @@ -393,7 +393,7 @@ export function removeStarterBrick(
console.debug("sidebarController:removeStarterBrick %s", starterBrickId, {
preserveExtensionIds,
panels: panels.filter(
(x) => x.modComponentRef.starterBrickId === starterBrickId,
(x) => x.modComponentRef.extensionPointId === starterBrickId,
),
});

Expand All @@ -402,8 +402,8 @@ export function removeStarterBrick(
panels.push(
...current.filter(
(x) =>
x.modComponentRef.starterBrickId !== starterBrickId ||
preserveExtensionIds.includes(x.modComponentRef.modComponentId),
x.modComponentRef.extensionPointId !== starterBrickId ||
preserveExtensionIds.includes(x.modComponentRef.extensionId),
),
);

Expand All @@ -418,22 +418,25 @@ export function reservePanels(refs: ModComponentRef[]): void {
return;
}

const current = new Set(panels.map((x) => x.modComponentRef.modComponentId));
for (const modComponentRef of refs) {
const { modComponentId, starterBrickId, modId } = modComponentRef;
if (!current.has(modComponentId)) {
const current = new Set(panels.map((x) => x.modComponentRef.extensionId));
for (const { extensionId, extensionPointId, blueprintId } of refs) {
if (!current.has(extensionId)) {
const entry: PanelEntry = {
type: "panel",
modComponentRef,
modComponentRef: {
extensionId,
extensionPointId,
blueprintId,
},
heading: "",
payload: null,
};

console.debug(
"sidebarController:reservePanels: reserve panel %s for %s",
modComponentId,
starterBrickId,
modId,
extensionId,
extensionPointId,
blueprintId,
{ ...entry },
);

Expand All @@ -446,15 +449,15 @@ export function reservePanels(refs: ModComponentRef[]): void {

export function updateHeading(extensionId: UUID, heading: string): void {
const entry = panels.find(
(x) => x.modComponentRef.modComponentId === extensionId,
(x) => x.modComponentRef.extensionId === extensionId,
);

if (entry) {
entry.heading = heading;
console.debug(
"updateHeading: update heading for panel %s for %s",
extensionId,
entry.modComponentRef.starterBrickId,
entry.modComponentRef.extensionPointId,
{ ...entry },
);
void renderPanelsIfVisible();
Expand All @@ -471,30 +474,30 @@ export function upsertPanel(
heading: string,
payload: PanelPayload,
): void {
const { modComponentId, starterBrickId, modId } = modComponentRef;
const { extensionId, extensionPointId, blueprintId } = modComponentRef;

const entry = panels.find(
(panel) => panel.modComponentRef.modComponentId === modComponentId,
(panel) => panel.modComponentRef.extensionId === extensionId,
);
if (entry) {
entry.payload = payload;
entry.heading = heading;
console.debug(
"sidebarController:upsertPanel: update existing panel %s for %s",
modComponentId,
starterBrickId,
modId,
extensionId,
extensionPointId,
blueprintId,
{ ...entry },
);
} else {
console.debug(
"sidebarController:upsertPanel: add new panel %s for %s",
modComponentId,
starterBrickId,
modId,
extensionId,
extensionPointId,
blueprintId,
{
entry,
starterBrickId,
extensionPointId,
heading,
payload,
},
Expand Down
6 changes: 3 additions & 3 deletions src/pageEditor/tabs/effect/useDocumentPreviewRunBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ export default function useDocumentPreviewRunBlock(
runId: traceRecord.runId,
title,
modComponentRef: {
modComponentId,
modId: modMetadata?.id,
starterBrickId,
extensionId: modComponentId,
blueprintId: modMetadata?.id,
extensionPointId: starterBrickId,
},
args: {
apiVersion,
Expand Down
4 changes: 2 additions & 2 deletions src/platform/forms/formController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export async function registerForm({

const preexistingForms = [...forms.entries()].filter(
([_, registeredForm]) =>
registeredForm.modComponentRef.modComponentId ===
modComponentRef.modComponentId,
registeredForm.modComponentRef.extensionId ===
modComponentRef.extensionId,
);

if (preexistingForms.length > 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/platform/panels/panelController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export function updatePanelDefinition(
// Panel entry may be undefined if the panel was registered with registerEmptyTemporaryPanel
if (
panel.entry &&
panel.entry.modComponentRef.modComponentId !==
panelDefinition.modComponentRef.modComponentId
panel.entry.modComponentRef.extensionId !==
panelDefinition.modComponentRef.extensionId
) {
throw new Error("extensionId mismatch");
}
Expand Down Expand Up @@ -205,7 +205,7 @@ function removePanelEntry(panelNonce: UUID): void {
const panel = panels.get(panelNonce);
if (panel?.entry) {
extensionNonces
.get(panel.entry.modComponentRef.modComponentId)
.get(panel.entry.modComponentRef.extensionId)
?.delete(panelNonce);
}

Expand Down
6 changes: 3 additions & 3 deletions src/sidebar/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const Tabs: React.FC = () => {
>
{panels.map((panel) => (
<TabWithDivider
key={panel.modComponentRef.modComponentId}
key={panel.modComponentRef.extensionId}
active={isPanelActive(panel)}
eventKey={eventKeyForEntry(panel)}
>
Expand All @@ -226,7 +226,7 @@ const Tabs: React.FC = () => {

{forms.map((form) => (
<TabWithDivider
key={form.modComponentRef.modComponentId}
key={form.modComponentRef.extensionId}
active={isPanelActive(form)}
eventKey={eventKeyForEntry(form)}
>
Expand Down Expand Up @@ -311,7 +311,7 @@ const Tabs: React.FC = () => {
// un-submitted form state/scroll position
unmountOnExit={false}
className={cx("full-height flex-grow", styles.paneOverrides)}
key={panel.modComponentRef.modComponentId}
key={panel.modComponentRef.extensionId}
eventKey={eventKeyForEntry(panel)}
>
<ErrorBoundary
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/TemporaryPanelTabPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const TemporaryPanelTabPane: React.FC<{
<ErrorBoundary
onError={() => {
reportEvent(Events.VIEW_ERROR, {
...modComponentRef,
...mapModComponentRefToMessageContext(modComponentRef),
panelType: type,
});
}}
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/modLauncher/ActiveSidebarModsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const ActiveSidebarModsList: React.FunctionComponent = () => {
tableInstance.prepareRow(row);
return (
<ActiveSidebarModsListItem
key={row.original.modComponentRef.modComponentId}
key={row.original.modComponentRef.extensionId}
panel={row.original}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions src/sidebar/sidebarSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const selectSidebarEntries = ({ sidebar }: SidebarRootState) => [
const extensionForEventKeySelector = createSelector(
selectSidebarEntries,
selectActivatedModComponents,
(_state: SidebarRootState, eventKey: string) => eventKey,
(state: SidebarRootState, eventKey: string) => eventKey,
(entries, extensions, eventKey): ActivatedModComponent | undefined => {
// Get sidebar entry by event key
const sidebarEntry = entries.find(
Expand All @@ -76,7 +76,7 @@ const extensionForEventKeySelector = createSelector(

return extensions.find(
(modComponent) =>
modComponent.id === sidebarEntry.modComponentRef.modComponentId,
modComponent.id === sidebarEntry.modComponentRef.extensionId,
);
},
);
Expand All @@ -102,7 +102,7 @@ export const selectExtensionFromEventKey =

return extensions.find(
(modComponent) =>
modComponent.id === sidebarEntry.modComponentRef.modComponentId,
modComponent.id === sidebarEntry.modComponentRef.extensionId,
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/starterBricks/sidebar/sidebarStarterBrick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("sidebarExtension", () => {
panels: [
expect.objectContaining({
modComponentRef: expect.objectContaining({
starterBrickId: starterBrick.id,
extensionPointId: starterBrick.id,
}),
}),
],
Expand Down
Loading

0 comments on commit 3bd6a9b

Please sign in to comment.