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

#9137: types and migrations for mod variable declaration section (1/3) #9138

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Sep 11, 2024

What does this PR do?

Discussion

  • Opening the PR because due to the POC, this wasn't a big lift. And writing sketch in enough detail to clarify required migration would be equivalently hard
  • Do we want to make variables required on activated mod component? optionsArgs?, services?, definitions? are all optional

Remaining Work

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

*
* @since 2.1.2
*/
variables?: ModVariablesDefinition;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grahamlangford @BLoe do you feel strongly about this being required? optionsArgs?, services?, definitions? are all optional

Copy link
Collaborator

Choose a reason for hiding this comment

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

The more we require, the simpler the typing is. But I don't feel strongly now that we have StrictNullChecks globally enabled

@@ -101,6 +117,7 @@ export interface UnsavedModDefinition extends Definition {
extensionPoints: ModComponentDefinition[];
definitions?: InnerDefinitions;
options?: ModOptionsDefinition;
variables?: ModVariablesDefinition;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Optional to avoid requiring backend/IDB migration. See discussion on activated mod component here: https://github.com/pixiebrix/pixiebrix-extension/pull/9138/files#r1755687124

@twschiller twschiller self-assigned this Sep 11, 2024
@twschiller twschiller added the enhancement New feature or request label Sep 11, 2024
Copy link

github-actions bot commented Sep 11, 2024

Playwright test results

passed  128 passed
flaky  2 flaky
skipped  4 skipped

Details

report  Open report ↗︎
stats  134 tests across 44 suites
duration  2 hours, 34.1 seconds
commit  39b6ae7
info  For more information on how to debug and view this report, see our readme

Flaky tests

chrome › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
msedge › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod

Skipped tests

chrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
msedge › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

@twschiller twschiller changed the title #9137: [WIP] types and migrations for variable section #9137: [WIP] types and migrations for mod variable declaration section Sep 11, 2024
* @see ModDefinition.variables
* @since 2.1.2
*/
variablesDefinition: ModVariablesDefinition;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the mismatch between mod.variables and variablesDefinition on the formState?

Copy link
Contributor Author

@twschiller twschiller Sep 13, 2024

Choose a reason for hiding this comment

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

Matching the naming conventions for the 2 types:

options?: ModOptionsDefinition;

Mod definition:

export interface UnsavedModDefinition extends Definition {
  kind: typeof DefinitionKinds.MOD;
  extensionPoints: ModComponentDefinition[];
  definitions?: InnerDefinitions;
  options?: ModOptionsDefinition;
  variables?: ModVariablesDefinition;
}

Versus form state:

  /**
   * Information about the mod options or `undefined`
   * if the mod component is not part of a mod.
   * @see ModDefinition.options
   */
  optionsDefinition?: ModOptionsDefinition;
  
    /**
   * The mod variable definitions/declarations
   * @see ModDefinition.variables
   * @since 2.1.2
   */
  variablesDefinition: ModVariablesDefinition;

Personally, I'm indifferent. So if there's preference on where the team wants the naming to go, we should adopt it now to avoid having to write another migration in the future

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should be migrating to a world where the formstate and the mod definition are as similar as possible (ideally a formstate would just be a mutable mod definition?). I would like to have @BLoe to weigh in though since he's spent the most time dealing with the form states in the Page Editor

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, I'd prefer to use the Definitions and Values suffixes everywhere possible to differentiate between the definitions and current values. I don't really care if we do that here/now or a DX change later that updates these all at once to add the suffix.

Copy link
Contributor Author

@twschiller twschiller Sep 16, 2024

Choose a reason for hiding this comment

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

In general, I'd prefer to use the Definitions and Values suffixes everywhere possible to differentiate between the definitions and current values

In ModDefinition, everything is definition. So using suffix on sub-properties would be redundant. Therefore, I wouldn't use the suffix there:

export interface UnsavedModDefinition extends Definition {
  kind: typeof DefinitionKinds.MOD;
  extensionPoints: ModComponentDefinition[];
  definitions?: InnerDefinitions;
  options?: ModOptionsDefinition;
  variables?: ModVariablesDefinition;
}

I've updated the change in ModComponent clarify that it's the definition and not the variables themselves

Copy link

codecov bot commented Sep 14, 2024

Codecov Report

Attention: Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.78%. Comparing base (8318d74) to head (39b6ae7).
Report is 306 commits behind head on main.

Files with missing lines Patch % Lines
src/store/editorMigrations.ts 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9138      +/-   ##
==========================================
+ Coverage   74.24%   74.78%   +0.53%     
==========================================
  Files        1332     1360      +28     
  Lines       40817    41925    +1108     
  Branches     7634     7829     +195     
==========================================
+ Hits        30306    31354    +1048     
- Misses      10511    10571      +60     

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

@twschiller twschiller changed the title #9137: [WIP] types and migrations for mod variable declaration section #9137: types and migrations for mod variable declaration section Sep 14, 2024
@twschiller twschiller marked this pull request as ready for review September 14, 2024 19:17
@twschiller
Copy link
Contributor Author

twschiller commented Sep 14, 2024

@BLoe @grahamlangford this PR is ready for review

@@ -22,8 +22,7 @@ import { type IntegrationDependency } from "@/integrations/integrationTypes";
import { PIXIEBRIX_INTEGRATION_ID } from "@/integrations/constants";

/**
* Infer options from existing mod-component-like instances for reinstalling a mod
* @see installRecipe
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Broken reference

@twschiller twschiller removed this from the 2.1.2 milestone Sep 17, 2024
@twschiller twschiller added this to the 2.1.3 milestone Sep 18, 2024
@twschiller twschiller changed the title #9137: types and migrations for mod variable declaration section #9137: types and migrations for mod variable declaration section (1/3) Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slice 1: Add ActivatedModComponent.variables and ModDefinition.variables sections and write state migrations
3 participants