diff options
author | 2019-09-17 12:20:57 +0200 | |
---|---|---|
committer | 2019-09-17 12:20:57 +0200 | |
commit | 4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd (patch) | |
tree | 702a4a712e18befb543389aee4aabf308de03846 /src/features/workspaces | |
parent | Implement #41 (diff) | |
parent | Merge pull request #44 from kytwb/issue-37 (diff) | |
download | ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.tar.gz ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.tar.zst ferdium-app-4ec6e8625e9a1ea995cd1557a06c17ef0b0774bd.zip |
Merge branch 'master' into issue-41
Diffstat (limited to 'src/features/workspaces')
-rw-r--r-- | src/features/workspaces/components/EditWorkspaceForm.js | 24 | ||||
-rw-r--r-- | src/features/workspaces/containers/EditWorkspaceScreen.js | 4 | ||||
-rw-r--r-- | src/features/workspaces/models/Workspace.js | 14 | ||||
-rw-r--r-- | src/features/workspaces/store.js | 4 |
4 files changed, 43 insertions, 3 deletions
diff --git a/src/features/workspaces/components/EditWorkspaceForm.js b/src/features/workspaces/components/EditWorkspaceForm.js index 82ea1b564..b3551a7b9 100644 --- a/src/features/workspaces/components/EditWorkspaceForm.js +++ b/src/features/workspaces/components/EditWorkspaceForm.js | |||
@@ -13,6 +13,10 @@ import { required } from '../../../helpers/validation-helpers'; | |||
13 | import WorkspaceServiceListItem from './WorkspaceServiceListItem'; | 13 | import WorkspaceServiceListItem from './WorkspaceServiceListItem'; |
14 | import Request from '../../../stores/lib/Request'; | 14 | import Request from '../../../stores/lib/Request'; |
15 | 15 | ||
16 | import { KEEP_WS_LOADED_USID } from '../../../config'; | ||
17 | |||
18 | import Toggle from '../../../components/ui/Toggle'; | ||
19 | |||
16 | const messages = defineMessages({ | 20 | const messages = defineMessages({ |
17 | buttonDelete: { | 21 | buttonDelete: { |
18 | id: 'settings.workspace.form.buttonDelete', | 22 | id: 'settings.workspace.form.buttonDelete', |
@@ -30,6 +34,14 @@ const messages = defineMessages({ | |||
30 | id: 'settings.workspace.form.yourWorkspaces', | 34 | id: 'settings.workspace.form.yourWorkspaces', |
31 | defaultMessage: '!!!Your workspaces', | 35 | defaultMessage: '!!!Your workspaces', |
32 | }, | 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 | }, | ||
33 | servicesInWorkspaceHeadline: { | 45 | servicesInWorkspaceHeadline: { |
34 | id: 'settings.workspace.form.servicesInWorkspaceHeadline', | 46 | id: 'settings.workspace.form.servicesInWorkspaceHeadline', |
35 | defaultMessage: '!!!Services in this Workspace', | 47 | defaultMessage: '!!!Services in this Workspace', |
@@ -51,6 +63,9 @@ const styles = () => ({ | |||
51 | serviceList: { | 63 | serviceList: { |
52 | height: 'auto', | 64 | height: 'auto', |
53 | }, | 65 | }, |
66 | keepLoadedInfo: { | ||
67 | marginBottom: '2rem !important', | ||
68 | }, | ||
54 | }); | 69 | }); |
55 | 70 | ||
56 | @injectSheet(styles) @observer | 71 | @injectSheet(styles) @observer |
@@ -88,6 +103,11 @@ class EditWorkspaceForm extends Component { | |||
88 | value: workspace.name, | 103 | value: workspace.name, |
89 | validators: [required], | 104 | validators: [required], |
90 | }, | 105 | }, |
106 | keepLoaded: { | ||
107 | label: intl.formatMessage(messages.keepLoaded), | ||
108 | value: workspace.services.includes(KEEP_WS_LOADED_USID), | ||
109 | default: false, | ||
110 | }, | ||
91 | services: { | 111 | services: { |
92 | value: workspace.services.slice(), | 112 | value: workspace.services.slice(), |
93 | }, | 113 | }, |
@@ -151,6 +171,10 @@ class EditWorkspaceForm extends Component { | |||
151 | <div className="settings__body"> | 171 | <div className="settings__body"> |
152 | <div className={classes.nameInput}> | 172 | <div className={classes.nameInput}> |
153 | <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> | ||
154 | </div> | 178 | </div> |
155 | <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2> | 179 | <h2>{intl.formatMessage(messages.servicesInWorkspaceHeadline)}</h2> |
156 | <div className={classes.serviceList}> | 180 | <div className={classes.serviceList}> |
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/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 @@ | |||
1 | import { observable } from 'mobx'; | 1 | import { observable } from 'mobx'; |
2 | 2 | ||
3 | import { KEEP_WS_LOADED_USID } from '../../../config'; | ||
4 | |||
3 | export default class Workspace { | 5 | export 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 da1582a77..949f8a792 100644 --- a/src/features/workspaces/store.js +++ b/src/features/workspaces/store.js | |||
@@ -17,6 +17,8 @@ import { WORKSPACES_ROUTES } from './index'; | |||
17 | import { createReactions } from '../../stores/lib/Reaction'; | 17 | import { createReactions } from '../../stores/lib/Reaction'; |
18 | import { createActionBindings } from '../utils/ActionBinding'; | 18 | import { createActionBindings } from '../utils/ActionBinding'; |
19 | 19 | ||
20 | import { KEEP_WS_LOADED_USID } from '../../config'; | ||
21 | |||
20 | const debug = require('debug')('Ferdi:feature:workspaces:store'); | 22 | const debug = require('debug')('Ferdi:feature:workspaces:store'); |
21 | 23 | ||
22 | export default class WorkspacesStore extends FeatureStore { | 24 | export default class WorkspacesStore extends FeatureStore { |
@@ -327,7 +329,7 @@ export default class WorkspacesStore extends FeatureStore { | |||
327 | // Loop through all workspaces and remove invalid service ids (locally) | 329 | // Loop through all workspaces and remove invalid service ids (locally) |
328 | this.workspaces.forEach((workspace) => { | 330 | this.workspaces.forEach((workspace) => { |
329 | workspace.services.forEach((serviceId) => { | 331 | workspace.services.forEach((serviceId) => { |
330 | if (servicesHaveBeenLoaded && !services.one(serviceId)) { | 332 | if (servicesHaveBeenLoaded && !services.one(serviceId) && serviceId !== KEEP_WS_LOADED_USID) { |
331 | workspace.services.remove(serviceId); | 333 | workspace.services.remove(serviceId); |
332 | } | 334 | } |
333 | }); | 335 | }); |