diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
commit | 58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch) | |
tree | 1211600c2a5d3b5f81c435c6896618111a611720 /src/actions | |
download | ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip |
initial commit
Diffstat (limited to 'src/actions')
-rw-r--r-- | src/actions/app.js | 23 | ||||
-rw-r--r-- | src/actions/index.js | 28 | ||||
-rw-r--r-- | src/actions/lib/actions.js | 18 | ||||
-rw-r--r-- | src/actions/news.js | 7 | ||||
-rw-r--r-- | src/actions/payment.js | 8 | ||||
-rw-r--r-- | src/actions/recipe.js | 9 | ||||
-rw-r--r-- | src/actions/recipePreview.js | 7 | ||||
-rw-r--r-- | src/actions/requests.js | 3 | ||||
-rw-r--r-- | src/actions/service.js | 75 | ||||
-rw-r--r-- | src/actions/settings.js | 10 | ||||
-rw-r--r-- | src/actions/ui.js | 11 | ||||
-rw-r--r-- | src/actions/user.js | 30 |
12 files changed, 229 insertions, 0 deletions
diff --git a/src/actions/app.js b/src/actions/app.js new file mode 100644 index 000000000..5db4b739e --- /dev/null +++ b/src/actions/app.js | |||
@@ -0,0 +1,23 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | setBadge: { | ||
5 | unreadDirectMessageCount: PropTypes.number.isRequired, | ||
6 | unreadIndirectMessageCount: PropTypes.number, | ||
7 | }, | ||
8 | notify: { | ||
9 | title: PropTypes.string.isRequired, | ||
10 | options: PropTypes.object.isRequired, | ||
11 | serviceId: PropTypes.string, | ||
12 | }, | ||
13 | launchOnStartup: { | ||
14 | enable: PropTypes.bool.isRequired, | ||
15 | }, | ||
16 | openExternalUrl: { | ||
17 | url: PropTypes.string.isRequired, | ||
18 | }, | ||
19 | checkForUpdates: {}, | ||
20 | resetUpdateStatus: {}, | ||
21 | installUpdate: {}, | ||
22 | healthCheck: {}, | ||
23 | }; | ||
diff --git a/src/actions/index.js b/src/actions/index.js new file mode 100644 index 000000000..59acabb0b --- /dev/null +++ b/src/actions/index.js | |||
@@ -0,0 +1,28 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | import defineActions from './lib/actions'; | ||
4 | import service from './service'; | ||
5 | import recipe from './recipe'; | ||
6 | import recipePreview from './recipePreview'; | ||
7 | import ui from './ui'; | ||
8 | import app from './app'; | ||
9 | import user from './user'; | ||
10 | import payment from './payment'; | ||
11 | import news from './news'; | ||
12 | import settings from './settings'; | ||
13 | import requests from './requests'; | ||
14 | |||
15 | const actions = Object.assign({}, { | ||
16 | service, | ||
17 | recipe, | ||
18 | recipePreview, | ||
19 | ui, | ||
20 | app, | ||
21 | user, | ||
22 | payment, | ||
23 | news, | ||
24 | settings, | ||
25 | requests, | ||
26 | }); | ||
27 | |||
28 | export default defineActions(actions, PropTypes.checkPropTypes); | ||
diff --git a/src/actions/lib/actions.js b/src/actions/lib/actions.js new file mode 100644 index 000000000..499018d70 --- /dev/null +++ b/src/actions/lib/actions.js | |||
@@ -0,0 +1,18 @@ | |||
1 | export default (definitions, validate) => { | ||
2 | const newActions = {}; | ||
3 | Object.keys(definitions).forEach((scopeName) => { | ||
4 | newActions[scopeName] = {}; | ||
5 | Object.keys(definitions[scopeName]).forEach((actionName) => { | ||
6 | const action = (params) => { | ||
7 | const schema = definitions[scopeName][actionName]; | ||
8 | validate(schema, params, actionName); | ||
9 | action.notify(params); | ||
10 | }; | ||
11 | newActions[scopeName][actionName] = action; | ||
12 | action.listeners = []; | ||
13 | action.listen = listener => action.listeners.push(listener); | ||
14 | action.notify = params => action.listeners.forEach(listener => listener(params)); | ||
15 | }); | ||
16 | }); | ||
17 | return newActions; | ||
18 | }; | ||
diff --git a/src/actions/news.js b/src/actions/news.js new file mode 100644 index 000000000..db106e84f --- /dev/null +++ b/src/actions/news.js | |||
@@ -0,0 +1,7 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | hide: { | ||
5 | newsId: PropTypes.string.isRequired, | ||
6 | }, | ||
7 | }; | ||
diff --git a/src/actions/payment.js b/src/actions/payment.js new file mode 100644 index 000000000..2aaefc025 --- /dev/null +++ b/src/actions/payment.js | |||
@@ -0,0 +1,8 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | createHostedPage: { | ||
5 | planId: PropTypes.string.isRequired, | ||
6 | }, | ||
7 | createDashboardUrl: {}, | ||
8 | }; | ||
diff --git a/src/actions/recipe.js b/src/actions/recipe.js new file mode 100644 index 000000000..29b0a151f --- /dev/null +++ b/src/actions/recipe.js | |||
@@ -0,0 +1,9 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | install: { | ||
5 | recipeId: PropTypes.string.isRequired, | ||
6 | update: PropTypes.bool, | ||
7 | }, | ||
8 | update: {}, | ||
9 | }; | ||
diff --git a/src/actions/recipePreview.js b/src/actions/recipePreview.js new file mode 100644 index 000000000..36de3d844 --- /dev/null +++ b/src/actions/recipePreview.js | |||
@@ -0,0 +1,7 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | search: { | ||
5 | needle: PropTypes.string.isRequired, | ||
6 | }, | ||
7 | }; | ||
diff --git a/src/actions/requests.js b/src/actions/requests.js new file mode 100644 index 000000000..89296e7ec --- /dev/null +++ b/src/actions/requests.js | |||
@@ -0,0 +1,3 @@ | |||
1 | export default { | ||
2 | retryRequiredRequests: {}, | ||
3 | }; | ||
diff --git a/src/actions/service.js b/src/actions/service.js new file mode 100644 index 000000000..7f429ca32 --- /dev/null +++ b/src/actions/service.js | |||
@@ -0,0 +1,75 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | setActive: { | ||
5 | serviceId: PropTypes.string.isRequired, | ||
6 | }, | ||
7 | showAddServiceInterface: { | ||
8 | recipeId: PropTypes.string.isRequired, | ||
9 | }, | ||
10 | createService: { | ||
11 | recipeId: PropTypes.string.isRequired, | ||
12 | serviceData: PropTypes.object.isRequired, | ||
13 | }, | ||
14 | createFromLegacyService: { | ||
15 | data: PropTypes.object.isRequired, | ||
16 | }, | ||
17 | updateService: { | ||
18 | serviceId: PropTypes.string.isRequired, | ||
19 | serviceData: PropTypes.object.isRequired, | ||
20 | redirect: PropTypes.bool, | ||
21 | }, | ||
22 | deleteService: { | ||
23 | serviceId: PropTypes.string.isRequired, | ||
24 | redirect: PropTypes.string, | ||
25 | }, | ||
26 | setUnreadMessageCount: { | ||
27 | serviceId: PropTypes.string.isRequired, | ||
28 | count: PropTypes.object.isRequired, | ||
29 | }, | ||
30 | setWebviewReference: { | ||
31 | serviceId: PropTypes.string.isRequired, | ||
32 | webview: PropTypes.object.isRequired, | ||
33 | }, | ||
34 | focusService: { | ||
35 | serviceId: PropTypes.string.isRequired, | ||
36 | }, | ||
37 | focusActiveService: {}, | ||
38 | toggleService: { | ||
39 | serviceId: PropTypes.string.isRequired, | ||
40 | }, | ||
41 | handleIPCMessage: { | ||
42 | serviceId: PropTypes.string.isRequired, | ||
43 | channel: PropTypes.string.isRequired, | ||
44 | args: PropTypes.array.isRequired, | ||
45 | }, | ||
46 | sendIPCMessage: { | ||
47 | serviceId: PropTypes.string.isRequired, | ||
48 | channel: PropTypes.string.isRequired, | ||
49 | args: PropTypes.object.isRequired, | ||
50 | }, | ||
51 | openWindow: { | ||
52 | event: PropTypes.object.isRequired, | ||
53 | }, | ||
54 | reload: { | ||
55 | serviceId: PropTypes.string.isRequired, | ||
56 | }, | ||
57 | reloadActive: {}, | ||
58 | reloadAll: {}, | ||
59 | reloadUpdatedServices: {}, | ||
60 | filter: { | ||
61 | needle: PropTypes.string.isRequired, | ||
62 | }, | ||
63 | resetFilter: {}, | ||
64 | reorder: { | ||
65 | oldIndex: PropTypes.number.isRequired, | ||
66 | newIndex: PropTypes.number.isRequired, | ||
67 | }, | ||
68 | toggleNotifications: { | ||
69 | serviceId: PropTypes.string.isRequired, | ||
70 | }, | ||
71 | openDevTools: { | ||
72 | serviceId: PropTypes.string.isRequired, | ||
73 | }, | ||
74 | openDevToolsForActiveService: {}, | ||
75 | }; | ||
diff --git a/src/actions/settings.js b/src/actions/settings.js new file mode 100644 index 000000000..3d53cd674 --- /dev/null +++ b/src/actions/settings.js | |||
@@ -0,0 +1,10 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | update: { | ||
5 | settings: PropTypes.object.isRequired, | ||
6 | }, | ||
7 | remove: { | ||
8 | key: PropTypes.string.isRequired, | ||
9 | }, | ||
10 | }; | ||
diff --git a/src/actions/ui.js b/src/actions/ui.js new file mode 100644 index 000000000..b913b430b --- /dev/null +++ b/src/actions/ui.js | |||
@@ -0,0 +1,11 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | openSettings: { | ||
5 | path: PropTypes.string, | ||
6 | }, | ||
7 | closeSettings: {}, | ||
8 | toggleServiceUpdatedInfoBar: { | ||
9 | visible: PropTypes.bool, | ||
10 | }, | ||
11 | }; | ||
diff --git a/src/actions/user.js b/src/actions/user.js new file mode 100644 index 000000000..fe32b8a05 --- /dev/null +++ b/src/actions/user.js | |||
@@ -0,0 +1,30 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | |||
3 | export default { | ||
4 | login: { | ||
5 | email: PropTypes.string.isRequired, | ||
6 | password: PropTypes.string.isRequired, | ||
7 | }, | ||
8 | logout: {}, | ||
9 | signup: { | ||
10 | firstname: PropTypes.string.isRequired, | ||
11 | lastname: PropTypes.string.isRequired, | ||
12 | email: PropTypes.string.isRequired, | ||
13 | password: PropTypes.string.isRequired, | ||
14 | accountType: PropTypes.string.isRequired, | ||
15 | company: PropTypes.string, | ||
16 | }, | ||
17 | retrievePassword: { | ||
18 | email: PropTypes.string.isRequired, | ||
19 | }, | ||
20 | invite: { | ||
21 | invites: PropTypes.array.isRequired, | ||
22 | }, | ||
23 | update: { | ||
24 | userData: PropTypes.object.isRequired, | ||
25 | }, | ||
26 | resetStatus: {}, | ||
27 | importLegacyServices: PropTypes.arrayOf(PropTypes.shape({ | ||
28 | recipe: PropTypes.string.isRequired, | ||
29 | })).isRequired, | ||
30 | }; | ||