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

#9131: Slice 3 - deactivate all team mods not in a deployment #9148

Merged

Conversation

grahamlangford
Copy link
Collaborator

@grahamlangford grahamlangford commented Sep 12, 2024

What does this PR do?

Demo

Future Work

  • Refactor syncDeployments to reduce complexity
  • Rename organizations -> teams
  • use the me transformer in backgroundApi

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

Copy link

github-actions bot commented Sep 12, 2024

Playwright test results

passed  126 passed
flaky  2 flaky
skipped  4 skipped

Details

report  Open report ↗︎
stats  132 tests across 44 suites
duration  41 minutes, 29 seconds
commit  290c823
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

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 67.67677% with 32 lines in your changes missing coverage. Please review.

Project coverage is 74.77%. Comparing base (8318d74) to head (290c823).
Report is 291 commits behind head on main.

Files with missing lines Patch % Lines
src/background/teamTrialUpdater.ts 0.00% 26 Missing ⚠️
src/data/service/backgroundApi.ts 28.57% 5 Missing ⚠️
src/background/background.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9148      +/-   ##
==========================================
+ Coverage   74.24%   74.77%   +0.53%     
==========================================
  Files        1332     1360      +28     
  Lines       40817    41842    +1025     
  Branches     7634     7807     +173     
==========================================
+ Hits        30306    31289     +983     
- Misses      10511    10553      +42     

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

@twschiller twschiller added the enhancement New feature or request label Sep 13, 2024
reloadMode: "queue" | "immediate";
};

async function saveModComponentStateAndReloadTabs(
Copy link
Collaborator Author

@grahamlangford grahamlangford Sep 13, 2024

Choose a reason for hiding this comment

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

extracted to src/background/utils/saveModComponentStateAndReloadTabs

}
}

function deactivateModComponentFromStates(
Copy link
Collaborator Author

@grahamlangford grahamlangford Sep 13, 2024

Choose a reason for hiding this comment

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

Duplicate versions in deploymentUpdater and modUpdater and also needed for teamTrialUpdater

extracted to src/background/utils/deactivateModComponent

return { options, editor };
}

async function deactivateModComponentsAndSaveState(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

extracted to src/background/utils/deactivateModComponentAndSaveState

@@ -256,35 +173,6 @@ async function deactivateUnassignedDeployments(
});
}

async function deactivateMod(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Duplicate versions in deploymentUpdater and modUpdater and also needed for teamTrialUpdater

extracted to src/background/utils/deactivateMod

@@ -230,85 +230,49 @@ describe("fetchModUpdates function", () => {
});
});

describe("deactivateMod function", () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Original tests moved to src/background/utils/deactivateMod.test.ts

activatedModComponentFactory({
_recipe: anotherMod,
}),
],
});
});

it("should remove the mod components from the options state", async () => {
it("should uninstall the context menus", async () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously handled by modUpdater's deactivateMod. Uninstalling the context menus was the only difference from the version in deploymentUpdater, so I pulled that functionality up to updateMod

* @param reduxState the current state of the modComponent and editor redux stores
* @returns the new redux state with the mod component deactivated
*/
function deactivateModComponent(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

* @returns new redux state with the mod components deactivated
* and the mod components that were deactivated
*/
export function deactivateMod(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// will see duplicate menu items because the old/new mod components have different UUIDs.
// `updateMods` calls `queueReloadModEveryTab`. Therefore, if the user clicks on a tab where the new version of the
// mod component is not loaded yet, they'll get a notification to reload the page.
void uninstallContextMenu({ modComponentId: activatedModComponent.id });
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This functionality moved to updateMod

Comment on lines +88 to +90
const UPDATE_INTERVAL_MS = 5 * 60 * 1000;

function initTeamTrialUpdater(): void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed with @johnnymetz that it's safe to call /api/organizations as often as we want. Set to 5 minute interval to be similar to the heartbeat, but can be anything

export const getOrganizations = memoizeUntilSettled(
async (): Promise<Array<components["schemas"]["Organization"]>> => {
expectContext("background");
const client = await getApiClient();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't have to be in this PR, but eventually I can see us extracting the getApiClient logic

activatedModComponents: ActivatedModComponent[],
organizationsWithTrials: Array<components["schemas"]["Organization"]>,
) {
const teamScopes = organizationsWithTrials.map((x) => x.scope);
Copy link
Collaborator

@mnholtz mnholtz Sep 13, 2024

Choose a reason for hiding this comment

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

nit: We should probably be consistent with terminology for teams/organizations, i.e. organizationScopes instead

@twschiller twschiller added this to the 2.1.2 milestone Sep 13, 2024
) {
const teamScopes = teamsWithTrials.map((x) => x.scope);
return activatedModComponents.filter((x) => {
if (x._deployment != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I might add a comment or a doc comment explaining the business use-case behind only deactivated non-deployed team mods

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.

@grahamlangford grahamlangford merged commit 7fe07ed into main Sep 16, 2024
26 checks passed
@grahamlangford grahamlangford deleted the 9131-slice-3-deactivate-all-team-mods-not-in-a-deployment branch September 16, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slice 3: Deactivate all team mods NOT in a deployment
4 participants