-
Notifications
You must be signed in to change notification settings - Fork 63
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
Gpii 4207 Updates to default values and some settings that were missing #824
Open
sgithens
wants to merge
9
commits into
GPII:master
Choose a base branch
from
sgithens:GPII-4207
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e5ecc13
GPII-4207 Adding some JAWS settings from the Basic Settings Dialog
sgithens de1a98a
GPII-4207 Default Settings Investigation
sgithens 2835aab
GPII-4207 Adding utility function and tests for finding the default v…
sgithens f1ac07a
GPII-4207 Adding type information back in to `findDefaultValue`
sgithens 556a578
GPII-4207 Updating mousekeys acceleration to be an integer type.
sgithens b0416bd
GPII-4207 Disambiguating win32 desktop personalization names
sgithens 37687db
GPII-4207 Removing some debug/investigating comments.
sgithens fa7d3f3
Merge remote-tracking branch 'GPII/master' into GPII-4207
sgithens 3b26e2d
GPII-4207 Cleaning up property access with fluid.get
sgithens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
gpii/node_modules/solutionsRegistry/src/js/SolutionsUtils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* GPII Solutions Utils - Independent helper functions and utilities for working with | ||
* solutions and their schemas. | ||
* | ||
* Copyright 2019 Raising the Floor - US | ||
* | ||
* Licensed under the New BSD license. You may not use this file except in | ||
* compliance with this License. | ||
* | ||
* The research leading to these results has received funding from the European Union's | ||
* Seventh Framework Programme (FP7/2007-2013) | ||
* under grant agreement no. 289016. | ||
* | ||
* You may obtain a copy of the License at | ||
* https://github.com/GPII/universal/blob/master/LICENSE.txt | ||
*/ | ||
"use strict"; | ||
var fluid = require("infusion"); | ||
var gpii = fluid.registerNamespace("gpii"); | ||
|
||
fluid.registerNamespace("gpii.universal.solutionsRegistry"); | ||
|
||
/** | ||
* This function will take a schema from a supported setting in the solutions | ||
* registry and return metadata on it's default value, including the type of | ||
* the default value. The function will always return a block of json in order | ||
* to avoid any ambiguities for a situation where the default value is perhaps | ||
* `null`. A key `hasDefault` will be `true` or `false` to communicate this. | ||
* If the schema does have a default value, then the properties `type` and | ||
* `default` can also be included. Note that there may not always be a `type` | ||
* that can be included, the inclusion of this in the return if optional and | ||
* will be included if a `type` is declared. | ||
* | ||
* This is NOT meant to be an exhaustive coverage of all the possible ways | ||
* default values can be set for any JSON Schema. We merely want to cover the | ||
* cases in use in the solutions registry, focussing on single primitive values, | ||
* and situations where we next one level deep due to a requirement of having a | ||
* `properties` entry in the schema. | ||
* | ||
* @param {Object} schema - Schema to search for a default value. This is what | ||
* would be in the solutions registry under `supportedSettings` and a | ||
* configuration. An example from the Windows Mouse Keys MaxSpeed setting is: | ||
* ```json | ||
* { | ||
* "title": "Mouse keys speed", | ||
* "description": "Speed of mouse keys", | ||
* "type": "number", | ||
* "multipleOf": 10, | ||
* "default": 80 | ||
* } | ||
* ``` | ||
* @return {Object} Always returns a json block. For the example above the | ||
* return value would be: | ||
* ```json | ||
* { | ||
* "hasDefault": true, | ||
* "type": "number", | ||
* "default": 80 | ||
* } | ||
* ``` | ||
* If a default value cannot be detected the return payload will be: | ||
* ```json | ||
* { | ||
* "hasDefault": false | ||
* } | ||
* ``` | ||
*/ | ||
gpii.universal.solutionsRegistry.findDefaultValue = function (schema) { | ||
var togo; | ||
|
||
// 1. The most simple, and hopefull case is that there is a top level | ||
// default value. | ||
if (schema["default"] !== undefined) { | ||
togo = { | ||
hasDefault: true, | ||
default: schema["default"] | ||
}; | ||
if (schema.type) { | ||
togo.type = schema.type; | ||
} | ||
} | ||
// 2. Sometimes we have a properties structure that can be interogated, example: | ||
// "properties": { | ||
// "path": { "type": "string"}, | ||
// "value": { | ||
// "type": "string", | ||
// "default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
// } | ||
// } | ||
else if (schema.properties && schema.properties.value && schema.properties.value["default"] !== undefined) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a great place to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, updated to use fluid.get |
||
togo = { | ||
hasDefault: true, | ||
default: schema.properties.value["default"] | ||
}; | ||
if (schema.properties.value.type) { | ||
togo.type = schema.properties.value.type; | ||
} | ||
} | ||
// We cannot find a default value for our simplified usage of json schema... | ||
else { | ||
togo = { | ||
hasDefault: false | ||
}; | ||
} | ||
|
||
return togo; | ||
}; |
153 changes: 153 additions & 0 deletions
153
gpii/node_modules/solutionsRegistry/test/SolutionsUtilsTests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Tests for GPII Solutions Utils | ||
* | ||
* Copyright 2019 Raising the Floor - US | ||
* | ||
* Licensed under the New BSD license. You may not use this file except in | ||
* compliance with this License. | ||
* | ||
* The research leading to these results has received funding from the European Union's | ||
* Seventh Framework Programme (FP7/2007-2013) | ||
* under grant agreement no. 289016. | ||
* | ||
* You may obtain a copy of the License at | ||
* https://github.com/GPII/universal/blob/master/LICENSE.txt | ||
*/ | ||
|
||
"use strict"; | ||
var fluid = require("infusion"); | ||
var gpii = fluid.registerNamespace("gpii"); | ||
var jqUnit = require("node-jqunit"); | ||
|
||
require("../src/js/SolutionsUtils"); | ||
|
||
jqUnit.module("Tests for Solutions Registry Utility functions."); | ||
|
||
fluid.registerNamespace("gpii.tests.universal.solutionsRegistry.solutionsUtils"); | ||
|
||
gpii.tests.universal.solutionsRegistry.solutionsUtils.defaultValueTests = [ | ||
{ | ||
schema: { | ||
"title": "Attribute Rotation Delay", | ||
"description": "When in Attribute...", | ||
"type": "integer", | ||
"default": 1000 | ||
}, | ||
result: { | ||
hasDefault: true, | ||
type: "integer", | ||
default: 1000 | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Attribute Rotation Delay", | ||
"description": "When in Attribute...", | ||
"default": 1000 | ||
}, | ||
result: { | ||
hasDefault: true, | ||
default: 1000 | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Attribute Rotation Delay With No Default...", | ||
"description": "When in Attribute...", | ||
"type": "integer" | ||
}, | ||
result: { | ||
hasDefault: false | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Desktop background wallpaper", | ||
"description": "The path to the image to be set as the new desktop wallpaper.", | ||
"properties": { | ||
"path": { "type": "string"}, | ||
"value": { | ||
"type": "string", | ||
"default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
} | ||
} | ||
}, | ||
result: { | ||
hasDefault: true, | ||
type: "string", | ||
default: "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Desktop background wallpaper", | ||
"description": "The path to the image to be set as the new desktop wallpaper.", | ||
"properties": { | ||
"path": { "type": "string"}, | ||
"value": { | ||
"default": "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
} | ||
} | ||
}, | ||
result: { | ||
hasDefault: true, | ||
default: "%SystemRoot%\\Web\\Wallpaper\\Windows\\img0.jpg" | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Desktop background wallpaper", | ||
"description": "The path to the image to be set as the new desktop wallpaper.", | ||
"properties": { | ||
"path": { "type": "string", "required": true}, | ||
"value": { | ||
"type": "string", | ||
"required": true, | ||
"default": "" | ||
} | ||
} | ||
}, | ||
result: { | ||
hasDefault: true, | ||
type: "string", | ||
default: "" | ||
} | ||
}, | ||
{ | ||
schema: { | ||
"title": "Screen mirroring", | ||
"description": "Mirrors the primary screen into a secondary screen.", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
result: { | ||
hasDefault: true, | ||
type: "boolean", | ||
default: false | ||
} | ||
} | ||
]; | ||
|
||
gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTest = function (schema, expectedResult) { | ||
var result = gpii.universal.solutionsRegistry.findDefaultValue(schema); | ||
jqUnit.assertDeepEq("Checking default value for: " + schema.title, expectedResult, result); | ||
}; | ||
|
||
gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTests = function () { | ||
jqUnit.test("Testing my empty stubs...", function () { | ||
fluid.each(gpii.tests.universal.solutionsRegistry.solutionsUtils.defaultValueTests, function (item) { | ||
gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTest(item.schema, item.result); | ||
}); | ||
}); | ||
}; | ||
|
||
fluid.defaults("gpii.tests.universal.solutionsRegistry.solutionsUtils", { | ||
gradeNames: ["fluid.component"], | ||
listeners: { | ||
"onCreate.findDefaultValueTest": { | ||
funcName: "gpii.tests.universal.solutionsRegistry.solutionsUtils.findDefaultValueTests" | ||
} | ||
} | ||
}); | ||
|
||
gpii.tests.universal.solutionsRegistry.solutionsUtils(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's helpful, but it is not used by anything in the codebase - does it belong in the capture tool instead?
Also note that the one place where we do fetch setting defaults, we do not use this approach - https://github.com/GPII/universal/blob/master/gpii/node_modules/flowManager/src/PSPChannel.js#L139 - instead, we read the value from build/schemas/solution-schema-codex.json . What do you think, @cindyli , @the-t-in-rtf ?
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.
I was confused as to where and why you'd use this, but then I looked at some of the deeper structures like the SPI settings here:
universal/testData/solutions/win32.json5
Line 6324 in 76ad0e6
I guess my questions are, what do you expect to do with this potential "deep default" and why do you preserve the "type" but not anything else? If you're putting up controls or anything else, you don't have enough information to create controls. You don't know the range any longer, you don't know if the field is required, et cetera. If you're getting that info somewhere else, why not get the type from there as well?
Also, your code is focused on the
value
property, there are others, like this object that has RGB properties. How do you plan to handle those?It seems to me like you need proper handling for nested properties, and this type of recursion should be possible in both javascript and handlebars templates. But maybe I just don't get what you're doing, and an example of what you're feeding into this and where you use it would help. Apologies if you've already covered that in the longer conversation.
I also am not sure this belongs in this particular part of the Solutions Registry. The use case would help confirm, but if it's truly about UI generation, it seems like this would be an early utility that would make up part of the "presentation registry" instead.
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.
@amb26 Well, it's first use is the capture tool (and I've already temporarily duplicated it there), but it will all need to be used in the PPT, Morphic Vaults and other user facing applications build on top of universal. Quite a number of our UX specs at some point highlight what the default value of a particular setting is.
Also, regardless of the input, whether it's from win32.json or from solution-schema-codex.json, I believe we have the same problems. (and this impl I believe should still work if you pass in the corresponding property/schema either way. Here is a section from my locally generated
solution-schema-codex.json
:Here, you can see that the
default
is at the top level forBounceKeysInterval
, and then forSlowKeysInterval
you need to drill down a level to get the default value.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.
@the-t-in-rtf An example of what I'm doing with the
default
value (regardless of whether it's in the top level of the items schema, or further down), is here in the capture tool where you can filter values on and off, depending if they match the default:In the PPT, on the tables that show settings for each solution there is a column for the default.
Current I'm just preserving
type
because it's the amount of information I need to build these UI's (maybe not a great answer, but the truth). I just need the default, and it's type so I can compare them. I've haven't yet dealt with RGB values or anything, as the comments on the method allude to, I'm trying to knock out the largest number of settings at the moment that show up on these UI's with the simplest solution so far.I'm ok with it being anywhere in universal, but it would be nice to have it in at least one of our most central repos... at the moment every one of our user facing projects still includes universal. Also, I can imagine a time soon where this default value information would be needed to create some time of data feed endpoint in universal.
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.
I still don't understand why you can't just use the schema in its entirety. We should discuss in the meeting today.