aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/workspaces')
-rw-r--r--src/features/workspaces/api.js12
-rw-r--r--src/features/workspaces/components/CreateWorkspaceForm.js4
-rw-r--r--src/features/workspaces/components/EditWorkspaceForm.js28
-rw-r--r--src/features/workspaces/components/WorkspaceDrawer.js9
-rw-r--r--src/features/workspaces/components/WorkspacesDashboard.js2
-rw-r--r--src/features/workspaces/containers/EditWorkspaceScreen.js4
-rw-r--r--src/features/workspaces/index.js2
-rw-r--r--src/features/workspaces/models/Workspace.js14
-rw-r--r--src/features/workspaces/store.js23
9 files changed, 63 insertions, 35 deletions
diff --git a/src/features/workspaces/api.js b/src/features/workspaces/api.js
index 0ec20c9ea..30fbd84be 100644
--- a/src/features/workspaces/api.js
+++ b/src/features/workspaces/api.js
@@ -1,14 +1,14 @@
1import { pick } from 'lodash'; 1import { pick } from 'lodash';
2import { sendAuthRequest } from '../../api/utils/auth'; 2import { sendAuthRequest } from '../../api/utils/auth';
3import { API, API_VERSION } from '../../environment';
4import Request from '../../stores/lib/Request'; 3import Request from '../../stores/lib/Request';
5import Workspace from './models/Workspace'; 4import Workspace from './models/Workspace';
5import apiBase from '../../api/apiBase';
6 6
7const debug = require('debug')('Franz:feature:workspaces:api'); 7const debug = require('debug')('Ferdi:feature:workspaces:api');
8 8
9export const workspaceApi = { 9export const workspaceApi = {
10 getUserWorkspaces: async () => { 10 getUserWorkspaces: async () => {
11 const url = `${API}/${API_VERSION}/workspace`; 11 const url = `${apiBase()}/workspace`;
12 debug('getUserWorkspaces GET', url); 12 debug('getUserWorkspaces GET', url);
13 const result = await sendAuthRequest(url, { method: 'GET' }); 13 const result = await sendAuthRequest(url, { method: 'GET' });
14 debug('getUserWorkspaces RESULT', result); 14 debug('getUserWorkspaces RESULT', result);
@@ -18,7 +18,7 @@ export const workspaceApi = {
18 }, 18 },
19 19
20 createWorkspace: async (name) => { 20 createWorkspace: async (name) => {
21 const url = `${API}/${API_VERSION}/workspace`; 21 const url = `${apiBase()}/workspace`;
22 const options = { 22 const options = {
23 method: 'POST', 23 method: 'POST',
24 body: JSON.stringify({ name }), 24 body: JSON.stringify({ name }),
@@ -31,7 +31,7 @@ export const workspaceApi = {
31 }, 31 },
32 32
33 deleteWorkspace: async (workspace) => { 33 deleteWorkspace: async (workspace) => {
34 const url = `${API}/${API_VERSION}/workspace/${workspace.id}`; 34 const url = `${apiBase()}/workspace/${workspace.id}`;
35 debug('deleteWorkspace DELETE', url); 35 debug('deleteWorkspace DELETE', url);
36 const result = await sendAuthRequest(url, { method: 'DELETE' }); 36 const result = await sendAuthRequest(url, { method: 'DELETE' });
37 debug('deleteWorkspace RESULT', result); 37 debug('deleteWorkspace RESULT', result);
@@ -40,7 +40,7 @@ export const workspaceApi = {
40 }, 40 },
41 41
42 updateWorkspace: async (workspace) => { 42 updateWorkspace: async (workspace) => {
43 const url = `${API}/${API_VERSION}/workspace/${workspace.id}`; 43 const url = `${apiBase()}/workspace/${workspace.id}`;
44 const options = { 44 const options = {
45 method: 'PUT', 45 method: 'PUT',
46 body: JSON.stringify(pick(workspace, ['name', 'services'])), 46 body: JSON.stringify(pick(workspace, ['name', 'services'])),
diff --git a/src/features/workspaces/components/CreateWorkspaceForm.js b/src/features/workspaces/components/CreateWorkspaceForm.js
index cddbb2b04..15b97121d 100644
--- a/src/features/workspaces/components/CreateWorkspaceForm.js
+++ b/src/features/workspaces/components/CreateWorkspaceForm.js
@@ -6,8 +6,7 @@ import { Input, Button } from '@meetfranz/forms';
6import injectSheet from 'react-jss'; 6import injectSheet from 'react-jss';
7import Form from '../../../lib/Form'; 7import Form from '../../../lib/Form';
8import { required } from '../../../helpers/validation-helpers'; 8import { required } from '../../../helpers/validation-helpers';
9import { gaEvent } from '../../../lib/analytics'; 9import { workspaceStore } from '../index';
10import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../index';
11 10
12const messages = defineMessages({ 11const messages = defineMessages({
13 submitButton: { 12 submitButton: {
@@ -66,7 +65,6 @@ class CreateWorkspaceForm extends Component {
66 const { onSubmit } = this.props; 65 const { onSubmit } = this.props;
67 const values = f.values(); 66 const values = f.values();
68 onSubmit(values); 67 onSubmit(values);
69 gaEvent(GA_CATEGORY_WORKSPACES, 'create', values.name);
70 }, 68 },
71 }); 69 });
72 } 70 }
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js
index e602ebd5a..b3551a7b9 100644
--- a/src/features/workspaces/components/EditWorkspaceForm.js
+++ b/src/features/workspaces/components/EditWorkspaceForm.js
@@ -12,8 +12,10 @@ import Form from '../../../lib/Form';
12import { required } from '../../../helpers/validation-helpers'; 12import { required } from '../../../helpers/validation-helpers';
13import WorkspaceServiceListItem from './WorkspaceServiceListItem'; 13import WorkspaceServiceListItem from './WorkspaceServiceListItem';
14import Request from '../../../stores/lib/Request'; 14import Request from '../../../stores/lib/Request';
15import { gaEvent } from '../../../lib/analytics'; 15
16import { GA_CATEGORY_WORKSPACES } from '../index'; 16import { KEEP_WS_LOADED_USID } from '../../../config';
17
18import Toggle from '../../../components/ui/Toggle';
17 19
18const messages = defineMessages({ 20const messages = defineMessages({
19 buttonDelete: { 21 buttonDelete: {
@@ -32,6 +34,14 @@ const messages = defineMessages({
32 id: 'settings.workspace.form.yourWorkspaces', 34 id: 'settings.workspace.form.yourWorkspaces',
33 defaultMessage: '!!!Your workspaces', 35 defaultMessage: '!!!Your workspaces',
34 }, 36 },
37 keepLoaded: {
38 id: 'settings.workspace.form.keepLoaded',
39 defaultMessage: '!!!Keep this workspace loaded*',
40 },
41 keepLoadedInfo: {
42 id: 'settings.workspace.form.keepLoadedInfo',
43 defaultMessage: '!!!*This option will be overwritten by the global "Keep all workspaces loaded" option.',
44 },
35 servicesInWorkspaceHeadline: { 45 servicesInWorkspaceHeadline: {
36 id: 'settings.workspace.form.servicesInWorkspaceHeadline', 46 id: 'settings.workspace.form.servicesInWorkspaceHeadline',
37 defaultMessage: '!!!Services in this Workspace', 47 defaultMessage: '!!!Services in this Workspace',
@@ -53,6 +63,9 @@ const styles = () => ({
53 serviceList: { 63 serviceList: {
54 height: 'auto', 64 height: 'auto',
55 }, 65 },
66 keepLoadedInfo: {
67 marginBottom: '2rem !important',
68 },
56}); 69});
57 70
58@injectSheet(styles) @observer 71@injectSheet(styles) @observer
@@ -90,6 +103,11 @@ class EditWorkspaceForm extends Component {
90 value: workspace.name, 103 value: workspace.name,
91 validators: [required], 104 validators: [required],
92 }, 105 },
106 keepLoaded: {
107 label: intl.formatMessage(messages.keepLoaded),
108 value: workspace.services.includes(KEEP_WS_LOADED_USID),
109 default: false,
110 },
93 services: { 111 services: {
94 value: workspace.services.slice(), 112 value: workspace.services.slice(),
95 }, 113 },
@@ -103,7 +121,6 @@ class EditWorkspaceForm extends Component {
103 const { onSave } = this.props; 121 const { onSave } = this.props;
104 const values = f.values(); 122 const values = f.values();
105 onSave(values); 123 onSave(values);
106 gaEvent(GA_CATEGORY_WORKSPACES, 'save');
107 }, 124 },
108 onError: async () => {}, 125 onError: async () => {},
109 }); 126 });
@@ -112,7 +129,6 @@ class EditWorkspaceForm extends Component {
112 delete() { 129 delete() {
113 const { onDelete } = this.props; 130 const { onDelete } = this.props;
114 onDelete(); 131 onDelete();
115 gaEvent(GA_CATEGORY_WORKSPACES, 'delete');
116 } 132 }
117 133
118 toggleService(service) { 134 toggleService(service) {
@@ -155,6 +171,10 @@ class EditWorkspaceForm extends Component {
155 <div className="settings__body"> 171 <div className="settings__body">
156 <div className={classes.nameInput}> 172 <div className={classes.nameInput}>
157 <Input {...form.$('name').bind()} /> 173 <Input {...form.$('name').bind()} />
174 <Toggle field={form.$('keepLoaded')} />
175 <p className={classes.keepLoadedInfo}>
176 { intl.formatMessage(messages.keepLoadedInfo) }
177 </p>
158 </div> 178 </div>
159 <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2> 179 <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2>
160 <div className={classes.serviceList}> 180 <div className={classes.serviceList}>
diff --git a/src/features/workspaces/components/WorkspaceDrawer.js b/src/features/workspaces/components/WorkspaceDrawer.js
index 07100f5a1..baa94f6b3 100644
--- a/src/features/workspaces/components/WorkspaceDrawer.js
+++ b/src/features/workspaces/components/WorkspaceDrawer.js
@@ -10,8 +10,7 @@ import ReactTooltip from 'react-tooltip';
10import { mdiPlusBox, mdiSettings, mdiStar } from '@mdi/js'; 10import { mdiPlusBox, mdiSettings, mdiStar } from '@mdi/js';
11import WorkspaceDrawerItem from './WorkspaceDrawerItem'; 11import WorkspaceDrawerItem from './WorkspaceDrawerItem';
12import { workspaceActions } from '../actions'; 12import { workspaceActions } from '../actions';
13import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../index'; 13import { workspaceStore } from '../index';
14import { gaEvent } from '../../../lib/analytics';
15 14
16const messages = defineMessages({ 15const messages = defineMessages({
17 headline: { 16 headline: {
@@ -158,7 +157,6 @@ class WorkspaceDrawer extends Component {
158 className={classes.workspacesSettingsButton} 157 className={classes.workspacesSettingsButton}
159 onClick={() => { 158 onClick={() => {
160 workspaceActions.openWorkspaceSettings(); 159 workspaceActions.openWorkspaceSettings();
161 gaEvent(GA_CATEGORY_WORKSPACES, 'settings', 'drawerHeadline');
162 }} 160 }}
163 data-tip={`${intl.formatMessage(messages.workspacesSettingsTooltip)}`} 161 data-tip={`${intl.formatMessage(messages.workspacesSettingsTooltip)}`}
164 > 162 >
@@ -180,7 +178,6 @@ class WorkspaceDrawer extends Component {
180 icon={mdiStar} 178 icon={mdiStar}
181 onClick={() => { 179 onClick={() => {
182 onUpgradeAccountClick(); 180 onUpgradeAccountClick();
183 gaEvent('User', 'upgrade', 'workspaceDrawer');
184 }} 181 }}
185 /> 182 />
186 ) : ( 183 ) : (
@@ -191,7 +188,6 @@ class WorkspaceDrawer extends Component {
191 icon={mdiPlusBox} 188 icon={mdiPlusBox}
192 onClick={() => { 189 onClick={() => {
193 workspaceActions.openWorkspaceSettings(); 190 workspaceActions.openWorkspaceSettings();
194 gaEvent(GA_CATEGORY_WORKSPACES, 'add', 'drawerPremiumCta');
195 }} 191 }}
196 /> 192 />
197 )} 193 )}
@@ -203,7 +199,6 @@ class WorkspaceDrawer extends Component {
203 onClick={() => { 199 onClick={() => {
204 workspaceActions.deactivate(); 200 workspaceActions.deactivate();
205 workspaceActions.toggleWorkspaceDrawer(); 201 workspaceActions.toggleWorkspaceDrawer();
206 gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'drawer');
207 }} 202 }}
208 services={getServicesForWorkspace(null)} 203 services={getServicesForWorkspace(null)}
209 isActive={actualWorkspace == null} 204 isActive={actualWorkspace == null}
@@ -218,7 +213,6 @@ class WorkspaceDrawer extends Component {
218 if (actualWorkspace === workspace) return; 213 if (actualWorkspace === workspace) return;
219 workspaceActions.activate({ workspace }); 214 workspaceActions.activate({ workspace });
220 workspaceActions.toggleWorkspaceDrawer(); 215 workspaceActions.toggleWorkspaceDrawer();
221 gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'drawer');
222 }} 216 }}
223 onContextMenuEditClick={() => workspaceActions.edit({ workspace })} 217 onContextMenuEditClick={() => workspaceActions.edit({ workspace })}
224 services={getServicesForWorkspace(workspace)} 218 services={getServicesForWorkspace(workspace)}
@@ -229,7 +223,6 @@ class WorkspaceDrawer extends Component {
229 className={classes.addNewWorkspaceLabel} 223 className={classes.addNewWorkspaceLabel}
230 onClick={() => { 224 onClick={() => {
231 workspaceActions.openWorkspaceSettings(); 225 workspaceActions.openWorkspaceSettings();
232 gaEvent(GA_CATEGORY_WORKSPACES, 'add', 'drawerAddLabel');
233 }} 226 }}
234 > 227 >
235 <Icon 228 <Icon
diff --git a/src/features/workspaces/components/WorkspacesDashboard.js b/src/features/workspaces/components/WorkspacesDashboard.js
index 4fb302be2..b499e02a4 100644
--- a/src/features/workspaces/components/WorkspacesDashboard.js
+++ b/src/features/workspaces/components/WorkspacesDashboard.js
@@ -47,7 +47,7 @@ const messages = defineMessages({
47 }, 47 },
48 workspaceFeatureHeadline: { 48 workspaceFeatureHeadline: {
49 id: 'settings.workspaces.workspaceFeatureHeadline', 49 id: 'settings.workspaces.workspaceFeatureHeadline',
50 defaultMessage: '!!!Less is More: Introducing Franz Workspaces', 50 defaultMessage: '!!!Less is More: Introducing Ferdi Workspaces',
51 }, 51 },
52}); 52});
53 53
diff --git a/src/features/workspaces/containers/EditWorkspaceScreen.js b/src/features/workspaces/containers/EditWorkspaceScreen.js
index 248b40131..7eaabc1ea 100644
--- a/src/features/workspaces/containers/EditWorkspaceScreen.js
+++ b/src/features/workspaces/containers/EditWorkspaceScreen.js
@@ -33,7 +33,9 @@ class EditWorkspaceScreen extends Component {
33 const { workspaceBeingEdited } = workspaceStore; 33 const { workspaceBeingEdited } = workspaceStore;
34 const { actions } = this.props; 34 const { actions } = this.props;
35 const workspace = new Workspace( 35 const workspace = new Workspace(
36 Object.assign({}, workspaceBeingEdited, values), 36 Object.assign({
37 saving: true,
38 }, workspaceBeingEdited, values),
37 ); 39 );
38 actions.workspaces.update({ workspace }); 40 actions.workspaces.update({ workspace });
39 }; 41 };
diff --git a/src/features/workspaces/index.js b/src/features/workspaces/index.js
index ed3e52096..560b732ab 100644
--- a/src/features/workspaces/index.js
+++ b/src/features/workspaces/index.js
@@ -2,7 +2,7 @@ import { reaction } from 'mobx';
2import WorkspacesStore from './store'; 2import WorkspacesStore from './store';
3import { resetApiRequests } from './api'; 3import { resetApiRequests } from './api';
4 4
5const debug = require('debug')('Franz:feature:workspaces'); 5const debug = require('debug')('Ferdi:feature:workspaces');
6 6
7export const GA_CATEGORY_WORKSPACES = 'Workspaces'; 7export const GA_CATEGORY_WORKSPACES = 'Workspaces';
8export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false; 8export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false;
diff --git a/src/features/workspaces/models/Workspace.js b/src/features/workspaces/models/Workspace.js
index 6c73d7095..77c4e05f4 100644
--- a/src/features/workspaces/models/Workspace.js
+++ b/src/features/workspaces/models/Workspace.js
@@ -1,5 +1,7 @@
1import { observable } from 'mobx'; 1import { observable } from 'mobx';
2 2
3import { KEEP_WS_LOADED_USID } from '../../../config';
4
3export default class Workspace { 5export default class Workspace {
4 id = null; 6 id = null;
5 7
@@ -19,7 +21,17 @@ export default class Workspace {
19 this.id = data.id; 21 this.id = data.id;
20 this.name = data.name; 22 this.name = data.name;
21 this.order = data.order; 23 this.order = data.order;
22 this.services.replace(data.services); 24
25 let services = data.services;
26 if (data.saving && data.keepLoaded) {
27 // Keep workspaces loaded
28 services.push(KEEP_WS_LOADED_USID);
29 } else if (data.saving && data.services.includes(KEEP_WS_LOADED_USID)) {
30 // Don't keep loaded
31 services = services.filter(e => e !== KEEP_WS_LOADED_USID);
32 }
33 this.services.replace(services);
34
23 this.userId = data.userId; 35 this.userId = data.userId;
24 } 36 }
25} 37}
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index 13227e033..5c90ff180 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -17,16 +17,18 @@ import { WORKSPACES_ROUTES } from './index';
17import { createReactions } from '../../stores/lib/Reaction'; 17import { createReactions } from '../../stores/lib/Reaction';
18import { createActionBindings } from '../utils/ActionBinding'; 18import { createActionBindings } from '../utils/ActionBinding';
19 19
20const debug = require('debug')('Franz:feature:workspaces:store'); 20import { KEEP_WS_LOADED_USID } from '../../config';
21
22const debug = require('debug')('Ferdi:feature:workspaces:store');
21 23
22export default class WorkspacesStore extends FeatureStore { 24export default class WorkspacesStore extends FeatureStore {
23 @observable isFeatureEnabled = false; 25 @observable isFeatureEnabled = true;
24 26
25 @observable isFeatureActive = false; 27 @observable isFeatureActive = false;
26 28
27 @observable isPremiumFeature = true; 29 @observable isPremiumFeature = false;
28 30
29 @observable isPremiumUpgradeRequired = true; 31 @observable isPremiumUpgradeRequired = false;
30 32
31 @observable activeWorkspace = null; 33 @observable activeWorkspace = null;
32 34
@@ -59,7 +61,8 @@ export default class WorkspacesStore extends FeatureStore {
59 } 61 }
60 62
61 @computed get isUserAllowedToUseFeature() { 63 @computed get isUserAllowedToUseFeature() {
62 return !this.isPremiumUpgradeRequired; 64 return true;
65 // return !this.isPremiumUpgradeRequired;
63 } 66 }
64 67
65 @computed get isAnyWorkspaceActive() { 68 @computed get isAnyWorkspaceActive() {
@@ -263,10 +266,10 @@ export default class WorkspacesStore extends FeatureStore {
263 }; 266 };
264 267
265 _setIsPremiumFeatureReaction = () => { 268 _setIsPremiumFeatureReaction = () => {
266 const { features } = this.stores; 269 // const { features } = this.stores;
267 const { isWorkspaceIncludedInCurrentPlan } = features.features; 270 // const { isWorkspaceIncludedInCurrentPlan } = features.features;
268 this.isPremiumFeature = !isWorkspaceIncludedInCurrentPlan; 271 // this.isPremiumFeature = !isWorkspaceIncludedInCurrentPlan;
269 this.isPremiumUpgradeRequired = !isWorkspaceIncludedInCurrentPlan; 272 // this.isPremiumUpgradeRequired = !isWorkspaceIncludedInCurrentPlan;
270 }; 273 };
271 274
272 _setWorkspaceBeingEditedReaction = () => { 275 _setWorkspaceBeingEditedReaction = () => {
@@ -331,7 +334,7 @@ export default class WorkspacesStore extends FeatureStore {
331 // Loop through all workspaces and remove invalid service ids (locally) 334 // Loop through all workspaces and remove invalid service ids (locally)
332 this.workspaces.forEach((workspace) => { 335 this.workspaces.forEach((workspace) => {
333 workspace.services.forEach((serviceId) => { 336 workspace.services.forEach((serviceId) => {
334 if (servicesHaveBeenLoaded && !services.one(serviceId)) { 337 if (servicesHaveBeenLoaded && !services.one(serviceId) && serviceId !== KEEP_WS_LOADED_USID) {
335 workspace.services.remove(serviceId); 338 workspace.services.remove(serviceId);
336 } 339 }
337 }); 340 });