cozy-bar 8.4.2 → 8.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cozy-bar.min.js +4 -4
- package/dist/cozy-bar.min.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -493
- package/transpiled/assets/icons/16/icon-storage-16.svg +0 -3
- package/transpiled/assets/icons/24/icon-arrow-left.svg +0 -3
- package/transpiled/assets/icons/32/icon-claudy.svg +0 -1
- package/transpiled/assets/icons/apps/icon-collect.svg +0 -25
- package/transpiled/assets/icons/apps/icon-drive.svg +0 -17
- package/transpiled/assets/icons/apps/icon-market-soon.svg +0 -25
- package/transpiled/assets/icons/apps/icon-photos.svg +0 -19
- package/transpiled/assets/icons/apps/icon-soon.svg +0 -21
- package/transpiled/assets/icons/apps/icon-store.svg +0 -19
- package/transpiled/assets/icons/claudyActions/icon-bills.svg +0 -6
- package/transpiled/assets/icons/claudyActions/icon-laptop.svg +0 -7
- package/transpiled/assets/icons/claudyActions/icon-phone.svg +0 -8
- package/transpiled/assets/icons/claudyActions/icon-question-mark.svg +0 -6
- package/transpiled/assets/icons/comingsoon/icon-bank.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-sante.svg +0 -12
- package/transpiled/assets/icons/comingsoon/icon-store.svg +0 -6
- package/transpiled/assets/icons/icon-cozy.svg +0 -3
- package/transpiled/assets/icons/icon-shield.svg +0 -3
- package/transpiled/assets/icons/spinner.svg +0 -4
- package/transpiled/assets/sprites/icon-apps.svg +0 -1
- package/transpiled/assets/sprites/icon-cozy-home.svg +0 -16
- package/transpiled/components/Apps/AppItem.js +0 -134
- package/transpiled/components/Apps/AppItemPlaceholder.js +0 -14
- package/transpiled/components/Apps/AppNavButtons.js +0 -108
- package/transpiled/components/Apps/AppsContent.js +0 -124
- package/transpiled/components/Apps/ButtonCozyHome.js +0 -25
- package/transpiled/components/Apps/ButtonCozyHome.spec.jsx +0 -53
- package/transpiled/components/Apps/IconCozyHome.js +0 -67
- package/transpiled/components/Apps/index.js +0 -102
- package/transpiled/components/Banner.js +0 -76
- package/transpiled/components/Bar.js +0 -329
- package/transpiled/components/Bar.spec.jsx +0 -133
- package/transpiled/components/Claudy.js +0 -123
- package/transpiled/components/ClaudyIcon.js +0 -16
- package/transpiled/components/Drawer.js +0 -367
- package/transpiled/components/Drawer.spec.jsx +0 -98
- package/transpiled/components/SearchBar.js +0 -407
- package/transpiled/components/Settings/SettingsContent.js +0 -128
- package/transpiled/components/Settings/StorageData.js +0 -24
- package/transpiled/components/Settings/helper.js +0 -9
- package/transpiled/components/Settings/index.js +0 -225
- package/transpiled/components/StorageIcon.js +0 -16
- package/transpiled/components/SupportModal.js +0 -86
- package/transpiled/components/__snapshots__/Bar.spec.jsx.snap +0 -302
- package/transpiled/config/claudyActions.json +0 -20
- package/transpiled/config/persistWhitelist.json +0 -4
- package/transpiled/cozy-bar.css +0 -5905
- package/transpiled/dom.js +0 -84
- package/transpiled/index.js +0 -246
- package/transpiled/index.spec.jsx +0 -34
- package/transpiled/lib/api/helpers.js +0 -12
- package/transpiled/lib/api/index.js +0 -175
- package/transpiled/lib/exceptions.js +0 -156
- package/transpiled/lib/expiringMemoize.js +0 -17
- package/transpiled/lib/icon.js +0 -154
- package/transpiled/lib/intents.js +0 -17
- package/transpiled/lib/logger.js +0 -10
- package/transpiled/lib/middlewares/appsI18n.js +0 -64
- package/transpiled/lib/realtime.js +0 -76
- package/transpiled/lib/reducers/apps.js +0 -291
- package/transpiled/lib/reducers/apps.spec.js +0 -59
- package/transpiled/lib/reducers/content.js +0 -68
- package/transpiled/lib/reducers/context.js +0 -138
- package/transpiled/lib/reducers/index.js +0 -59
- package/transpiled/lib/reducers/locale.js +0 -27
- package/transpiled/lib/reducers/settings.js +0 -253
- package/transpiled/lib/reducers/theme.js +0 -64
- package/transpiled/lib/reducers/unserializable.js +0 -31
- package/transpiled/lib/stack-client.js +0 -442
- package/transpiled/lib/stack.js +0 -122
- package/transpiled/lib/store/index.js +0 -42
- package/transpiled/locales/de.json +0 -57
- package/transpiled/locales/en.json +0 -57
- package/transpiled/locales/es.json +0 -57
- package/transpiled/locales/fr.json +0 -57
- package/transpiled/locales/it.json +0 -57
- package/transpiled/locales/ja.json +0 -57
- package/transpiled/locales/nl_NL.json +0 -57
- package/transpiled/locales/pl.json +0 -57
- package/transpiled/locales/ru.json +0 -57
- package/transpiled/locales/sq.json +0 -57
- package/transpiled/locales/zh_CN.json +0 -57
- package/transpiled/proptypes/index.js +0 -11
- package/transpiled/queries/index.js +0 -19
- package/transpiled/styles/apps.css +0 -248
- package/transpiled/styles/banner.css +0 -64
- package/transpiled/styles/bar.css +0 -106
- package/transpiled/styles/base.css +0 -21
- package/transpiled/styles/claudy.css +0 -98
- package/transpiled/styles/drawer.css +0 -126
- package/transpiled/styles/index.styl +0 -33
- package/transpiled/styles/indicators.css +0 -58
- package/transpiled/styles/nav.css +0 -81
- package/transpiled/styles/navigation_item.css +0 -34
- package/transpiled/styles/searchbar.css +0 -156
- package/transpiled/styles/settings.css +0 -34
- package/transpiled/styles/storage.css +0 -22
- package/transpiled/styles/supportModal.css +0 -20
- package/transpiled/styles/theme.styl +0 -25
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import stack from "../stack";
|
|
5
|
-
import unionWith from 'lodash.unionwith'; // constants
|
|
6
|
-
|
|
7
|
-
var DELETE_APP = 'DELETE_APP';
|
|
8
|
-
var RECEIVE_APP = 'RECEIVE_APP';
|
|
9
|
-
var RECEIVE_APP_LIST = 'RECEIVE_APP_LIST';
|
|
10
|
-
var RECEIVE_HOME_APP = 'RECEIVE_HOME_APP';
|
|
11
|
-
var FETCH_APPS = 'FETCH_APPS';
|
|
12
|
-
var FETCH_APPS_FAILURE = 'FETCH_APPS_FAILURE';
|
|
13
|
-
var SET_INFOS = 'SET_INFOS';
|
|
14
|
-
export var isCurrentApp = function isCurrentApp(state, app) {
|
|
15
|
-
return app.slug === state.appSlug;
|
|
16
|
-
}; // selectors
|
|
17
|
-
|
|
18
|
-
export var getApps = function getApps(state) {
|
|
19
|
-
if (!state.apps) return [];
|
|
20
|
-
return state.apps;
|
|
21
|
-
};
|
|
22
|
-
export var getHomeApp = function getHomeApp(state) {
|
|
23
|
-
return state.homeApp;
|
|
24
|
-
};
|
|
25
|
-
export var isFetchingApps = function isFetchingApps(state) {
|
|
26
|
-
return state ? state.isFetching : false;
|
|
27
|
-
};
|
|
28
|
-
export var hasFetched = function hasFetched(state) {
|
|
29
|
-
return state.hasFetched;
|
|
30
|
-
}; // actions
|
|
31
|
-
|
|
32
|
-
export var deleteApp = function deleteApp(app) {
|
|
33
|
-
return {
|
|
34
|
-
type: DELETE_APP,
|
|
35
|
-
app: app
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export var receiveApp = function receiveApp(app) {
|
|
39
|
-
return {
|
|
40
|
-
type: RECEIVE_APP,
|
|
41
|
-
app: app
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var receiveAppList = function receiveAppList(apps) {
|
|
46
|
-
return {
|
|
47
|
-
type: RECEIVE_APP_LIST,
|
|
48
|
-
apps: apps
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var receiveHomeApp = function receiveHomeApp(homeApp) {
|
|
53
|
-
return {
|
|
54
|
-
type: RECEIVE_HOME_APP,
|
|
55
|
-
homeApp: homeApp
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export var setInfos = function setInfos(appName, appNamePrefix, appSlug) {
|
|
60
|
-
return {
|
|
61
|
-
type: SET_INFOS,
|
|
62
|
-
appName: appName,
|
|
63
|
-
appNamePrefix: appNamePrefix,
|
|
64
|
-
appSlug: appSlug
|
|
65
|
-
};
|
|
66
|
-
}; // actions async
|
|
67
|
-
|
|
68
|
-
export var fetchApps = function fetchApps() {
|
|
69
|
-
return /*#__PURE__*/function () {
|
|
70
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch) {
|
|
71
|
-
var rawAppList, apps;
|
|
72
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
73
|
-
while (1) {
|
|
74
|
-
switch (_context.prev = _context.next) {
|
|
75
|
-
case 0:
|
|
76
|
-
_context.prev = 0;
|
|
77
|
-
dispatch({
|
|
78
|
-
type: FETCH_APPS
|
|
79
|
-
});
|
|
80
|
-
_context.next = 4;
|
|
81
|
-
return stack.get.apps();
|
|
82
|
-
|
|
83
|
-
case 4:
|
|
84
|
-
rawAppList = _context.sent;
|
|
85
|
-
apps = rawAppList.map(mapApp);
|
|
86
|
-
|
|
87
|
-
if (rawAppList.length) {
|
|
88
|
-
_context.next = 8;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
throw new Error('No installed apps found by the bar');
|
|
93
|
-
|
|
94
|
-
case 8:
|
|
95
|
-
_context.next = 10;
|
|
96
|
-
return dispatch(setDefaultApp(apps));
|
|
97
|
-
|
|
98
|
-
case 10:
|
|
99
|
-
_context.next = 12;
|
|
100
|
-
return dispatch(receiveAppList(apps));
|
|
101
|
-
|
|
102
|
-
case 12:
|
|
103
|
-
_context.next = 18;
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case 14:
|
|
107
|
-
_context.prev = 14;
|
|
108
|
-
_context.t0 = _context["catch"](0);
|
|
109
|
-
dispatch({
|
|
110
|
-
type: FETCH_APPS_FAILURE
|
|
111
|
-
}); // eslint-disable-next-line no-console
|
|
112
|
-
|
|
113
|
-
console.warn(_context.t0.message ? _context.t0.message : _context.t0);
|
|
114
|
-
|
|
115
|
-
case 18:
|
|
116
|
-
case "end":
|
|
117
|
-
return _context.stop();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}, _callee, null, [[0, 14]]);
|
|
121
|
-
}));
|
|
122
|
-
|
|
123
|
-
return function (_x) {
|
|
124
|
-
return _ref.apply(this, arguments);
|
|
125
|
-
};
|
|
126
|
-
}();
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
*
|
|
130
|
-
* @param {Array} appsList
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
export var setDefaultApp = function setDefaultApp(appsList) {
|
|
134
|
-
return /*#__PURE__*/function () {
|
|
135
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dispatch) {
|
|
136
|
-
var context, defaultRedirection, homeApp, HOME_APP_SLUG, slugRegexp, matches, defaultAppSlug;
|
|
137
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
138
|
-
while (1) {
|
|
139
|
-
switch (_context2.prev = _context2.next) {
|
|
140
|
-
case 0:
|
|
141
|
-
_context2.prev = 0;
|
|
142
|
-
_context2.next = 3;
|
|
143
|
-
return stack.get.context();
|
|
144
|
-
|
|
145
|
-
case 3:
|
|
146
|
-
context = _context2.sent;
|
|
147
|
-
defaultRedirection = context.data && context.data.attributes && context.data.attributes.default_redirection;
|
|
148
|
-
homeApp = null; // self hosted cozy has no context by default
|
|
149
|
-
// so let's use hardcoded home slug if needed
|
|
150
|
-
|
|
151
|
-
if (!defaultRedirection) {
|
|
152
|
-
HOME_APP_SLUG = 'home';
|
|
153
|
-
homeApp = findAppInArray(HOME_APP_SLUG, appsList);
|
|
154
|
-
} else {
|
|
155
|
-
slugRegexp = /^([^/]+)\/.*/;
|
|
156
|
-
matches = defaultRedirection.match(slugRegexp);
|
|
157
|
-
defaultAppSlug = matches && matches[1];
|
|
158
|
-
homeApp = findAppInArray(defaultAppSlug, appsList);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!homeApp) {
|
|
162
|
-
_context2.next = 9;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return _context2.abrupt("return", dispatch(receiveHomeApp(homeApp)));
|
|
167
|
-
|
|
168
|
-
case 9:
|
|
169
|
-
_context2.next = 14;
|
|
170
|
-
break;
|
|
171
|
-
|
|
172
|
-
case 11:
|
|
173
|
-
_context2.prev = 11;
|
|
174
|
-
_context2.t0 = _context2["catch"](0);
|
|
175
|
-
// eslint-disable-next-line no-console
|
|
176
|
-
console.warn("Cozy-bar cannot fetch home app data: ".concat(_context2.t0.message));
|
|
177
|
-
|
|
178
|
-
case 14:
|
|
179
|
-
case "end":
|
|
180
|
-
return _context2.stop();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}, _callee2, null, [[0, 11]]);
|
|
184
|
-
}));
|
|
185
|
-
|
|
186
|
-
return function (_x2) {
|
|
187
|
-
return _ref2.apply(this, arguments);
|
|
188
|
-
};
|
|
189
|
-
}();
|
|
190
|
-
}; // reducers
|
|
191
|
-
|
|
192
|
-
var defaultState = {
|
|
193
|
-
apps: [],
|
|
194
|
-
homeApp: null,
|
|
195
|
-
isFetching: true,
|
|
196
|
-
appName: null,
|
|
197
|
-
appNamePrefix: null,
|
|
198
|
-
appSlug: null,
|
|
199
|
-
hasFetched: false
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
var reducer = function reducer() {
|
|
203
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
|
204
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
205
|
-
|
|
206
|
-
switch (action.type) {
|
|
207
|
-
case FETCH_APPS:
|
|
208
|
-
return _objectSpread({}, state, {
|
|
209
|
-
isFetching: true
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
case FETCH_APPS_FAILURE:
|
|
213
|
-
return _objectSpread({}, state, {
|
|
214
|
-
isFetching: false
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
case RECEIVE_APP:
|
|
218
|
-
return _objectSpread({}, state, {
|
|
219
|
-
apps: unionWith(state.apps, [mapApp(action.app)], function (appA, appB) {
|
|
220
|
-
return appA.slug === appB.slug;
|
|
221
|
-
})
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
case RECEIVE_APP_LIST:
|
|
225
|
-
{
|
|
226
|
-
var appsList = action.apps.map(function (app) {
|
|
227
|
-
return _objectSpread({}, app, {
|
|
228
|
-
isCurrentApp: isCurrentApp(state, app)
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
return _objectSpread({}, state, {
|
|
232
|
-
isFetching: false,
|
|
233
|
-
hasFetched: true,
|
|
234
|
-
apps: appsList
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
case RECEIVE_HOME_APP:
|
|
239
|
-
{
|
|
240
|
-
var homeApp = action.homeApp;
|
|
241
|
-
return isCurrentApp(state, homeApp) ? _objectSpread({}, state, {
|
|
242
|
-
homeApp: _objectSpread({}, homeApp, {
|
|
243
|
-
isCurrentApp: true
|
|
244
|
-
})
|
|
245
|
-
}) : _objectSpread({}, state, {
|
|
246
|
-
homeApp: homeApp
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
case DELETE_APP:
|
|
251
|
-
return _objectSpread({}, state, {
|
|
252
|
-
apps: state.apps.filter(function (app) {
|
|
253
|
-
return app.slug !== action.app.slug;
|
|
254
|
-
})
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
case SET_INFOS:
|
|
258
|
-
return _objectSpread({}, state, {
|
|
259
|
-
appName: action.appName,
|
|
260
|
-
appNamePrefix: action.appNamePrefix,
|
|
261
|
-
appSlug: action.appSlug
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
default:
|
|
265
|
-
return state;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
export default reducer; // helpers
|
|
270
|
-
|
|
271
|
-
var camelCasify = function camelCasify(object) {
|
|
272
|
-
return !!object && Object.keys(object).reduce(function (acc, key) {
|
|
273
|
-
var camelCaseKey = key.split('_').map(function (segment, index) {
|
|
274
|
-
return index ? segment.charAt(0).toUpperCase() + segment.slice(1) : segment;
|
|
275
|
-
}).join('');
|
|
276
|
-
acc[camelCaseKey] = object[key];
|
|
277
|
-
return acc;
|
|
278
|
-
}, {});
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
var mapApp = function mapApp(app) {
|
|
282
|
-
return _objectSpread({}, app, camelCasify(app.attributes), {
|
|
283
|
-
href: app.links && app.links.related
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
var findAppInArray = function findAppInArray(appSlug, apps) {
|
|
288
|
-
return apps.find(function (app) {
|
|
289
|
-
return app.slug === appSlug;
|
|
290
|
-
});
|
|
291
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import CozyClient from 'cozy-client'
|
|
2
|
-
import client from 'lib/stack-client.js'
|
|
3
|
-
import stack from 'lib/stack.js'
|
|
4
|
-
import { setDefaultApp } from './apps'
|
|
5
|
-
|
|
6
|
-
const cozyURL = 'https://test.mycozy.cloud'
|
|
7
|
-
const token = 'mytoken'
|
|
8
|
-
const fakeStackClient = {
|
|
9
|
-
uri: cozyURL,
|
|
10
|
-
token: { token }
|
|
11
|
-
}
|
|
12
|
-
describe('app reducer', () => {
|
|
13
|
-
beforeAll(() => {
|
|
14
|
-
jest.clearAllMocks()
|
|
15
|
-
const params = {
|
|
16
|
-
cozyClient: new CozyClient({ fakeStackClient }),
|
|
17
|
-
onCreate: function() {},
|
|
18
|
-
onDelete: function() {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
stack.init(params)
|
|
22
|
-
})
|
|
23
|
-
it('dispatch RECEIVE_HOME_APP if context has default redirection', async () => {
|
|
24
|
-
jest.spyOn(client.get, 'context').mockResolvedValue({
|
|
25
|
-
data: { attributes: { default_redirection: 'home/' } }
|
|
26
|
-
})
|
|
27
|
-
const dispatchMock = jest.fn(x => x)
|
|
28
|
-
|
|
29
|
-
const setted = setDefaultApp([{ slug: 'home' }])
|
|
30
|
-
await setted(dispatchMock)
|
|
31
|
-
expect(dispatchMock).toHaveBeenCalledWith({
|
|
32
|
-
homeApp: { slug: 'home' },
|
|
33
|
-
type: 'RECEIVE_HOME_APP'
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('dispatch RECEIVE_HOME_APP with hardcoded home if context has no default redirection', async () => {
|
|
38
|
-
jest.spyOn(client.get, 'context').mockResolvedValue({})
|
|
39
|
-
const dispatchMock = jest.fn(x => x)
|
|
40
|
-
|
|
41
|
-
const setted = setDefaultApp([{ slug: 'home' }])
|
|
42
|
-
await setted(dispatchMock)
|
|
43
|
-
expect(dispatchMock).toHaveBeenCalledWith({
|
|
44
|
-
homeApp: { slug: 'home' },
|
|
45
|
-
type: 'RECEIVE_HOME_APP'
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('dispatch nothing if the default redirection if not in the apps array', async () => {
|
|
50
|
-
jest.spyOn(client.get, 'context').mockResolvedValue({
|
|
51
|
-
data: { attributes: { default_redirection: 'drive/' } }
|
|
52
|
-
})
|
|
53
|
-
const dispatchMock = jest.fn(x => x)
|
|
54
|
-
|
|
55
|
-
const setted = setDefaultApp([{ slug: 'home' }])
|
|
56
|
-
await setted(dispatchMock)
|
|
57
|
-
expect(dispatchMock).not.toHaveBeenCalled()
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
3
|
-
var SET_CONTENT = 'SET_CONTENT';
|
|
4
|
-
var UNSET_CONTENT = 'UNSET_CONTENT';
|
|
5
|
-
|
|
6
|
-
var getLastItemInMap = function getLastItemInMap(map) {
|
|
7
|
-
return Array.from(map)[map.size - 1];
|
|
8
|
-
}; // action creator
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export var setContent = function setContent(location, content, id) {
|
|
12
|
-
return {
|
|
13
|
-
type: SET_CONTENT,
|
|
14
|
-
location: location,
|
|
15
|
-
content: content,
|
|
16
|
-
id: id
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export var unsetContent = function unsetContent(location, id) {
|
|
20
|
-
return {
|
|
21
|
-
type: UNSET_CONTENT,
|
|
22
|
-
location: location,
|
|
23
|
-
id: id
|
|
24
|
-
};
|
|
25
|
-
}; // reducer
|
|
26
|
-
|
|
27
|
-
export var getDefaultState = function getDefaultState() {
|
|
28
|
-
return {
|
|
29
|
-
left: new Map(),
|
|
30
|
-
center: new Map(),
|
|
31
|
-
right: new Map(),
|
|
32
|
-
search: new Map()
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export var reducer = function reducer() {
|
|
36
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultState();
|
|
37
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
38
|
-
if (!action.location || typeof action.id === undefined) return state;
|
|
39
|
-
|
|
40
|
-
switch (action.type) {
|
|
41
|
-
case SET_CONTENT:
|
|
42
|
-
{
|
|
43
|
-
var currentState = state[action.location];
|
|
44
|
-
currentState.set(action.id, action.content);
|
|
45
|
-
return _objectSpread({}, state, _defineProperty({}, action.location, currentState));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
case UNSET_CONTENT:
|
|
49
|
-
{
|
|
50
|
-
var _currentState = state[action.location];
|
|
51
|
-
|
|
52
|
-
if (!_currentState.get(action.id)) {
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_currentState.delete(action.id);
|
|
57
|
-
|
|
58
|
-
return _objectSpread({}, state, _defineProperty({}, action.location, _currentState));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
default:
|
|
62
|
-
return state;
|
|
63
|
-
}
|
|
64
|
-
}; // selectors
|
|
65
|
-
|
|
66
|
-
export var getContent = function getContent(state, location) {
|
|
67
|
-
return getLastItemInMap(state[location]) && getLastItemInMap(state[location])[1];
|
|
68
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import stack from "../stack";
|
|
5
|
-
import CLAUDY_ACTIONS from "../../config/claudyActions.json";
|
|
6
|
-
import { LOG_OUT } from "./settings";
|
|
7
|
-
import flag from 'cozy-flags';
|
|
8
|
-
var FETCH_CONTEXT = 'FETCH_CONTEXT';
|
|
9
|
-
var FETCH_CONTEXT_SUCCESS = 'FETCH_CONTEXT_SUCCESS';
|
|
10
|
-
var RECEIVE_NO_CONTEXT = 'RECEIVE_NO_CONTEXT'; // selectors
|
|
11
|
-
|
|
12
|
-
export var getHelpLink = function getHelpLink(state) {
|
|
13
|
-
return state.helpLink;
|
|
14
|
-
};
|
|
15
|
-
export var getClaudyActions = function getClaudyActions(state) {
|
|
16
|
-
return state.claudyActions;
|
|
17
|
-
};
|
|
18
|
-
export var shouldEnableClaudy = function shouldEnableClaudy(state) {
|
|
19
|
-
var claudyActions = getClaudyActions(state);
|
|
20
|
-
return !!claudyActions && !!claudyActions.length;
|
|
21
|
-
}; // actions
|
|
22
|
-
|
|
23
|
-
export var fetchContext = function fetchContext() {
|
|
24
|
-
return /*#__PURE__*/function () {
|
|
25
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch, getState) {
|
|
26
|
-
var context;
|
|
27
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
|
-
while (1) {
|
|
29
|
-
switch (_context.prev = _context.next) {
|
|
30
|
-
case 0:
|
|
31
|
-
dispatch({
|
|
32
|
-
type: FETCH_CONTEXT
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (!getState().context.contextNotExist) {
|
|
36
|
-
_context.next = 3;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return _context.abrupt("return", dispatch({
|
|
41
|
-
type: FETCH_CONTEXT_SUCCESS,
|
|
42
|
-
context: null
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
case 3:
|
|
46
|
-
_context.prev = 3;
|
|
47
|
-
_context.next = 6;
|
|
48
|
-
return stack.get.context();
|
|
49
|
-
|
|
50
|
-
case 6:
|
|
51
|
-
context = _context.sent;
|
|
52
|
-
return _context.abrupt("return", dispatch({
|
|
53
|
-
type: FETCH_CONTEXT_SUCCESS,
|
|
54
|
-
context: context
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
case 10:
|
|
58
|
-
_context.prev = 10;
|
|
59
|
-
_context.t0 = _context["catch"](3);
|
|
60
|
-
|
|
61
|
-
if (_context.t0.status && _context.t0.status === 404) {
|
|
62
|
-
dispatch({
|
|
63
|
-
type: RECEIVE_NO_CONTEXT
|
|
64
|
-
});
|
|
65
|
-
} // eslint-disable-next-line no-console
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
console.warn('Cannot get Cozy context');
|
|
69
|
-
return _context.abrupt("return", null);
|
|
70
|
-
|
|
71
|
-
case 15:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, _callee, null, [[3, 10]]);
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
return function (_x, _x2) {
|
|
80
|
-
return _ref.apply(this, arguments);
|
|
81
|
-
};
|
|
82
|
-
}();
|
|
83
|
-
}; // reducers
|
|
84
|
-
|
|
85
|
-
var defaultState = {
|
|
86
|
-
claudyActions: [],
|
|
87
|
-
contextNotExist: false,
|
|
88
|
-
helpLink: null,
|
|
89
|
-
isFetching: false
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
var reducer = function reducer() {
|
|
93
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
|
|
94
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
95
|
-
|
|
96
|
-
switch (action.type) {
|
|
97
|
-
case FETCH_CONTEXT:
|
|
98
|
-
return _objectSpread({}, state, {
|
|
99
|
-
isFetching: true
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
case FETCH_CONTEXT_SUCCESS:
|
|
103
|
-
{
|
|
104
|
-
var attr = action.context && action.context.data && action.context.data.attributes;
|
|
105
|
-
var contextActions = flag('bar.claudy.force-all-actions') ? Object.keys(CLAUDY_ACTIONS) : attr && attr['claudy_actions']; // get an arrays of action
|
|
106
|
-
|
|
107
|
-
var claudyActions = contextActions.map(function (slug) {
|
|
108
|
-
if (CLAUDY_ACTIONS.hasOwnProperty(slug)) {
|
|
109
|
-
// adding also the action slug
|
|
110
|
-
return Object.assign({}, CLAUDY_ACTIONS[slug], {
|
|
111
|
-
slug: slug
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}).filter(function (action) {
|
|
115
|
-
return action;
|
|
116
|
-
});
|
|
117
|
-
return _objectSpread({}, state, {
|
|
118
|
-
helpLink: attr && attr['help_link'] || null,
|
|
119
|
-
claudyActions: claudyActions,
|
|
120
|
-
isFetching: false,
|
|
121
|
-
contextNotExist: false
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
case RECEIVE_NO_CONTEXT:
|
|
126
|
-
return _objectSpread({}, state, {
|
|
127
|
-
contextNotExist: true
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
case LOG_OUT:
|
|
131
|
-
return defaultState;
|
|
132
|
-
|
|
133
|
-
default:
|
|
134
|
-
return state;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export default reducer;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { combineReducers } from 'redux';
|
|
2
|
-
import * as content from "./content";
|
|
3
|
-
import * as locale from "./locale";
|
|
4
|
-
import * as theme from "./theme";
|
|
5
|
-
import * as unserializable from "./unserializable";
|
|
6
|
-
import appsReducer, * as apps from "./apps";
|
|
7
|
-
import settingsReducer, * as settings from "./settings";
|
|
8
|
-
import contextReducer, * as context from "./context";
|
|
9
|
-
|
|
10
|
-
var proxy = function proxy(attr, method) {
|
|
11
|
-
return function (state) {
|
|
12
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
13
|
-
args[_key - 1] = arguments[_key];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return method.apply(void 0, [state[attr]].concat(args));
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
var setContent = content.setContent;
|
|
21
|
-
var unsetContent = content.unsetContent;
|
|
22
|
-
var setLocale = locale.setLocale;
|
|
23
|
-
var setTheme = theme.setTheme;
|
|
24
|
-
var setWebviewContext = unserializable.setWebviewContext;
|
|
25
|
-
var fetchApps = apps.fetchApps;
|
|
26
|
-
var setInfos = apps.setInfos;
|
|
27
|
-
var fetchSettingsData = settings.fetchSettingsData;
|
|
28
|
-
var logOut = settings.logOut;
|
|
29
|
-
var fetchContext = context.fetchContext;
|
|
30
|
-
export { setContent, unsetContent, setLocale, setTheme, setWebviewContext, fetchApps, setInfos, fetchSettingsData, logOut, fetchContext };
|
|
31
|
-
export var getContent = proxy('content', content.getContent);
|
|
32
|
-
export var getLocale = proxy('locale', locale.getLocale);
|
|
33
|
-
export var getTheme = proxy('theme', theme.getTheme);
|
|
34
|
-
export var getApps = proxy('apps', apps.getApps);
|
|
35
|
-
export var getHomeApp = proxy('apps', apps.getHomeApp);
|
|
36
|
-
export var isFetchingApps = proxy('apps', apps.isFetchingApps);
|
|
37
|
-
export var isCurrentApp = proxy('apps', apps.isCurrentApp);
|
|
38
|
-
export var hasFetched = proxy('apps', apps.hasFetched);
|
|
39
|
-
export var getStorageData = proxy('settings', settings.getStorageData);
|
|
40
|
-
export var getSettingsAppURL = proxy('settings', settings.getSettingsAppURL);
|
|
41
|
-
export var isSettingsBusy = proxy('settings', settings.isSettingsBusy);
|
|
42
|
-
export var isFetchingSettings = proxy('settings', settings.isFetchingSettings);
|
|
43
|
-
export var getHelpLink = proxy('context', context.getHelpLink);
|
|
44
|
-
export var getClaudyActions = proxy('context', context.getClaudyActions);
|
|
45
|
-
export var shouldEnableClaudy = proxy('context', context.shouldEnableClaudy);
|
|
46
|
-
export var getWebviewContext = proxy('unserializable', unserializable.getWebviewContext); // realtime handlers
|
|
47
|
-
|
|
48
|
-
export var onRealtimeCreate = apps.receiveApp;
|
|
49
|
-
export var onRealtimeDelete = apps.deleteApp;
|
|
50
|
-
export var reducers = {
|
|
51
|
-
apps: appsReducer,
|
|
52
|
-
content: content.reducer,
|
|
53
|
-
context: contextReducer,
|
|
54
|
-
locale: locale.reducer,
|
|
55
|
-
settings: settingsReducer,
|
|
56
|
-
theme: theme.reducer,
|
|
57
|
-
unserializable: unserializable.reducer
|
|
58
|
-
};
|
|
59
|
-
export default combineReducers(reducers);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export var SET_LOCALE = 'SET_LOCALE'; // action creator
|
|
2
|
-
|
|
3
|
-
export var setLocale = function setLocale(lang) {
|
|
4
|
-
return {
|
|
5
|
-
type: SET_LOCALE,
|
|
6
|
-
lang: lang
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
var getDefaultLang = function getDefaultLang() {
|
|
11
|
-
return document.documentElement.getAttribute('lang') || 'en';
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export var reducer = function reducer() {
|
|
15
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultLang();
|
|
16
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
17
|
-
|
|
18
|
-
if (action.type === SET_LOCALE) {
|
|
19
|
-
return action.lang;
|
|
20
|
-
} else {
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
}; // selector
|
|
24
|
-
|
|
25
|
-
export var getLocale = function getLocale(state) {
|
|
26
|
-
return state;
|
|
27
|
-
};
|