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

#9378: decouple mod options args from form states to apply to all mod components #9379

Merged
merged 6 commits into from
Oct 29, 2024

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Oct 29, 2024

What does this PR do?

Remaining Work

Future Work

  • Eliminate duplication of modMetadata
  • Decouple variablesDefinition from form states
  • Consider if we want to create form states for all mod components in a mod automatically. It's less important if we hoist mod-level data. However, there'd still be a benefit for simplifying Page Editor code (e.g., availability detection, Mod List item components, etc.). The only downside I see is increased use of localStorage because a copy of the whole mod is always stored

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

@twschiller twschiller changed the title #9378: decouple mod options args and form state #9378: decouple mod options args from form states to fix args bugs Oct 29, 2024
@twschiller twschiller added this to the 2.1.6 milestone Oct 29, 2024
@twschiller twschiller added bug Something isn't working page editor labels Oct 29, 2024
@twschiller twschiller changed the title #9378: decouple mod options args from form states to fix args bugs #9378: decouple mod options args from form states to apply to all mod components Oct 29, 2024
Copy link

github-actions bot commented Oct 29, 2024

Playwright test results

passed  140 passed
flaky  6 flaky
skipped  2 skipped

Details

report  Open report ↗︎
stats  148 tests across 48 suites
duration  10 minutes, 16 seconds
commit  d36e25f
info  For more information on how to debug and view this report, see our readme

Flaky tests

msedge-setup › setup/unaffiliated.setup.ts › authenticate with unaffiliated user
msedge › tests/extensionConsole/activation.spec.ts › can activate a mod with built-in integration
chrome › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration
chrome › tests/pageEditor/saveMod.spec.ts › shows error notification when updating a public mod without incrementing the version
chrome › tests/runtime/sidebar/sidebarActivation.spec.ts › does not redirect to non-pixiebrix domain
msedge › tests/telemetry/errors.spec.ts › can report an indexdb error to telemetry service

Skipped tests

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 base branch from main to feature/9355-clear-changes October 29, 2024 12:42
@twschiller twschiller added the do not merge Merging of this PR is blocked by another one label Oct 29, 2024
expect(updatedExistingComponent?.optionsArgs).toEqual(updatedOptionsArgs);
});

test("deleted mod component form states don't have their options args updated", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests are no longer relevant

* @deprecated - Do not use versioned state types directly, exported for testing
* @since 2.1.6
*/
export type EditorStateV10 = Except<
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type changes

@twschiller twschiller self-assigned this Oct 29, 2024
Finish todo

Fix more type errors

[WIP] refactor analysis

Fix types/tests
@twschiller twschiller removed the do not merge Merging of this PR is blocked by another one label Oct 29, 2024
@twschiller twschiller changed the base branch from feature/9355-clear-changes to main October 29, 2024 14:49
@twschiller twschiller marked this pull request as ready for review October 29, 2024 14:50
const ModOptionsDefinitionEditor: React.VFC = () => {
const [activeField, setActiveField] = useState<string | null>(null);
const modId = useSelector(selectActiveModId);
assertNotNullish(modId, "Expected active mod id");

const {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactor to use AsyncStateGate

}

/** @internal */
export function migrateEditorStateV9(
Copy link
Contributor Author

@twschiller twschiller Oct 29, 2024

Choose a reason for hiding this comment

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

@grahamlangford migration code here. Note the use of dirty to decide whether to set the dirty options args

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 8 lines in your changes missing coverage. Please review.

Project coverage is 75.33%. Comparing base (8318d74) to head (d36e25f).
Report is 434 commits behind head on main.

Files with missing lines Patch % Lines
src/pageEditor/starterBricks/quickBar.ts 0.00% 2 Missing ⚠️
...dOptionsDefinitions/ModOptionsDefinitionEditor.tsx 87.50% 2 Missing ⚠️
...or/hooks/useRegisterDraftModInstanceOnAllFrames.ts 75.00% 1 Missing ⚠️
src/pageEditor/starterBricks/contextMenu.ts 50.00% 1 Missing ⚠️
src/pageEditor/starterBricks/dynamicQuickBar.ts 0.00% 1 Missing ⚠️
src/store/editorMigrations.ts 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9379      +/-   ##
==========================================
+ Coverage   74.24%   75.33%   +1.08%     
==========================================
  Files        1332     1374      +42     
  Lines       40817    41884    +1067     
  Branches     7634     7764     +130     
==========================================
+ Hits        30306    31553    +1247     
+ Misses      10511    10331     -180     

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

* Mod-level editor state passed to the runtime/analysis engine
* @since 2.1.6
*/
export type DraftModState = {
Copy link
Contributor Author

@twschiller twschiller Oct 29, 2024

Choose a reason for hiding this comment

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

This DraftModState type will eventually contain the other mod-level information for the draft:

  • Mod Options Definitions
  • Mod Variable Definitions
  • Mod Metadata

Copy link

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.

@twschiller twschiller merged commit af74eea into main Oct 29, 2024
23 checks passed
@twschiller twschiller deleted the feature/mod-args branch October 29, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working page editor
Development

Successfully merging this pull request may close these issues.

Mod Options Args not applied unless mod component has been selected
2 participants