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

Use ModComponentRef instead of flat extensionId and blueprintId in panel entries #8756

Merged
merged 13 commits into from
Jul 8, 2024

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Jul 6, 2024

What does this PR do?

  • Use ModComponentRef instead of flat extensionId and blueprintId in panel runtime
    • Follows the principle that semantically coupled properties should be grouped
  • Prep work for renaming associated to use official terminology
  • Prep work for making mod id required in the runtime

Remaining Work

  • Fix broken tests

Discussion

  • Including starter brick on the ref even though it's not strictly necessary in most parts, as it's only used in panel behavior of "show panel" preferring panels from the same mod. We could consider including a type that doesn't include the starter brick reference

Future Work

  • Perform same refactoring for quick bar action registry, etc. NOTE: it's not required for SnippetShortcut because mod and starter brick is not currently used for functionality. (Although, in the future, we might consider clearing stale snippets when the user updates the mod in the Page Editor): Use ModComponentRef in Quick Bar protocol #8758
  • Rationalize the use of MessageContext. The runtime should likely pass ModComponentRef through to BrickOptions vs. bricks having to read the context from the logger's MessageContext, which has weaker nullness constraints
  • Rename fields in ModComponentRef: id (modComponentId would be redundant), modId, starterBrickId
  • Rename uses of extensionId in exported panel runtime code
  • Rename useDocumentPreviewRunBlock

For more information on our expectations for the PR process, see the
code review principles doc

@twschiller twschiller self-assigned this Jul 6, 2024
@twschiller twschiller changed the title Use ModComponentRef instead of flat extensionId and blueprintId in panel runtime Use ModComponentRef instead of flat extensionId and blueprintId in panel runtime Jul 6, 2024
@twschiller twschiller added this to the 2.0.5 milestone Jul 6, 2024
Copy link

github-actions bot commented Jul 6, 2024

Playwright test results

passed  83 passed
flaky  1 flaky
skipped  2 skipped

Details

report  Open report ↗︎
stats  86 tests across 30 suites
duration  13 minutes, 57 seconds
commit  6b8c8a3

Flaky tests

chrome › tests/workshop/createMod.spec.ts › can create a new mod from a yaml definition and update it

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
edge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

});
export function sidebarEntryFactory<T = PanelEntry>(
export function sidebarEntryFactory(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous formulation was not type-safe because there was no constraint on the type. There's no reason for the overrides to use generics, so remove them

@twschiller twschiller changed the title Use ModComponentRef instead of flat extensionId and blueprintId in panel runtime Use ModComponentRef instead of flat extensionId and blueprintId in panel entries Jul 6, 2024
Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 73.49398% with 22 lines in your changes missing coverage. Please review.

Project coverage is 74.24%. Comparing base (8318d74) to head (6b8c8a3).
Report is 22 commits behind head on main.

Files Patch % Lines
src/store/sidebar/sidebarSlice.ts 58.82% 7 Missing ⚠️
src/contentScript/sidebarController.tsx 81.25% 3 Missing ⚠️
...geEditor/tabs/effect/useDocumentPreviewRunBlock.ts 62.50% 3 Missing ⚠️
src/platform/panels/panelController.ts 25.00% 3 Missing ⚠️
src/contentScript/lifecycle.ts 0.00% 2 Missing ⚠️
src/sidebar/sidebarSelectors.ts 0.00% 2 Missing ⚠️
src/contentScript/pageEditor/runRendererBrick.ts 0.00% 1 Missing ⚠️
src/store/sidebar/thunks/addFormPanel.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8756      +/-   ##
==========================================
- Coverage   74.24%   74.24%   -0.01%     
==========================================
  Files        1332     1332              
  Lines       40817    40852      +35     
  Branches     7634     7636       +2     
==========================================
+ Hits        30306    30330      +24     
- Misses      10511    10522      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

* @param modComponentRef
* @see selectEventData
*/
export function mapModComponentRefToEventData(
Copy link
Contributor Author

@twschiller twschiller Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper method to avoid needing to map field names at telemetry sites

*
* @throws TypeError if the extensionId or extensionPointId is missing
*/
export function mapMessageContextToModComponentRef(
Copy link
Contributor Author

@twschiller twschiller Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper method to avoid remapping field names in bricks. Eventually, we need to stop using the logger context in bricks to produce the mod component ref given that the MessageContext nullness type is too weak


expect(state).toStrictEqual({
...state,
activeKey: eventKeyForEntry(originalPanel),
});
});

it("sets activeKey to the active key of any panel with the same modId as the removedEntry if it exists and there is no matching extensionId", () => {
it("sets activeKey to the active key of any panel with the same modId as the removedEntry if it exists and there is no matching component id", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it("sets activeKey to the active key of any panel with the same modId as the removedEntry if it exists and there is no matching component id", () => {
it("sets activeKey to the active key of any panel with the same modId as the removedEntry if it exists and there is no matching mod component id", () => {

Copy link

github-actions bot commented Jul 8, 2024

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@grahamlangford grahamlangford enabled auto-merge (squash) July 8, 2024 15:24
@grahamlangford grahamlangford merged commit 8ca6af5 into main Jul 8, 2024
18 checks passed
@grahamlangford grahamlangford deleted the feature/refactor-component-reference branch July 8, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants