aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rwxr-xr-xsrc/features/settingsWS/actions.ts11
-rw-r--r--src/features/todos/components/TodosWebview.js15
-rw-r--r--src/features/todos/containers/TodosScreen.js17
-rw-r--r--src/features/utils/ActionBinding.ts5
-rw-r--r--src/features/utils/FeatureStore.test.js21
-rw-r--r--src/features/workspaces/components/WorkspaceDrawerItem.js8
-rw-r--r--src/features/workspaces/components/WorkspacesDashboard.js3
-rw-r--r--src/features/workspaces/store.js46
8 files changed, 74 insertions, 52 deletions
diff --git a/src/features/settingsWS/actions.ts b/src/features/settingsWS/actions.ts
index 631670c8a..03a398eb5 100755
--- a/src/features/settingsWS/actions.ts
+++ b/src/features/settingsWS/actions.ts
@@ -1,10 +1,13 @@
1import PropTypes from 'prop-types'; 1import PropTypes from 'prop-types';
2import { createActionsFromDefinitions } from '../../actions/lib/actions'; 2import { createActionsFromDefinitions } from '../../actions/lib/actions';
3 3
4export const settingsWSActions = createActionsFromDefinitions({ 4export const settingsWSActions = createActionsFromDefinitions(
5 greet: { 5 {
6 name: PropTypes.string.isRequired, 6 greet: {
7 name: PropTypes.string.isRequired,
8 },
7 }, 9 },
8}, PropTypes.checkPropTypes); 10 PropTypes.checkPropTypes,
11);
9 12
10export default settingsWSActions; 13export default settingsWSActions;
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js
index b31c7d858..1d423544b 100644
--- a/src/features/todos/components/TodosWebview.js
+++ b/src/features/todos/components/TodosWebview.js
@@ -7,14 +7,15 @@ import classnames from 'classnames';
7 7
8import { TODOS_PARTITION_ID } from '../../../config'; 8import { TODOS_PARTITION_ID } from '../../../config';
9 9
10const styles = (theme) => ({ 10const styles = theme => ({
11 root: { 11 root: {
12 background: theme.colorBackground, 12 background: theme.colorBackground,
13 position: 'relative', 13 position: 'relative',
14 borderLeft: [1, 'solid', theme.todos.todosLayer.borderLeftColor], 14 borderLeft: [1, 'solid', theme.todos.todosLayer.borderLeftColor],
15 zIndex: 300, 15 zIndex: 300,
16 16
17 transform: ({ isVisible, width, isTodosServiceActive }) => `translateX(${isVisible || isTodosServiceActive ? 0 : width}px)`, 17 transform: ({ isVisible, width, isTodosServiceActive }) =>
18 `translateX(${isVisible || isTodosServiceActive ? 0 : width}px)`,
18 19
19 '& webview': { 20 '& webview': {
20 height: '100%', 21 height: '100%',
@@ -79,7 +80,7 @@ class TodosWebview extends Component {
79 this.node.addEventListener('mouseleave', this.stopResize.bind(this)); 80 this.node.addEventListener('mouseleave', this.stopResize.bind(this));
80 } 81 }
81 82
82 startResize = (event) => { 83 startResize = event => {
83 this.setState({ 84 this.setState({
84 isDragging: true, 85 isDragging: true,
85 initialPos: event.clientX, 86 initialPos: event.clientX,
@@ -126,7 +127,7 @@ class TodosWebview extends Component {
126 startListeningToIpcMessages() { 127 startListeningToIpcMessages() {
127 const { handleClientMessage } = this.props; 128 const { handleClientMessage } = this.props;
128 if (!this.webview) return; 129 if (!this.webview) return;
129 this.webview.addEventListener('ipc-message', (e) => { 130 this.webview.addEventListener('ipc-message', e => {
130 // console.log(e); 131 // console.log(e);
131 handleClientMessage({ channel: e.channel, message: e.args[0] }); 132 handleClientMessage({ channel: e.channel, message: e.args[0] });
132 }); 133 });
@@ -159,7 +160,7 @@ class TodosWebview extends Component {
159 })} 160 })}
160 style={{ width: displayedWidth }} 161 style={{ width: displayedWidth }}
161 onMouseUp={() => this.stopResize()} 162 onMouseUp={() => this.stopResize()}
162 ref={(node) => { 163 ref={node => {
163 this.node = node; 164 this.node = node;
164 }} 165 }}
165 id="todos-panel" 166 id="todos-panel"
@@ -170,7 +171,7 @@ class TodosWebview extends Component {
170 left: delta, 171 left: delta,
171 ...(isDragging ? { width: 600, marginLeft: -200 } : {}), 172 ...(isDragging ? { width: 600, marginLeft: -200 } : {}),
172 }} // This hack is required as resizing with webviews beneath behaves quite bad 173 }} // This hack is required as resizing with webviews beneath behaves quite bad
173 onMouseDown={(e) => this.startResize(e)} 174 onMouseDown={e => this.startResize(e)}
174 /> 175 />
175 {isDragging && ( 176 {isDragging && (
176 <div 177 <div
@@ -188,7 +189,7 @@ class TodosWebview extends Component {
188 }} 189 }}
189 partition={TODOS_PARTITION_ID} 190 partition={TODOS_PARTITION_ID}
190 preload="./features/todos/preload.js" 191 preload="./features/todos/preload.js"
191 ref={(webview) => { 192 ref={webview => {
192 this.webview = webview ? webview.view : null; 193 this.webview = webview ? webview.view : null;
193 }} 194 }}
194 useragent={userAgent} 195 useragent={userAgent}
diff --git a/src/features/todos/containers/TodosScreen.js b/src/features/todos/containers/TodosScreen.js
index c2b6a5af4..536810d2d 100644
--- a/src/features/todos/containers/TodosScreen.js
+++ b/src/features/todos/containers/TodosScreen.js
@@ -10,24 +10,31 @@ import { TODOS_MIN_WIDTH } from '../../../config';
10import { todoActions } from '../actions'; 10import { todoActions } from '../actions';
11import ServicesStore from '../../../stores/ServicesStore'; 11import ServicesStore from '../../../stores/ServicesStore';
12 12
13@inject('stores', 'actions') @observer 13@inject('stores', 'actions')
14@observer
14class TodosScreen extends Component { 15class TodosScreen extends Component {
15 render() { 16 render() {
16 if (!todosStore || !todosStore.isFeatureActive || todosStore.isTodosPanelForceHidden) { 17 if (
18 !todosStore ||
19 !todosStore.isFeatureActive ||
20 todosStore.isTodosPanelForceHidden
21 ) {
17 return null; 22 return null;
18 } 23 }
19 24
20 return ( 25 return (
21 <ErrorBoundary> 26 <ErrorBoundary>
22 <TodosWebview 27 <TodosWebview
23 isTodosServiceActive={this.props.stores.services.isTodosServiceActive || false} 28 isTodosServiceActive={
29 this.props.stores.services.isTodosServiceActive || false
30 }
24 isVisible={todosStore.isTodosPanelVisible} 31 isVisible={todosStore.isTodosPanelVisible}
25 togglePanel={todoActions.toggleTodosPanel} 32 togglePanel={todoActions.toggleTodosPanel}
26 handleClientMessage={todoActions.handleClientMessage} 33 handleClientMessage={todoActions.handleClientMessage}
27 setTodosWebview={(webview) => todoActions.setTodosWebview({ webview })} 34 setTodosWebview={webview => todoActions.setTodosWebview({ webview })}
28 width={todosStore.width} 35 width={todosStore.width}
29 minWidth={TODOS_MIN_WIDTH} 36 minWidth={TODOS_MIN_WIDTH}
30 resize={(width) => todoActions.resize({ width })} 37 resize={width => todoActions.resize({ width })}
31 userAgent={todosStore.userAgent} 38 userAgent={todosStore.userAgent}
32 todoUrl={todosStore.todoUrl} 39 todoUrl={todosStore.todoUrl}
33 isTodoUrlValid={todosStore.isTodoUrlValid} 40 isTodoUrlValid={todosStore.isTodoUrlValid}
diff --git a/src/features/utils/ActionBinding.ts b/src/features/utils/ActionBinding.ts
index 787166d44..16308fae4 100644
--- a/src/features/utils/ActionBinding.ts
+++ b/src/features/utils/ActionBinding.ts
@@ -24,6 +24,5 @@ export default class ActionBinding {
24 } 24 }
25} 25}
26 26
27export const createActionBindings = (actions) => ( 27export const createActionBindings = actions =>
28 actions.map((a) => new ActionBinding(a)) 28 actions.map(a => new ActionBinding(a));
29);
diff --git a/src/features/utils/FeatureStore.test.js b/src/features/utils/FeatureStore.test.js
index 92308bf52..1995431bd 100644
--- a/src/features/utils/FeatureStore.test.js
+++ b/src/features/utils/FeatureStore.test.js
@@ -5,9 +5,12 @@ import { createActionsFromDefinitions } from '../../actions/lib/actions';
5import { createActionBindings } from './ActionBinding'; 5import { createActionBindings } from './ActionBinding';
6import { createReactions } from '../../stores/lib/Reaction'; 6import { createReactions } from '../../stores/lib/Reaction';
7 7
8const actions = createActionsFromDefinitions({ 8const actions = createActionsFromDefinitions(
9 countUp: {}, 9 {
10}, PropTypes.checkPropTypes); 10 countUp: {},
11 },
12 PropTypes.checkPropTypes,
13);
11 14
12class TestFeatureStore extends FeatureStore { 15class TestFeatureStore extends FeatureStore {
13 @observable count = 0; 16 @observable count = 0;
@@ -15,12 +18,10 @@ class TestFeatureStore extends FeatureStore {
15 reactionInvokedCount = 0; 18 reactionInvokedCount = 0;
16 19
17 start() { 20 start() {
18 this._registerActions(createActionBindings([ 21 this._registerActions(
19 [actions.countUp, this._countUp], 22 createActionBindings([[actions.countUp, this._countUp]]),
20 ])); 23 );
21 this._registerReactions(createReactions([ 24 this._registerReactions(createReactions([this._countReaction]));
22 this._countReaction,
23 ]));
24 } 25 }
25 26
26 _countUp = () => { 27 _countUp = () => {
@@ -29,7 +30,7 @@ class TestFeatureStore extends FeatureStore {
29 30
30 _countReaction = () => { 31 _countReaction = () => {
31 this.reactionInvokedCount += 1; 32 this.reactionInvokedCount += 1;
32 } 33 };
33} 34}
34 35
35describe('FeatureStore', () => { 36describe('FeatureStore', () => {
diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.js b/src/features/workspaces/components/WorkspaceDrawerItem.js
index 237f9488b..d3c9fa767 100644
--- a/src/features/workspaces/components/WorkspaceDrawerItem.js
+++ b/src/features/workspaces/components/WorkspaceDrawerItem.js
@@ -118,14 +118,12 @@ class WorkspaceDrawerItem extends Component {
118 isActive ? classes.isActiveItem : null, 118 isActive ? classes.isActiveItem : null,
119 ])} 119 ])}
120 onClick={onClick} 120 onClick={onClick}
121 onContextMenu={() => 121 onContextMenu={() => onContextMenuEditClick && contextMenu.popup()}
122 onContextMenuEditClick && contextMenu.popup()
123 }
124 data-tip={`${ 122 data-tip={`${
125 shortcutIndex <= 9 123 shortcutIndex <= 9
126 ? `(${cmdOrCtrlShortcutKey(false)}+${altKey( 124 ? `(${cmdOrCtrlShortcutKey(false)}+${altKey(
127 false, 125 false,
128 )}+${shortcutIndex})` 126 )}+${shortcutIndex})`
129 : '' 127 : ''
130 }`} 128 }`}
131 > 129 >
diff --git a/src/features/workspaces/components/WorkspacesDashboard.js b/src/features/workspaces/components/WorkspacesDashboard.js
index 78b758e7d..8ab9174d3 100644
--- a/src/features/workspaces/components/WorkspacesDashboard.js
+++ b/src/features/workspaces/components/WorkspacesDashboard.js
@@ -40,7 +40,8 @@ const messages = defineMessages({
40 }, 40 },
41 workspaceFeatureInfo: { 41 workspaceFeatureInfo: {
42 id: 'settings.workspaces.workspaceFeatureInfo', 42 id: 'settings.workspaces.workspaceFeatureInfo',
43 defaultMessage: 'Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time. You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.', 43 defaultMessage:
44 'Ferdi Workspaces let you focus on what’s important right now. Set up different sets of services and easily switch between them at any time. You decide which services you need when and where, so we can help you stay on top of your game - or easily switch off from work whenever you want.',
44 }, 45 },
45 workspaceFeatureHeadline: { 46 workspaceFeatureHeadline: {
46 id: 'settings.workspaces.workspaceFeatureHeadline', 47 id: 'settings.workspaces.workspaceFeatureHeadline',
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index db2b69f99..0fa43b723 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -124,7 +124,7 @@ export default class WorkspacesStore extends FeatureStore {
124 this.isFeatureActive = false; 124 this.isFeatureActive = false;
125 } 125 }
126 126
127 filterServicesByActiveWorkspace = (services) => { 127 filterServicesByActiveWorkspace = services => {
128 const { activeWorkspace, isFeatureActive } = this; 128 const { activeWorkspace, isFeatureActive } = this;
129 if (isFeatureActive && activeWorkspace) { 129 if (isFeatureActive && activeWorkspace) {
130 return this.getWorkspaceServices(activeWorkspace); 130 return this.getWorkspaceServices(activeWorkspace);
@@ -134,14 +134,14 @@ export default class WorkspacesStore extends FeatureStore {
134 134
135 getWorkspaceServices(workspace) { 135 getWorkspaceServices(workspace) {
136 const { services } = this.stores; 136 const { services } = this.stores;
137 return workspace.services.map((id) => services.one(id)).filter((s) => !!s); 137 return workspace.services.map(id => services.one(id)).filter(s => !!s);
138 } 138 }
139 139
140 // ========== PRIVATE METHODS ========= // 140 // ========== PRIVATE METHODS ========= //
141 141
142 _getWorkspaceById = (id) => this.workspaces.find((w) => w.id === id); 142 _getWorkspaceById = id => this.workspaces.find(w => w.id === id);
143 143
144 _updateSettings = (changes) => { 144 _updateSettings = changes => {
145 localStorage.setItem('workspaces', { 145 localStorage.setItem('workspaces', {
146 ...this.settings, 146 ...this.settings,
147 ...changes, 147 ...changes,
@@ -191,9 +191,15 @@ export default class WorkspacesStore extends FeatureStore {
191 this.isSwitchingWorkspace = false; 191 this.isSwitchingWorkspace = false;
192 this.nextWorkspace = null; 192 this.nextWorkspace = null;
193 if (this.stores.settings.app.splitMode) { 193 if (this.stores.settings.app.splitMode) {
194 const serviceNames = new Set(this.getWorkspaceServices(workspace).map(service => service.name)); 194 const serviceNames = new Set(
195 for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { 195 this.getWorkspaceServices(workspace).map(service => service.name),
196 wrapper.style.display = serviceNames.has(wrapper.dataset.name) ? '' : 'none'; 196 );
197 for (const wrapper of document.querySelectorAll(
198 '.services__webview-wrapper',
199 )) {
200 wrapper.style.display = serviceNames.has(wrapper.dataset.name)
201 ? ''
202 : 'none';
197 } 203 }
198 } 204 }
199 }, 1000); 205 }, 1000);
@@ -212,7 +218,9 @@ export default class WorkspacesStore extends FeatureStore {
212 setTimeout(() => { 218 setTimeout(() => {
213 this.isSwitchingWorkspace = false; 219 this.isSwitchingWorkspace = false;
214 if (this.stores.settings.app.splitMode) { 220 if (this.stores.settings.app.splitMode) {
215 for (const wrapper of document.querySelectorAll('.services__webview-wrapper')) { 221 for (const wrapper of document.querySelectorAll(
222 '.services__webview-wrapper',
223 )) {
216 wrapper.style.display = ''; 224 wrapper.style.display = '';
217 } 225 }
218 } 226 }
@@ -262,7 +270,8 @@ export default class WorkspacesStore extends FeatureStore {
262 const activeService = this.stores.services.active; 270 const activeService = this.stores.services.active;
263 const workspaceServices = this.getWorkspaceServices(this.activeWorkspace); 271 const workspaceServices = this.getWorkspaceServices(this.activeWorkspace);
264 if (workspaceServices.length <= 0) return; 272 if (workspaceServices.length <= 0) return;
265 const isActiveServiceInWorkspace = workspaceServices.includes(activeService); 273 const isActiveServiceInWorkspace =
274 workspaceServices.includes(activeService);
266 if (!isActiveServiceInWorkspace) { 275 if (!isActiveServiceInWorkspace) {
267 this.actions.service.setActive({ 276 this.actions.service.setActive({
268 serviceId: workspaceServices[0].id, 277 serviceId: workspaceServices[0].id,
@@ -288,8 +297,10 @@ export default class WorkspacesStore extends FeatureStore {
288 const isWorkspaceSettingsRoute = router.location.pathname.includes( 297 const isWorkspaceSettingsRoute = router.location.pathname.includes(
289 WORKSPACES_ROUTES.ROOT, 298 WORKSPACES_ROUTES.ROOT,
290 ); 299 );
291 const isSwitchingToSettingsRoute = !this.isSettingsRouteActive && isWorkspaceSettingsRoute; 300 const isSwitchingToSettingsRoute =
292 const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this.isSettingsRouteActive; 301 !this.isSettingsRouteActive && isWorkspaceSettingsRoute;
302 const isLeavingSettingsRoute =
303 !isWorkspaceSettingsRoute && this.isSettingsRouteActive;
293 304
294 if (isSwitchingToSettingsRoute) { 305 if (isSwitchingToSettingsRoute) {
295 this.isSettingsRouteActive = true; 306 this.isSettingsRouteActive = true;
@@ -300,8 +311,8 @@ export default class WorkspacesStore extends FeatureStore {
300 } else if (isLeavingSettingsRoute) { 311 } else if (isLeavingSettingsRoute) {
301 this.isSettingsRouteActive = false; 312 this.isSettingsRouteActive = false;
302 if ( 313 if (
303 !this._wasDrawerOpenBeforeSettingsRoute 314 !this._wasDrawerOpenBeforeSettingsRoute &&
304 && this.isWorkspaceDrawerOpen 315 this.isWorkspaceDrawerOpen
305 ) { 316 ) {
306 workspaceActions.toggleWorkspaceDrawer(); 317 workspaceActions.toggleWorkspaceDrawer();
307 } 318 }
@@ -311,14 +322,15 @@ export default class WorkspacesStore extends FeatureStore {
311 _cleanupInvalidServiceReferences = () => { 322 _cleanupInvalidServiceReferences = () => {
312 const { services } = this.stores; 323 const { services } = this.stores;
313 const { allServicesRequest } = services; 324 const { allServicesRequest } = services;
314 const servicesHaveBeenLoaded = allServicesRequest.wasExecuted && !allServicesRequest.isError; 325 const servicesHaveBeenLoaded =
326 allServicesRequest.wasExecuted && !allServicesRequest.isError;
315 // Loop through all workspaces and remove invalid service ids (locally) 327 // Loop through all workspaces and remove invalid service ids (locally)
316 for (const workspace of this.workspaces) { 328 for (const workspace of this.workspaces) {
317 for (const serviceId of workspace.services) { 329 for (const serviceId of workspace.services) {
318 if ( 330 if (
319 servicesHaveBeenLoaded 331 servicesHaveBeenLoaded &&
320 && !services.one(serviceId) 332 !services.one(serviceId) &&
321 && serviceId !== KEEP_WS_LOADED_USID 333 serviceId !== KEEP_WS_LOADED_USID
322 ) { 334 ) {
323 workspace.services.remove(serviceId); 335 workspace.services.remove(serviceId);
324 } 336 }