-
Notifications
You must be signed in to change notification settings - Fork 22
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
#9131: Slice 3 - deactivate all team mods not in a deployment #9148
Conversation
Playwright test resultsDetails Open report ↗︎ Flaky testschrome › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod Skipped testschrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor |
Codecov ReportAttention: Patch coverage is
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. |
reloadMode: "queue" | "immediate"; | ||
}; | ||
|
||
async function saveModComponentStateAndReloadTabs( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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
const UPDATE_INTERVAL_MS = 5 * 60 * 1000; | ||
|
||
function initTeamTrialUpdater(): void { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
src/background/teamTrialUpdater.ts
Outdated
activatedModComponents: ActivatedModComponent[], | ||
organizationsWithTrials: Array<components["schemas"]["Organization"]>, | ||
) { | ||
const teamScopes = organizationsWithTrials.map((x) => x.scope); |
There was a problem hiding this comment.
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
…create-organization-data-model
…9131-slice-3-deactivate-all-team-mods-not-in-a-deployment
…/pixiebrix-extension into 9131-slice-3-deactivate-all-team-mods-not-in-a-deployment
…9131-slice-3-deactivate-all-team-mods-not-in-a-deployment
) { | ||
const teamScopes = teamsWithTrials.map((x) => x.scope); | ||
return activatedModComponents.filter((x) => { | ||
if (x._deployment != null) { |
There was a problem hiding this comment.
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
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. |
What does this PR do?
Demo
Future Work
syncDeployments
to reduce complexityFor more information on our expectations for the PR process, see the
code review principles doc