aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/workspaces')
-rw-r--r--src/features/workspaces/components/EditWorkspaceForm.js23
-rw-r--r--src/features/workspaces/components/WorkspacesDashboard.js8
-rw-r--r--src/features/workspaces/containers/EditWorkspaceScreen.js4
-rw-r--r--src/features/workspaces/store.js47
4 files changed, 50 insertions, 32 deletions
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js
index f23bc6cbf..0ff836cba 100644
--- a/src/features/workspaces/components/EditWorkspaceForm.js
+++ b/src/features/workspaces/components/EditWorkspaceForm.js
@@ -40,7 +40,8 @@ const messages = defineMessages({
40 }, 40 },
41 keepLoadedInfo: { 41 keepLoadedInfo: {
42 id: 'settings.workspace.form.keepLoadedInfo', 42 id: 'settings.workspace.form.keepLoadedInfo',
43 defaultMessage: '!!!*This option will be overwritten by the global "Keep all workspaces loaded" option.', 43 defaultMessage:
44 '!!!*This option will be overwritten by the global "Keep all workspaces loaded" option.',
44 }, 45 },
45 servicesInWorkspaceHeadline: { 46 servicesInWorkspaceHeadline: {
46 id: 'settings.workspace.form.servicesInWorkspaceHeadline', 47 id: 'settings.workspace.form.servicesInWorkspaceHeadline',
@@ -68,7 +69,8 @@ const styles = () => ({
68 }, 69 },
69}); 70});
70 71
71@injectSheet(styles) @observer 72@injectSheet(styles)
73@observer
72class EditWorkspaceForm extends Component { 74class EditWorkspaceForm extends Component {
73 static contextTypes = { 75 static contextTypes = {
74 intl: intlShape, 76 intl: intlShape,
@@ -86,6 +88,7 @@ class EditWorkspaceForm extends Component {
86 88
87 form = this.prepareWorkspaceForm(this.props.workspace); 89 form = this.prepareWorkspaceForm(this.props.workspace);
88 90
91 // eslint-disable-next-line react/no-deprecated
89 componentWillReceiveProps(nextProps) { 92 componentWillReceiveProps(nextProps) {
90 const { workspace } = this.props; 93 const { workspace } = this.props;
91 if (workspace.id !== nextProps.workspace.id) { 94 if (workspace.id !== nextProps.workspace.id) {
@@ -164,16 +167,14 @@ class EditWorkspaceForm extends Component {
164 </Link> 167 </Link>
165 </span> 168 </span>
166 <span className="separator" /> 169 <span className="separator" />
167 <span className="settings__header-item"> 170 <span className="settings__header-item">{workspace.name}</span>
168 {workspace.name}
169 </span>
170 </div> 171 </div>
171 <div className="settings__body"> 172 <div className="settings__body">
172 <div className={classes.nameInput}> 173 <div className={classes.nameInput}>
173 <Input {...form.$('name').bind()} /> 174 <Input {...form.$('name').bind()} />
174 <Toggle field={form.$('keepLoaded')} /> 175 <Toggle field={form.$('keepLoaded')} />
175 <p className={`${classes.keepLoadedInfo} franz-form__label`}> 176 <p className={`${classes.keepLoadedInfo} franz-form__label`}>
176 { intl.formatMessage(messages.keepLoadedInfo) } 177 {intl.formatMessage(messages.keepLoadedInfo)}
177 </p> 178 </p>
178 </div> 179 </div>
179 <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2> 180 <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2>
@@ -187,11 +188,13 @@ class EditWorkspaceForm extends Component {
187 </span> 188 </span>
188 {intl.formatMessage(messages.noServicesAdded)} 189 {intl.formatMessage(messages.noServicesAdded)}
189 </p> 190 </p>
190 <Link to="/settings/recipes" className="button">{intl.formatMessage(messages.discoverServices)}</Link> 191 <Link to="/settings/recipes" className="button">
192 {intl.formatMessage(messages.discoverServices)}
193 </Link>
191 </div> 194 </div>
192 ) : ( 195 ) : (
193 <Fragment> 196 <>
194 {services.map(s => ( 197 {services.map((s) => (
195 <WorkspaceServiceListItem 198 <WorkspaceServiceListItem
196 key={s.id} 199 key={s.id}
197 service={s} 200 service={s}
@@ -199,7 +202,7 @@ class EditWorkspaceForm extends Component {
199 onToggle={() => this.toggleService(s)} 202 onToggle={() => this.toggleService(s)}
200 /> 203 />
201 ))} 204 ))}
202 </Fragment> 205 </>
203 )} 206 )}
204 </div> 207 </div>
205 </div> 208 </div>
diff --git a/src/features/workspaces/components/WorkspacesDashboard.js b/src/features/workspaces/components/WorkspacesDashboard.js
index a90bb37e9..cfaacd56e 100644
--- a/src/features/workspaces/components/WorkspacesDashboard.js
+++ b/src/features/workspaces/components/WorkspacesDashboard.js
@@ -184,7 +184,7 @@ class WorkspacesDashboard extends Component {
184 {getUserWorkspacesRequest.isExecuting ? ( 184 {getUserWorkspacesRequest.isExecuting ? (
185 <Loader /> 185 <Loader />
186 ) : ( 186 ) : (
187 <Fragment> 187 <>
188 {/* ===== Workspace could not be loaded error ===== */} 188 {/* ===== Workspace could not be loaded error ===== */}
189 {getUserWorkspacesRequest.error ? ( 189 {getUserWorkspacesRequest.error ? (
190 <Infobox 190 <Infobox
@@ -197,7 +197,7 @@ class WorkspacesDashboard extends Component {
197 {intl.formatMessage(messages.workspacesRequestFailed)} 197 {intl.formatMessage(messages.workspacesRequestFailed)}
198 </Infobox> 198 </Infobox>
199 ) : ( 199 ) : (
200 <Fragment> 200 <>
201 {workspaces.length === 0 ? ( 201 {workspaces.length === 0 ? (
202 <div className="align-middle settings__empty-state"> 202 <div className="align-middle settings__empty-state">
203 {/* ===== Workspaces empty state ===== */} 203 {/* ===== Workspaces empty state ===== */}
@@ -222,9 +222,9 @@ class WorkspacesDashboard extends Component {
222 </tbody> 222 </tbody>
223 </table> 223 </table>
224 )} 224 )}
225 </Fragment> 225 </>
226 )} 226 )}
227 </Fragment> 227 </>
228 )} 228 )}
229 </> 229 </>
230 )} 230 )}
diff --git a/src/features/workspaces/containers/EditWorkspaceScreen.js b/src/features/workspaces/containers/EditWorkspaceScreen.js
index 5eca71259..ba7606031 100644
--- a/src/features/workspaces/containers/EditWorkspaceScreen.js
+++ b/src/features/workspaces/containers/EditWorkspaceScreen.js
@@ -32,9 +32,7 @@ class EditWorkspaceScreen extends Component {
32 const { workspaceBeingEdited } = workspaceStore; 32 const { workspaceBeingEdited } = workspaceStore;
33 const { actions } = this.props; 33 const { actions } = this.props;
34 const workspace = new Workspace( 34 const workspace = new Workspace(
35 Object.assign({ 35 ({ saving: true, ...workspaceBeingEdited, ...values }),
36 saving: true,
37 }, workspaceBeingEdited, values),
38 ); 36 );
39 actions.workspaces.update({ workspace }); 37 actions.workspaces.update({ workspace });
40 }; 38 };
diff --git a/src/features/workspaces/store.js b/src/features/workspaces/store.js
index bddcb6eb4..632f3c299 100644
--- a/src/features/workspaces/store.js
+++ b/src/features/workspaces/store.js
@@ -1,8 +1,4 @@
1import { 1import { computed, observable, action } from 'mobx';
2 computed,
3 observable,
4 action,
5} from 'mobx';
6import localStorage from 'mobx-localstorage'; 2import localStorage from 'mobx-localstorage';
7import { matchRoute } from '../../helpers/routing-helpers'; 3import { matchRoute } from '../../helpers/routing-helpers';
8import { workspaceActions } from './actions'; 4import { workspaceActions } from './actions';
@@ -105,7 +101,10 @@ export default class WorkspacesStore extends FeatureStore {
105 [workspaceActions.update, this._update], 101 [workspaceActions.update, this._update],
106 [workspaceActions.activate, this._setActiveWorkspace], 102 [workspaceActions.activate, this._setActiveWorkspace],
107 [workspaceActions.deactivate, this._deactivateActiveWorkspace], 103 [workspaceActions.deactivate, this._deactivateActiveWorkspace],
108 [workspaceActions.toggleKeepAllWorkspacesLoadedSetting, this._toggleKeepAllWorkspacesLoadedSetting], 104 [
105 workspaceActions.toggleKeepAllWorkspacesLoadedSetting,
106 this._toggleKeepAllWorkspacesLoadedSetting,
107 ],
109 ]); 108 ]);
110 this._allActions = this._freeUserActions.concat(this._premiumUserActions); 109 this._allActions = this._freeUserActions.concat(this._premiumUserActions);
111 this._registerActions(this._allActions); 110 this._registerActions(this._allActions);
@@ -124,7 +123,9 @@ export default class WorkspacesStore extends FeatureStore {
124 this._activateLastUsedWorkspaceReaction, 123 this._activateLastUsedWorkspaceReaction,
125 this._setWorkspaceBeingEditedReaction, 124 this._setWorkspaceBeingEditedReaction,
126 ]); 125 ]);
127 this._allReactions = this._freeUserReactions.concat(this._premiumUserReactions); 126 this._allReactions = this._freeUserReactions.concat(
127 this._premiumUserReactions,
128 );
128 129
129 this._registerReactions(this._allReactions); 130 this._registerReactions(this._allReactions);
130 131
@@ -157,12 +158,12 @@ export default class WorkspacesStore extends FeatureStore {
157 158
158 getWorkspaceServices(workspace) { 159 getWorkspaceServices(workspace) {
159 const { services } = this.stores; 160 const { services } = this.stores;
160 return workspace.services.map(id => services.one(id)).filter(s => !!s); 161 return workspace.services.map((id) => services.one(id)).filter((s) => !!s);
161 } 162 }
162 163
163 // ========== PRIVATE METHODS ========= // 164 // ========== PRIVATE METHODS ========= //
164 165
165 _getWorkspaceById = id => this.workspaces.find(w => w.id === id); 166 _getWorkspaceById = (id) => this.workspaces.find((w) => w.id === id);
166 167
167 _updateSettings = (changes) => { 168 _updateSettings = (changes) => {
168 localStorage.setItem('workspaces', { 169 localStorage.setItem('workspaces', {
@@ -178,6 +179,7 @@ export default class WorkspacesStore extends FeatureStore {
178 }; 179 };
179 180
180 @action _create = async ({ name }) => { 181 @action _create = async ({ name }) => {
182 // eslint-disable-next-line no-useless-catch
181 try { 183 try {
182 const workspace = await createWorkspaceRequest.execute(name); 184 const workspace = await createWorkspaceRequest.execute(name);
183 await getUserWorkspacesRequest.result.push(workspace); 185 await getUserWorkspacesRequest.result.push(workspace);
@@ -188,6 +190,7 @@ export default class WorkspacesStore extends FeatureStore {
188 }; 190 };
189 191
190 @action _delete = async ({ workspace }) => { 192 @action _delete = async ({ workspace }) => {
193 // eslint-disable-next-line no-useless-catch
191 try { 194 try {
192 await deleteWorkspaceRequest.execute(workspace); 195 await deleteWorkspaceRequest.execute(workspace);
193 await getUserWorkspacesRequest.result.remove(workspace); 196 await getUserWorkspacesRequest.result.remove(workspace);
@@ -198,6 +201,7 @@ export default class WorkspacesStore extends FeatureStore {
198 }; 201 };
199 202
200 @action _update = async ({ workspace }) => { 203 @action _update = async ({ workspace }) => {
204 // eslint-disable-next-line no-useless-catch
201 try { 205 try {
202 await updateWorkspaceRequest.execute(workspace); 206 await updateWorkspaceRequest.execute(workspace);
203 // Path local result optimistically 207 // Path local result optimistically
@@ -235,7 +239,9 @@ export default class WorkspacesStore extends FeatureStore {
235 this.activeWorkspace = null; 239 this.activeWorkspace = null;
236 }, 100); 240 }, 100);
237 // Indicate that we are done switching to the default workspace 241 // Indicate that we are done switching to the default workspace
238 setTimeout(() => { this.isSwitchingWorkspace = false; }, 1000); 242 setTimeout(() => {
243 this.isSwitchingWorkspace = false;
244 }, 1000);
239 }; 245 };
240 246
241 @action _toggleWorkspaceDrawer = () => { 247 @action _toggleWorkspaceDrawer = () => {
@@ -255,7 +261,9 @@ export default class WorkspacesStore extends FeatureStore {
255 }; 261 };
256 262
257 _toggleKeepAllWorkspacesLoadedSetting = async () => { 263 _toggleKeepAllWorkspacesLoadedSetting = async () => {
258 this._updateSettings({ keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded }); 264 this._updateSettings({
265 keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded,
266 });
259 }; 267 };
260 268
261 // Reactions 269 // Reactions
@@ -309,7 +317,9 @@ export default class WorkspacesStore extends FeatureStore {
309 317
310 _openDrawerWithSettingsReaction = () => { 318 _openDrawerWithSettingsReaction = () => {
311 const { router } = this.stores; 319 const { router } = this.stores;
312 const isWorkspaceSettingsRoute = router.location.pathname.includes(WORKSPACES_ROUTES.ROOT); 320 const isWorkspaceSettingsRoute = router.location.pathname.includes(
321 WORKSPACES_ROUTES.ROOT,
322 );
313 const isSwitchingToSettingsRoute = !this.isSettingsRouteActive && isWorkspaceSettingsRoute; 323 const isSwitchingToSettingsRoute = !this.isSettingsRouteActive && isWorkspaceSettingsRoute;
314 const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this.isSettingsRouteActive; 324 const isLeavingSettingsRoute = !isWorkspaceSettingsRoute && this.isSettingsRouteActive;
315 325
@@ -321,7 +331,10 @@ export default class WorkspacesStore extends FeatureStore {
321 } 331 }
322 } else if (isLeavingSettingsRoute) { 332 } else if (isLeavingSettingsRoute) {
323 this.isSettingsRouteActive = false; 333 this.isSettingsRouteActive = false;
324 if (!this._wasDrawerOpenBeforeSettingsRoute && this.isWorkspaceDrawerOpen) { 334 if (
335 !this._wasDrawerOpenBeforeSettingsRoute
336 && this.isWorkspaceDrawerOpen
337 ) {
325 workspaceActions.toggleWorkspaceDrawer(); 338 workspaceActions.toggleWorkspaceDrawer();
326 } 339 }
327 } 340 }
@@ -334,7 +347,11 @@ export default class WorkspacesStore extends FeatureStore {
334 // Loop through all workspaces and remove invalid service ids (locally) 347 // Loop through all workspaces and remove invalid service ids (locally)
335 this.workspaces.forEach((workspace) => { 348 this.workspaces.forEach((workspace) => {
336 workspace.services.forEach((serviceId) => { 349 workspace.services.forEach((serviceId) => {
337 if (servicesHaveBeenLoaded && !services.one(serviceId) && serviceId !== KEEP_WS_LOADED_USID) { 350 if (
351 servicesHaveBeenLoaded
352 && !services.one(serviceId)
353 && serviceId !== KEEP_WS_LOADED_USID
354 ) {
338 workspace.services.remove(serviceId); 355 workspace.services.remove(serviceId);
339 } 356 }
340 }); 357 });
@@ -351,5 +368,5 @@ export default class WorkspacesStore extends FeatureStore {
351 this._startActions(this._premiumUserActions); 368 this._startActions(this._premiumUserActions);
352 this._startReactions(this._premiumUserReactions); 369 this._startReactions(this._premiumUserReactions);
353 } 370 }
354 } 371 };
355} 372}