hippo-fw 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/client/hippo/access/subscription-choice-layer.jsx +170 -0
  3. data/client/hippo/access/subscription-choice-layer/cancel-subscription.jsx +111 -0
  4. data/client/hippo/access/subscription-choice-layer/payment-form.jsx +154 -0
  5. data/client/hippo/access/subscription-choice-layer/subscription-choice.scss +29 -0
  6. data/client/hippo/boot.jsx +1 -1
  7. data/client/hippo/components/asset.jsx +1 -1
  8. data/client/hippo/components/asset.scss +1 -0
  9. data/client/hippo/components/data-table.jsx +36 -38
  10. data/client/hippo/components/date-time.jsx +25 -9
  11. data/client/hippo/components/form/api.js +1 -0
  12. data/client/hippo/components/form/fields.jsx +3 -2
  13. data/client/hippo/components/form/fields/checkbox-wrapper.jsx +1 -1
  14. data/client/hippo/components/form/fields/date-wrapper.jsx +1 -1
  15. data/client/hippo/components/form/fields/email-wrapper.jsx +31 -0
  16. data/client/hippo/components/form/fields/form-field.scss +8 -0
  17. data/client/hippo/components/form/fields/label.jsx +5 -7
  18. data/client/hippo/components/form/fields/select-wrapper.jsx +1 -1
  19. data/client/hippo/components/form/fields/tags-wrapper.jsx +1 -1
  20. data/client/hippo/components/form/fields/text-wrapper.jsx +1 -1
  21. data/client/hippo/components/form/fields/textarea-wrapper.jsx +1 -1
  22. data/client/hippo/components/form/wrapper.jsx +1 -1
  23. data/client/hippo/components/grid.js +1 -0
  24. data/client/hippo/components/master-detail.jsx +1 -1
  25. data/client/hippo/components/network-activity-overlay.jsx +6 -6
  26. data/client/hippo/components/payments/field.jsx +64 -0
  27. data/client/hippo/components/payments/field.scss +18 -0
  28. data/client/hippo/components/popout-window.jsx +1 -1
  29. data/client/hippo/components/query-builder.jsx +1 -1
  30. data/client/hippo/components/query-builder/boolean-picker.jsx +1 -1
  31. data/client/hippo/components/query-builder/clause-filter.jsx +2 -2
  32. data/client/hippo/components/query-builder/clause.jsx +16 -10
  33. data/client/hippo/components/query-builder/date-picker.jsx +1 -1
  34. data/client/hippo/components/query-builder/query-builder.scss +23 -2
  35. data/client/hippo/components/record-finder.jsx +5 -2
  36. data/client/hippo/components/record-finder/query-layer.jsx +1 -1
  37. data/client/hippo/components/save-button.jsx +1 -1
  38. data/client/hippo/components/screen.jsx +1 -1
  39. data/client/hippo/components/text-editor.jsx +82 -40
  40. data/client/hippo/components/text-editor/renderer.jsx +15 -35
  41. data/client/hippo/components/text-editor/renderer.scss +15 -0
  42. data/client/hippo/components/text-editor/text-editor.scss +2 -15
  43. data/client/hippo/components/text-editor/upload-adapter.js +66 -0
  44. data/client/hippo/components/time-zone-select.jsx +1 -1
  45. data/client/hippo/components/tool-tip.jsx +9 -14
  46. data/client/hippo/components/toolbar.jsx +16 -0
  47. data/client/hippo/components/warning-notification.jsx +1 -1
  48. data/client/hippo/extensions/base.js +3 -2
  49. data/client/hippo/extensions/index.js +1 -1
  50. data/client/hippo/lib/action_cable.js +8 -0
  51. data/client/hippo/lib/action_cable/cable.js +47 -0
  52. data/client/hippo/lib/action_cable/connection.js +192 -0
  53. data/client/hippo/lib/action_cable/connection_monitor.js +135 -0
  54. data/client/hippo/lib/action_cable/consumer.js +56 -0
  55. data/client/hippo/lib/action_cable/subscription.js +98 -0
  56. data/client/hippo/lib/action_cable/subscriptions.js +129 -0
  57. data/client/hippo/lib/date-range.js +22 -5
  58. data/client/hippo/lib/lazy-getter.js +31 -0
  59. data/client/hippo/lib/util.js +6 -1
  60. data/client/hippo/models/base.js +8 -3
  61. data/client/hippo/models/config.js +7 -2
  62. data/client/hippo/models/date-type.js +14 -0
  63. data/client/hippo/models/decorators.js +5 -5
  64. data/client/hippo/models/pub_sub.js +1 -1
  65. data/client/hippo/models/query/array-result.js +4 -1
  66. data/client/hippo/models/subscription.js +35 -0
  67. data/client/hippo/models/sync.js +1 -1
  68. data/client/hippo/models/tenant.js +14 -1
  69. data/client/hippo/react/component-not-found.jsx +14 -18
  70. data/client/hippo/screens/async-loading.jsx +46 -0
  71. data/client/hippo/screens/definition.js +2 -1
  72. data/client/hippo/screens/preferences.jsx +57 -0
  73. data/client/hippo/screens/system-settings.jsx +4 -6
  74. data/client/hippo/screens/system-settings/mailer-config.jsx +1 -1
  75. data/client/hippo/screens/system-settings/tenant.jsx +57 -4
  76. data/client/hippo/screens/user-management.jsx +2 -2
  77. data/client/hippo/screens/user-management/edit-form.jsx +1 -1
  78. data/client/hippo/styles/global/fancy-header.scss +2 -1
  79. data/client/hippo/styles/global/mixins.scss +14 -1
  80. data/client/hippo/testing/index.js +7 -0
  81. data/client/hippo/user.js +9 -2
  82. data/client/hippo/workspace/index.jsx +29 -8
  83. data/client/hippo/workspace/menu-group.jsx +1 -1
  84. data/client/hippo/workspace/menu-option.jsx +2 -0
  85. data/client/hippo/workspace/menu.jsx +30 -6
  86. data/client/hippo/workspace/screen.jsx +5 -1
  87. data/client/hippo/workspace/styles.scss +22 -3
  88. data/command-reference-files/initial/Gemfile +1 -1
  89. data/config/routes.rb +6 -0
  90. data/config/screens.rb +9 -17
  91. data/db/migrate/20171129024737_create_subscriptions.rb +12 -0
  92. data/fixtures/vcr_cassettes/Tenant_changes/sends_email_when_tenant_identifier_changes.yml +72 -0
  93. data/fixtures/vcr_cassettes/Tenant_isoloation/disallows_using_a_user_s_token_on_incorrect_domain.yml +141 -0
  94. data/fixtures/vcr_cassettes/Tenant_isoloation/isolates_bar_s_tenant_data_from_foo.yml +141 -0
  95. data/fixtures/vcr_cassettes/Tenant_isoloation/isolates_foo_s_tenant_data_from_bar.yml +141 -0
  96. data/hippo-fw.gemspec +4 -3
  97. data/lib/hippo.rb +1 -0
  98. data/lib/hippo/access/roles/basic_user.rb +1 -0
  99. data/lib/hippo/api/authentication_provider.rb +4 -5
  100. data/lib/hippo/api/handlers/asset.rb +9 -4
  101. data/lib/hippo/api/handlers/subscription.rb +39 -0
  102. data/lib/hippo/api/handlers/user_session.rb +0 -1
  103. data/lib/hippo/api/helper_methods.rb +8 -4
  104. data/lib/hippo/api/request_wrapper.rb +12 -1
  105. data/lib/hippo/command/console.rb +3 -3
  106. data/lib/hippo/concerns/asset_uploader.rb +8 -2
  107. data/lib/hippo/concerns/pub_sub.rb +8 -8
  108. data/lib/hippo/configuration.rb +6 -4
  109. data/lib/hippo/extension.rb +3 -2
  110. data/lib/hippo/model.rb +1 -0
  111. data/lib/hippo/models/subscription.rb +7 -0
  112. data/lib/hippo/payments.rb +129 -0
  113. data/lib/hippo/screen.rb +4 -2
  114. data/lib/hippo/screen/definition.rb +4 -0
  115. data/lib/hippo/spec_helper.rb +4 -4
  116. data/lib/hippo/templates/liquid/precision.rb +9 -0
  117. data/lib/hippo/tenant.rb +4 -5
  118. data/lib/hippo/user.rb +5 -5
  119. data/lib/hippo/version.rb +1 -1
  120. data/lib/hippo/webpack.rb +5 -1
  121. data/package-lock.json +437 -881
  122. data/package.json +19 -5
  123. data/spec/client/components/__snapshots__/query-builder.spec.jsx.snap +34 -1
  124. data/spec/client/components/__snapshots__/record-finder.spec.jsx.snap +1 -0
  125. data/spec/client/models/base.spec.js +7 -0
  126. data/spec/client/models/subscription.spec.js +8 -0
  127. data/spec/client/screens/__snapshots__/preferences.spec.jsx.snap +223 -0
  128. data/spec/client/screens/preferences.spec.jsx +10 -0
  129. data/spec/client/test-models.js +1 -1
  130. data/spec/client/workspace/__snapshots__/menu.spec.jsx.snap +12 -0
  131. data/spec/factories/subscription.rb +6 -0
  132. data/spec/factories/tenant.rb +1 -1
  133. data/spec/factories/user.rb +1 -1
  134. data/spec/server/api/tenant_change_spec.rb +11 -8
  135. data/spec/server/api/tenant_isolation_spec.rb +11 -8
  136. data/spec/server/api/user_sessions_spec.rb +10 -7
  137. data/spec/server/api/user_spec.rb +45 -0
  138. data/spec/server/models/subscription_spec.rb +10 -0
  139. data/spec/server/payment_helpers.rb +13 -0
  140. data/spec/server/print/form_spec.rb +1 -1
  141. data/spec/server/spec_helper.rb +3 -11
  142. data/templates/js/screen-definitions.js +4 -1
  143. data/templates/spec/factories/model.rb +1 -1
  144. data/views/hippo_root_view.erb +5 -5
  145. metadata +84 -25
  146. data/client/hippo/components/grid/config.json +0 -3
  147. data/client/hippo/components/grid/editors.scss +0 -78
  148. data/client/hippo/components/grid/index.js +0 -2
  149. data/client/hippo/components/grid/row-editor.scss +0 -74
  150. data/client/hippo/components/grid/styles.scss +0 -118
  151. data/client/hippo/components/text-editor/display-modes/Button.jsx +0 -20
  152. data/client/hippo/components/text-editor/display-modes/ToggleEdit.jsx +0 -23
  153. data/client/hippo/components/text-editor/display-modes/ToggleInsert.jsx +0 -22
  154. data/client/hippo/components/text-editor/display-modes/ToggleLayout.jsx +0 -22
  155. data/client/hippo/components/text-editor/display-modes/TogglePreview.jsx +0 -22
  156. data/client/hippo/components/text-editor/display-modes/ToggleResize.jsx +0 -22
  157. data/client/hippo/components/text-editor/display-modes/index.css +0 -0
  158. data/client/hippo/components/text-editor/display-modes/index.js +0 -30
  159. data/client/hippo/components/text-editor/image-plugin/Component/Display/index.js +0 -82
  160. data/client/hippo/components/text-editor/image-plugin/Component/Form/index.js +0 -42
  161. data/client/hippo/components/text-editor/image-plugin/Component/index.js +0 -16
  162. data/client/hippo/components/text-editor/image-plugin/Component/index.scss +0 -0
  163. data/client/hippo/components/text-editor/image-plugin/index.js +0 -32
  164. data/client/hippo/components/text-editor/image-plugin/index.scss +0 -25
  165. data/client/hippo/components/toolbar/changes-notification.scss +0 -63
  166. data/client/hippo/components/toolbar/index.js +0 -3
  167. data/client/hippo/components/toolbar/styles.scss +0 -74
@@ -0,0 +1,31 @@
1
+ // credit to https://github.com/jayphelps/core-decorators/blob/master/src/lazy-initialize.js
2
+ export default function lazyGetter(target, key, descriptor) {
3
+ const {
4
+ configurable, enumerable, initializer, value,
5
+ } = descriptor;
6
+
7
+ return {
8
+ configurable,
9
+ enumerable,
10
+
11
+ get() {
12
+ // This happens if someone accesses the
13
+ // property directly on the prototype
14
+ if (this === target) {
15
+ return null;
16
+ }
17
+
18
+ const ret = initializer ? initializer.call(this) : value;
19
+
20
+ Object.defineProperty(this, key, {
21
+ configurable,
22
+ enumerable,
23
+ writable: false,
24
+ value: ret,
25
+ });
26
+
27
+ return ret;
28
+ },
29
+
30
+ };
31
+ }
@@ -1,8 +1,9 @@
1
1
  import logger from 'loglevel';
2
2
  import {
3
3
  trim, isDate, isNaN, isError, isElement, isFunction, isBoolean, isRegExp,
4
- isNumber, isObject, isEmpty, isNil, isString, each,
4
+ isNumber, isObject, isEmpty, isNil, isString, isArray, each,
5
5
  } from 'lodash';
6
+ import { isObservableArray } from 'mobx';
6
7
  import pluralize from 'pluralize';
7
8
  import classnames from 'classnames';
8
9
  import { getColumnProps } from 'react-flexbox-grid';
@@ -104,3 +105,7 @@ export function isBlank(value) {
104
105
  return isNil(value);
105
106
  }
106
107
  }
108
+
109
+ export function isArrayLike(value) {
110
+ return isObservableArray(value) || isArray(value);
111
+ }
@@ -2,13 +2,14 @@ import PropTypes from 'prop-types';
2
2
  import {
3
3
  findModel,
4
4
  } from 'mobx-decorated-models';
5
+ import { readonly } from 'core-decorators';
5
6
  import invariant from 'invariant';
6
7
  import {
7
8
  isEmpty, isNil, find, extend, assign, pick, map, isArray,
8
9
  } from 'lodash';
9
10
 
10
11
  import { action, observable, computed } from 'mobx';
11
-
12
+ import './date-type';
12
13
  import Sync from './sync';
13
14
  import Config from '../config';
14
15
  import { toSentence, humanize } from '../lib/util';
@@ -70,14 +71,18 @@ export class BaseModel {
70
71
  }
71
72
  }
72
73
 
73
- get isModel() { return true; }
74
+ @readonly isModel = true;
74
75
 
75
76
  @observable syncInProgress = false;
76
77
  @observable lastServerMessage = '';
77
78
  @observable errors = {};
78
79
 
79
80
  @computed get errorMessage() {
80
- return this.errors ? toSentence(map(this.errors, (v, k) => `${humanize(k)} ${v}`)) : '';
81
+ return this.errors ? toSentence(
82
+ map(this.errors, (v, k) => (
83
+ 'base' === k ? v : `${humanize(k)} ${v}`
84
+ )),
85
+ ) : '';
81
86
  }
82
87
 
83
88
  @computed get isValid() {
@@ -1,5 +1,5 @@
1
1
  import { observable, observe } from 'mobx';
2
- import { keysIn, pick, assign, get } from 'lodash';
2
+ import { pickBy, assign, get, hasIn, isNil } from 'lodash';
3
3
  import { persist, create as createHydrator } from 'mobx-persist';
4
4
 
5
5
  import Extensions from '../extensions';
@@ -13,13 +13,18 @@ export default class Config {
13
13
  @persist @observable access_token;
14
14
  @persist @observable root_view;
15
15
  @persist @observable assets_path_prefix = '/assets';
16
+ @persist @observable print_path_prefix = '/print';
16
17
  @persist @observable website_domain;
17
18
  @persist @observable product_name;
19
+ @persist @observable support_email;
20
+
18
21
  @persist('list') @observable screen_ids = [];
19
22
  @persist @observable user_info;
20
23
  @persist('object') @observable logo;
21
24
  @observable user;
25
+ @observable environment;
22
26
  @observable isIntialized = false;
27
+ @observable subscription_plans = [];
23
28
 
24
29
  static create(hydrationConfig) {
25
30
  const hydrate = createHydrator(hydrationConfig);
@@ -35,7 +40,7 @@ export default class Config {
35
40
  }
36
41
 
37
42
  update(attrs) {
38
- assign(this, pick(attrs, keysIn(this)));
43
+ assign(this, pickBy(attrs, (v, k) => !isNil(v) && hasIn(this, k)));
39
44
  Extensions.setBootstrapData(attrs);
40
45
  }
41
46
 
@@ -0,0 +1,14 @@
1
+ import { registerCustomType } from 'mobx-decorated-models';
2
+ import moment from 'moment-timezone';
3
+
4
+ registerCustomType('fdate', {
5
+
6
+ serialize(date) {
7
+ return date.toISOString();
8
+ },
9
+
10
+ deserialize(dateLikeThing) {
11
+ return moment(dateLikeThing);
12
+ },
13
+
14
+ });
@@ -1,8 +1,8 @@
1
1
  import {
2
- isEmpty, isArray, isNumber, isObject, isString, partial, defaults, isNil, isDate,
2
+ isEmpty, isArray, isNumber, isObject, isString, partial, defaults, isNil,
3
3
  } from 'lodash';
4
4
  import invariant from 'invariant';
5
-
5
+ import moment from 'moment';
6
6
  import { intercept, isObservableArray, isObservableObject } from 'mobx';
7
7
 
8
8
  import {
@@ -16,13 +16,13 @@ const VALIDATORS = {
16
16
  string: isString,
17
17
  array(a) { return isArray(a) || isObservableArray(a); },
18
18
  object(o) { return isObject(o) || isObservableObject(o); },
19
- date: isDate,
19
+ date(d) { return moment.isMoment(d); },
20
20
  };
21
21
 
22
22
  const COERCE = {
23
23
  date(change) {
24
- if (!isDate(change.newValue)) {
25
- change.newValue = new Date(change.newValue); // eslint-disable-line no-param-reassign
24
+ if (!moment.isMoment(change.newValue)) {
25
+ change.newValue = moment(change.newValue); // eslint-disable-line no-param-reassign
26
26
  }
27
27
  },
28
28
  };
@@ -1,5 +1,5 @@
1
1
  import { Atom, when, reaction } from 'mobx';
2
- import ActionCable from 'actioncable';
2
+ import ActionCable from '../lib/action_cable';
3
3
  import { BaseModel } from './base';
4
4
  import User from '../user';
5
5
  import Config from '../config';
@@ -72,7 +72,10 @@ export default class ArrayResult extends Result {
72
72
  }
73
73
 
74
74
  rowAsObject(index) {
75
- const row = this.rows[index];
75
+ return this.convertRowToObject(this.rows[index]);
76
+ }
77
+
78
+ convertRowToObject(row) {
76
79
  const obj = {};
77
80
  this.query.info.loadableFields.forEach((f) => {
78
81
  const value = row[f.dataIndex] || f.defaultValue;
@@ -0,0 +1,35 @@
1
+ import Big from 'big.js';
2
+ import { map } from 'lodash';
3
+ import Config from '../config';
4
+ import {
5
+ BaseModel, identifiedBy, identifier, field, session, computed,
6
+ } from './base';
7
+
8
+ @identifiedBy('hippo/subscription')
9
+ export default class Subscription extends BaseModel {
10
+
11
+ @computed static get all() {
12
+ return map(Config.subscription_plans, plan => new Subscription(plan));
13
+ }
14
+
15
+ @identifier id;
16
+ @field name;
17
+ @field description;
18
+ @field price;
19
+
20
+ @field nonce;
21
+ @session authorization;
22
+
23
+ @computed get formattedPrice() {
24
+ return Big(this.price).round(2).toFixed(2);
25
+ }
26
+
27
+ @computed get costDescription() {
28
+ return `${this.formattedPrice} per month`;
29
+ }
30
+
31
+ @computed get nameAndCost() {
32
+ return `${this.name} at ${this.costDescription}`;
33
+ }
34
+
35
+ }
@@ -107,7 +107,7 @@ const peformMobxyRequest = action('SyncforModel', (mobxObj, options = {}) => {
107
107
  mobxObj.errors = { network: e };
108
108
  mobxObj.syncInProgress = undefined;
109
109
  mobxObj.lastServerMessage = e.toString();
110
- return {};
110
+ return mobxObj;
111
111
  }));
112
112
  });
113
113
 
@@ -1,8 +1,10 @@
1
1
  import { observable, computed } from 'mobx';
2
- import { first } from 'lodash';
2
+ import { find, first } from 'lodash';
3
3
  import {
4
4
  BaseModel, identifiedBy, field, identifier,
5
5
  } from './base';
6
+ import Extensions from '../extensions';
7
+ import Subscription from './subscription';
6
8
  import Config from '../config';
7
9
 
8
10
  const CACHED = observable.box();
@@ -22,22 +24,33 @@ export default class Tenant extends BaseModel {
22
24
  }
23
25
 
24
26
  static bootstrap(data) {
27
+ Extensions.fireOnInitialized();
25
28
  Tenant.current.update(data);
26
29
  if (data.bootstrap) {
27
30
  Config.update(data.bootstrap);
28
31
  }
32
+ Extensions.fireOnAvailable();
29
33
  }
30
34
 
31
35
  @identifier({ type: 'string' }) identifier = 'current';
32
36
  @field name;
33
37
  @field email;
34
38
  @field slug;
39
+ @field subscription_id;
35
40
 
41
+ @computed get hasSubscription() {
42
+ return Boolean(this.subscription);
43
+ }
36
44
 
37
45
  @computed get domain() {
38
46
  return `${this.slug}.${Config.website_domain}`;
39
47
  }
40
48
 
49
+ @computed get subscription() {
50
+ return this.subscription_id ?
51
+ find(Subscription.all, { id: this.subscription_id }) : null;
52
+ }
53
+
41
54
  set syncData(data) {
42
55
  Tenant.bootstrap(data);
43
56
  }
@@ -1,23 +1,19 @@
1
- import React from 'react';
1
+ import React from 'react'; // eslint-disable-line no-unused-vars
2
2
  import PropTypes from 'prop-types';
3
3
  import { get } from 'lodash';
4
4
  import { classify } from '../lib/util';
5
5
 
6
- export default class ComponentNotFound extends React.PureComponent {
7
-
8
- static propTypes = {
9
- extension: PropTypes.shape({
10
- identifier: PropTypes.string,
11
- }),
12
- }
13
-
14
- render() {
15
- const identifier = get(this.props.extension, 'identifier', 'UnknownExtension');
16
- return (
17
- <div className="fancy-header">
18
- <h1>{classify(identifier)}.rootElement() did not return an element to render!</h1>
19
- </div>
20
- );
21
- }
22
-
6
+ export default function ComponentNotFound(props) {
7
+ const identifier = get(props.extension, 'identifier', 'UnknownExtension');
8
+ return (
9
+ <div className="fancy-header">
10
+ <h1>{classify(identifier)}.rootElement() did not return an element to render!</h1>
11
+ </div>
12
+ );
23
13
  }
14
+
15
+ ComponentNotFound.propTypes = {
16
+ extension: PropTypes.shape({
17
+ identifier: PropTypes.string,
18
+ }),
19
+ };
@@ -0,0 +1,46 @@
1
+ import React from 'react'; // eslint-disable-line no-unused-vars
2
+ import Spinning from 'grommet/components/icons/Spinning';
3
+ import FormRefreshIcon from 'grommet/components/icons/base/FormRefresh';
4
+ import AlertIcon from 'grommet/components/icons/base/Alert';
5
+ import Button from 'grommet/components/Button';
6
+ import { asyncComponent } from 'react-async-component';
7
+ import { observer } from 'mobx-react';
8
+ import cn from 'classnames';
9
+
10
+ const ErrorComponent = observer(({ screen, retry }) => (
11
+ <div
12
+ data-screen-id={screen.definition.id}
13
+ className={cn('hippo-screen', 'async-loading', 'error', { 'is-active': screen.isActive })}
14
+ >
15
+ <div className="content">
16
+ <h4><AlertIcon /> Failed to load {screen.definition.title}…</h4>
17
+ <Button
18
+ icon={<FormRefreshIcon />}
19
+ onClick={retry}
20
+ label="Retry"
21
+ />
22
+ </div>
23
+ </div>
24
+ ));
25
+
26
+
27
+ const LoadingComponent = observer(({ screen }) => (
28
+ <div
29
+ data-screen-id={screen.definition.id}
30
+ className={cn('hippo-screen', 'async-loading', 'is-loading', { 'is-active': screen.isActive })}
31
+ >
32
+ <div className="content">
33
+ <h4><Spinning /> Loading {screen.definition.title}…</h4>
34
+ </div>
35
+ </div>
36
+ ));
37
+
38
+
39
+ export default function asyncLoading({ screen, resolve }) {
40
+ return asyncComponent({
41
+ ErrorComponent,
42
+ LoadingComponent,
43
+ resolve,
44
+ screen,
45
+ });
46
+ }
@@ -8,7 +8,8 @@ import Instance, { displaying } from './instance';
8
8
  import Registry from './index';
9
9
  import Group from './group';
10
10
 
11
- export { asyncComponent } from 'react-async-component';
11
+ export asyncComponent from './async-loading';
12
+
12
13
 
13
14
  @identifiedBy('hippo/screen/definition')
14
15
  export default class ScreenDefinition extends BaseModel {
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { observer } from 'mobx-react';
4
+ import { action } from 'mobx';
5
+ import { Row } from 'react-flexbox-grid';
6
+ import Screen from '../components/screen';
7
+ import { Toolbar, SaveButton } from '../components/toolbar';
8
+ import {
9
+ Form, Field, FormState, nonBlank, validEmail,
10
+ } from '../components/form';
11
+ import User from '../user';
12
+
13
+ @observer
14
+ export default class Preferences extends React.PureComponent {
15
+
16
+ static propTypes = {
17
+ screen: PropTypes.instanceOf(Screen.Instance).isRequired,
18
+ }
19
+
20
+ formState = new FormState()
21
+
22
+ componentWillMount() {
23
+ User.fetch();
24
+ this.formState.setFromModel(User);
25
+ }
26
+
27
+ @action.bound onSave() {
28
+ if (this.formState.isValid) {
29
+ this.formState.persistTo(User)
30
+ .then(() => User.save())
31
+ .then(() => this.formState.setFromModel(User));
32
+ } else {
33
+ this.formState.exposeErrors();
34
+ }
35
+ }
36
+
37
+ render() {
38
+ return (
39
+ <Form screen={this.props.screen} state={this.formState}>
40
+ <Toolbar>
41
+ <SaveButton
42
+ model={User}
43
+ onClick={this.onSave}
44
+ />
45
+ </Toolbar>
46
+ <h4>Account information:</h4>
47
+ <Row>
48
+ <Field xs={6} name="login" validate={nonBlank} />
49
+ <Field xs={6} name="name" validate={nonBlank} />
50
+ <Field sm={6} xs={12} name="email" validate={validEmail} />
51
+ <Field sm={6} xs={12} name="password" type="password" />
52
+ </Row>
53
+ </Form>
54
+ );
55
+ }
56
+
57
+ }
@@ -5,13 +5,11 @@ import { observer } from 'mobx-react';
5
5
  import { map, compact, invoke } from 'lodash';
6
6
  import { Row, Col } from 'react-flexbox-grid';
7
7
  import Heading from 'grommet/components/Heading';
8
- import Header from 'grommet/components/Header';
9
-
10
8
  import Screen from '../components/screen';
11
9
  import Asset from '../components/asset';
12
10
  import Settings from '../models/system-setting';
13
11
  import Warning from '../components/warning-notification';
14
- import SaveButton from '../components/save-button';
12
+ import { Toolbar, SaveButton } from '../components/toolbar';
15
13
  import ScreenInstance from '../screens/instance';
16
14
  import Extensions from '../extensions';
17
15
  import MailerConfig from './system-settings/mailer-config';
@@ -20,7 +18,7 @@ import TenantSettings from './system-settings/tenant';
20
18
  import './system-settings/system-settings.scss';
21
19
 
22
20
  @observer
23
- export default class SystemSettings extends React.PureComponent {
21
+ export default class SystemSettings extends React.Component {
24
22
 
25
23
  @observable settings = new Settings();
26
24
  extensionPanelRefs = new Map();
@@ -79,12 +77,12 @@ export default class SystemSettings extends React.PureComponent {
79
77
  render() {
80
78
  return (
81
79
  <Screen {...this.props}>
82
- <Header fixed>
80
+ <Toolbar>
83
81
  <SaveButton
84
82
  model={this.settings}
85
83
  onClick={this.onSave}
86
84
  />
87
- </Header>
85
+ </Toolbar>
88
86
  <Heading>{this.props.screen.definition.title}</Heading>
89
87
  <Warning message={this.settings.errorMessage} />
90
88
  <TenantSettings ref={this.setTenantRef} />