diff options
Diffstat (limited to 'src/shared/settings')
-rw-r--r-- | src/shared/settings/properties.js | 15 | ||||
-rw-r--r-- | src/shared/settings/property-types.js | 6 | ||||
-rw-r--r-- | src/shared/settings/validator.js | 5 | ||||
-rw-r--r-- | src/shared/settings/values.js | 6 |
4 files changed, 22 insertions, 10 deletions
diff --git a/src/shared/settings/properties.js b/src/shared/settings/properties.js new file mode 100644 index 0000000..ff8039b --- /dev/null +++ b/src/shared/settings/properties.js @@ -0,0 +1,15 @@ +const types = { + // TODO describe property types here + // mystr: 'string', + // mynum: 'number', + // mybool: 'boolean', +}; + +const defaults = { + // TODO describe property defaults values + // mystr: 'hello', + // mynum: 123, + // mybool: true, +}; + +export { types, defaults }; diff --git a/src/shared/settings/property-types.js b/src/shared/settings/property-types.js deleted file mode 100644 index bcfa809..0000000 --- a/src/shared/settings/property-types.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - // TODO describe property types here - // mystr: 'string', - // mynum: 'number', - // mybool: 'boolean', -}; diff --git a/src/shared/settings/validator.js b/src/shared/settings/validator.js index 6fadac7..744f63d 100644 --- a/src/shared/settings/validator.js +++ b/src/shared/settings/validator.js @@ -1,5 +1,4 @@ import operations from 'shared/operations'; -import propertyTypes from './property-types'; const VALID_TOP_KEYS = ['keymaps', 'search', 'blacklist', 'properties']; const VALID_OPERATION_VALUES = Object.keys(operations).map((key) => { @@ -51,10 +50,10 @@ const validateSearch = (search) => { const validateProperties = (properties) => { for (let name of Object.keys(properties)) { - if (!propertyTypes[name]) { + if (!properties.types[name]) { throw new Error(`Unknown property name: "${name}"`); } - if (typeof properties[name] !== propertyTypes[name]) { + if (typeof properties[name] !== properties.types[name]) { throw new Error(`Invalid type for property: "${name}"`); } } diff --git a/src/shared/settings/values.js b/src/shared/settings/values.js index 5027ba5..bd03be2 100644 --- a/src/shared/settings/values.js +++ b/src/shared/settings/values.js @@ -1,3 +1,5 @@ +import * as properties from './properties'; + const operationFromFormName = (name) => { let [type, argStr] = name.split('?'); let args = {}; @@ -81,11 +83,13 @@ const formFromValue = (value, allowedOps) => { } } + let formProperties = Object.assign({}, properties.defaults, value.properties); + return { keymaps, search, blacklist: value.blacklist, - properties: value.properties, + properties: formProperties, }; }; |