aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/settings/components/index.jsx4
-rw-r--r--src/shared/settings/properties.js15
-rw-r--r--src/shared/settings/property-types.js6
-rw-r--r--src/shared/settings/validator.js5
-rw-r--r--src/shared/settings/values.js6
5 files changed, 24 insertions, 12 deletions
diff --git a/src/settings/components/index.jsx b/src/settings/components/index.jsx
index c41aa6b..d7696a1 100644
--- a/src/settings/components/index.jsx
+++ b/src/settings/components/index.jsx
@@ -5,7 +5,7 @@ import SearchForm from './form/search-form';
import KeymapsForm from './form/keymaps-form';
import BlacklistForm from './form/blacklist-form';
import PropertiesForm from './form/properties-form';
-import PropertyTypes from 'shared/settings/property-types';
+import * as properties from 'shared/settings/properties';
import * as settingActions from 'settings/actions/setting';
import * as validator from 'shared/settings/validator';
import * as settingsValues from 'shared/settings/values';
@@ -70,7 +70,7 @@ class SettingsComponent extends Component {
<fieldset>
<legend>Properties</legend>
<PropertiesForm
- types={PropertyTypes}
+ types={properties.types}
value={this.state.settings.form.properties}
onChange={value => this.bindForm('properties', value)}
/>
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,
};
};