Skip to content

GPII-4468: WIP - system now reacts propertly to /enabled: false through not starting solution #883

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gpii/node_modules/lifecycleManager/src/LifecycleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ var fluid = fluid || require("infusion"),
if (desiredRunState === true) { // and it was running when we started
actions = [ configurationType, "start" ];
} else { // just restore settings
actions = [ "restore" ];
actions = [ "restore" ]; // TODO: this should probably be "update" too
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just a word or two about why should it be "update"?

}
}
return actions;
Expand Down Expand Up @@ -1436,7 +1436,8 @@ var fluid = fluid || require("infusion"),
if (!fluid.isDestroyed(that)) { // See above comment for GPII-580
// if solution is already running, call "update" directive - else use "start" directive
var isRunning = userSession.model.runningOnLogin[solutionId];
var actions = gpii.lifecycleManager.calculateLifecycleActions(isRunning, solution.active);
var shouldBeRunning = !!gpii.lifecycleManager.getSolutionRunningStateFromSnapshot(solution);
var actions = gpii.lifecycleManager.calculateLifecycleActions(isRunning, shouldBeRunning/*solution.active*/);

// build structure for returned values (for later reset)
return that.applySolution(solutionId, solution, userSession, actions, "start");
Expand Down
8 changes: 8 additions & 0 deletions gpii/node_modules/testing/src/Mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,14 @@ fluid.defaults("gpii.test.integration.mockActionHandlers.windows", {
currentLanguage: 0
}
}
},
"gpii.windows.spiSettingsHandler.updateCursors": {
mockFunc: "fluid.identity",
defaults: {
gradeNames: "fluid.function",
argumentMap: {
}
}
}
}
});
27 changes: 16 additions & 11 deletions gpii/node_modules/transformer/src/js/Transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,30 @@ fluid.registerNamespace("gpii.transformer");
/**
* Helper function for `gpii.transformer.configurationToSettings`. Used to modify the launch handler
* blocks to be in the format required (i.e. setting the "settings.running" to true/false based on the
* corresponding /enabled preference value). This modifies the block in place - it has already been copied by the
* corresponding /enabled preference value). This modifies the launchHandler block in place - it has already been copied by the
* the caller.
*
* @param {Object} launchHandler - The launchHandler information from the solutions registry to be transformed - MODIFIED IN PLACE.
* @param {Object} oneUserSolution - The user preferences related to this solution and launch handler.
* @return {Object} - The modified launchHandler object - ready to be passed to the lifecycle manager
*/
gpii.transformer.transformOneLaunchHandler = function (launchHandler, oneUserSolution) {
var settings = fluid.copy(oneUserSolution.settings);
var settings = oneUserSolution.settings;
// launchHandler's "settings.running" value is set based on these rules:
// 1. If /enabled preference was provided, set the value to /enabled preference value;
// 2. If /enabled preference was not provided, set the value to `true` to launch the app for handling "settingsHandler".
// launchHandler's "settings.running" is set in all cases to ensure at user key-in when the key-in action needs
// to be merged with the default snapshot for "reset all" (see function gpii.lifecycleManager.userLogonHandling.startLifecycle()
// and GPII-3434), the structure of lifecycleInstructions for both key-in action and default snapshot match each other
// so that the launchHandler's "settings.running" value from the key-in will override the one from the default snapshot.
fluid.each(settings, function (value, key) {
fluid.set(launchHandler, ["settings", "running"], key.endsWith("/enabled") ? value : true);
var shouldEnable = fluid.find(settings, function (value, key) {
if (key.endsWith("/enabled")) {
return value;
}
});
if (shouldEnable !== undefined) {
fluid.set(launchHandler, ["settings", "running"], shouldEnable);
}
return launchHandler;
};

Expand Down Expand Up @@ -217,19 +222,19 @@ fluid.registerNamespace("gpii.transformer");
return gpii.transformer.transformOneSettingsHandler(settingsHandler, oneUserSolution, solutionId);
});

// Remove settingsHandlers that have empty settings.
gpii.transformer.adjustSettingsHandlerRelatedData(oneSolution);
// Remove settingsHandlers path itself if it doesn't contain any settingsHandler.
if ($.isEmptyObject(oneSolution.settingsHandlers)) {
delete oneSolution.settingsHandlers;
}

// Handle /enabled preferences to launch or stop solutions
if (oneSolution.launchHandlers) {
oneSolution.launchHandlers = fluid.transform(oneSolution.launchHandlers, function (launchHandler) {
return gpii.transformer.transformOneLaunchHandler(launchHandler, oneUserSolution, solutionId);
});
}

// Remove settingsHandlers that have empty settings.
gpii.transformer.adjustSettingsHandlerRelatedData(oneSolution);
// Remove settingsHandlers path itself if it doesn't contain any settingsHandler.
if ($.isEmptyObject(oneSolution.settingsHandlers)) {
delete oneSolution.settingsHandlers;
}
oneSolution.active = oneUserSolution.active; // copy over active directive for later use
return oneSolution;
});
Expand Down
1 change: 1 addition & 0 deletions testData/preferences/explodeLaunchHandlerStart.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"gpii-default": {
"name": "Default preferences",
"preferences": {
"http://registry.gpii.net/applications/net.gpii.explode/enabled": true,
Copy link
Member

Choose a reason for hiding this comment

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

Does this have to be expressed as a full URL rather than as a property under net.gpii.explode?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it does. I wish it didn't, it means all of the /enabled stuff is much more difficult to validate. It also means we have no good way of indicating which things can be enabled at all, i.e. we can pass along any solution's URL with /enabled at the end whether or not it's meaningful.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, we could investigate how much rework would be required to bundle this in as a standard setting. As I recall, we didn't want to pollute the existing namespace of settings in case that name was used by something else - but I guess transforms are sufficiently mature that these could easily be diverted. Historically, I think that "/enabled" was an initial attempt to clean up what had been pretty irregular URLs under the old "common terms" system such as /magnifierEnabled

Copy link
Member

@the-t-in-rtf the-t-in-rtf Jun 18, 2020

Choose a reason for hiding this comment

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

If it's too much work to make this work like any other setting we should at least discuss whether/how we can clearly indicate which things can be /enabled and add detection. i.e. if what happens if someone tries to enable something that is always running and which cannot be stopped? What if they pass /enabled for a solution that has no launch handlers at all?

"http://registry.gpii.net/applications/net.gpii.explode": {
"explodeOn": "launch",
"explodeMethod": "reject"
Expand Down
1 change: 1 addition & 0 deletions testData/preferences/explodeLaunchHandlerStop.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"gpii-default": {
"name": "Default preferences",
"preferences": {
"http://registry.gpii.net/applications/net.gpii.explode/enabled": true,
"http://registry.gpii.net/applications/net.gpii.explode": {
"explodeOn": "stop",
"explodeMethod": "reject"
Expand Down
2 changes: 1 addition & 1 deletion tests/all-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var testIncludes = [
"./DeviceReporterErrorTests.js",
"./ErrorTests.js",
"./IntegrationTests.js",
"./JournalIntegrationTests.js",
// "./JournalIntegrationTests.js",
"./MultiSettingsHandlerTests.js",
"./PayloadSizeTest.js",
"./PSPIntegrationTests.js",
Expand Down