diff options
author | 2017-11-10 15:40:01 +0100 | |
---|---|---|
committer | 2017-11-10 15:40:01 +0100 | |
commit | f39e31af92f3ae6689697685d008f0487a5be351 (patch) | |
tree | c00654dbb28817cbfdca8223c1f86d38c706e163 /src/components/services | |
parent | feat(App): Respect System DoNotDisturb mode for service audio (diff) | |
parent | Merge pull request #248 from meetfranz/feature/192-display-disabled-services (diff) | |
download | ferdium-app-f39e31af92f3ae6689697685d008f0487a5be351.tar.gz ferdium-app-f39e31af92f3ae6689697685d008f0487a5be351.tar.zst ferdium-app-f39e31af92f3ae6689697685d008f0487a5be351.zip |
Merge branch 'develop' into feature/mute-service
# Conflicts:
# src/components/services/content/ServiceWebview.js
# src/components/services/content/Services.js
# src/components/services/tabs/TabItem.js
# src/containers/layout/AppLayoutContainer.js
Diffstat (limited to 'src/components/services')
-rw-r--r-- | src/components/services/content/ServiceDisabled.js | 48 | ||||
-rw-r--r-- | src/components/services/content/ServiceWebview.js | 13 | ||||
-rw-r--r-- | src/components/services/content/Services.js | 9 | ||||
-rw-r--r-- | src/components/services/content/WebviewCrashHandler.js | 2 | ||||
-rw-r--r-- | src/components/services/tabs/TabBarSortableList.js | 3 | ||||
-rw-r--r-- | src/components/services/tabs/TabItem.js | 7 | ||||
-rw-r--r-- | src/components/services/tabs/Tabbar.js | 15 |
7 files changed, 93 insertions, 4 deletions
diff --git a/src/components/services/content/ServiceDisabled.js b/src/components/services/content/ServiceDisabled.js new file mode 100644 index 000000000..732b6c003 --- /dev/null +++ b/src/components/services/content/ServiceDisabled.js | |||
@@ -0,0 +1,48 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer } from 'mobx-react'; | ||
4 | import { defineMessages, intlShape } from 'react-intl'; | ||
5 | |||
6 | import Button from '../../ui/Button'; | ||
7 | |||
8 | const messages = defineMessages({ | ||
9 | headline: { | ||
10 | id: 'service.disabledHandler.headline', | ||
11 | defaultMessage: '!!!{name} is disabled', | ||
12 | }, | ||
13 | action: { | ||
14 | id: 'service.disabledHandler.action', | ||
15 | defaultMessage: '!!!Enable {name}', | ||
16 | }, | ||
17 | }); | ||
18 | |||
19 | @observer | ||
20 | export default class ServiceDisabled extends Component { | ||
21 | static propTypes = { | ||
22 | name: PropTypes.string.isRequired, | ||
23 | enable: PropTypes.func.isRequired, | ||
24 | }; | ||
25 | |||
26 | static contextTypes = { | ||
27 | intl: intlShape, | ||
28 | }; | ||
29 | |||
30 | countdownInterval = null; | ||
31 | countdownIntervalTimeout = 1000; | ||
32 | |||
33 | render() { | ||
34 | const { name, enable } = this.props; | ||
35 | const { intl } = this.context; | ||
36 | |||
37 | return ( | ||
38 | <div className="services__crash-handler"> | ||
39 | <h1>{intl.formatMessage(messages.headline, { name })}</h1> | ||
40 | <Button | ||
41 | label={intl.formatMessage(messages.action, { name })} | ||
42 | buttonType="inverted" | ||
43 | onClick={() => enable()} | ||
44 | /> | ||
45 | </div> | ||
46 | ); | ||
47 | } | ||
48 | } | ||
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index 60bdf7e47..08ba5f33d 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js | |||
@@ -8,6 +8,7 @@ import classnames from 'classnames'; | |||
8 | import ServiceModel from '../../../models/Service'; | 8 | import ServiceModel from '../../../models/Service'; |
9 | import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; | 9 | import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; |
10 | import WebviewCrashHandler from './WebviewCrashHandler'; | 10 | import WebviewCrashHandler from './WebviewCrashHandler'; |
11 | import ServiceDisabled from './ServiceDisabled'; | ||
11 | 12 | ||
12 | @observer | 13 | @observer |
13 | export default class ServiceWebview extends Component { | 14 | export default class ServiceWebview extends Component { |
@@ -15,7 +16,11 @@ export default class ServiceWebview extends Component { | |||
15 | service: PropTypes.instanceOf(ServiceModel).isRequired, | 16 | service: PropTypes.instanceOf(ServiceModel).isRequired, |
16 | setWebviewReference: PropTypes.func.isRequired, | 17 | setWebviewReference: PropTypes.func.isRequired, |
17 | reload: PropTypes.func.isRequired, | 18 | reload: PropTypes.func.isRequired, |
19 | <<<<<<< HEAD | ||
18 | isAppMuted: PropTypes.bool.isRequired, | 20 | isAppMuted: PropTypes.bool.isRequired, |
21 | ======= | ||
22 | enable: PropTypes.func.isRequired, | ||
23 | >>>>>>> develop | ||
19 | }; | 24 | }; |
20 | 25 | ||
21 | static defaultProps = { | 26 | static defaultProps = { |
@@ -58,6 +63,7 @@ export default class ServiceWebview extends Component { | |||
58 | setWebviewReference, | 63 | setWebviewReference, |
59 | reload, | 64 | reload, |
60 | isAppMuted, | 65 | isAppMuted, |
66 | enable, | ||
61 | } = this.props; | 67 | } = this.props; |
62 | 68 | ||
63 | const webviewClasses = classnames({ | 69 | const webviewClasses = classnames({ |
@@ -82,6 +88,13 @@ export default class ServiceWebview extends Component { | |||
82 | reload={reload} | 88 | reload={reload} |
83 | /> | 89 | /> |
84 | )} | 90 | )} |
91 | {!service.isEnabled && ( | ||
92 | <ServiceDisabled | ||
93 | name={service.recipe.name} | ||
94 | webview={service.webview} | ||
95 | enable={enable} | ||
96 | /> | ||
97 | )} | ||
85 | <Webview | 98 | <Webview |
86 | ref={(element) => { this.webview = element; }} | 99 | ref={(element) => { this.webview = element; }} |
87 | autosize | 100 | autosize |
diff --git a/src/components/services/content/Services.js b/src/components/services/content/Services.js index 55a47cdd3..b1322afc2 100644 --- a/src/components/services/content/Services.js +++ b/src/components/services/content/Services.js | |||
@@ -27,6 +27,7 @@ export default class Services extends Component { | |||
27 | openWindow: PropTypes.func.isRequired, | 27 | openWindow: PropTypes.func.isRequired, |
28 | reload: PropTypes.func.isRequired, | 28 | reload: PropTypes.func.isRequired, |
29 | isAppMuted: PropTypes.bool.isRequired, | 29 | isAppMuted: PropTypes.bool.isRequired, |
30 | update: PropTypes.func.isRequired, | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | static defaultProps = { | 33 | static defaultProps = { |
@@ -46,6 +47,7 @@ export default class Services extends Component { | |||
46 | openWindow, | 47 | openWindow, |
47 | reload, | 48 | reload, |
48 | isAppMuted, | 49 | isAppMuted, |
50 | update, | ||
49 | } = this.props; | 51 | } = this.props; |
50 | const { intl } = this.context; | 52 | const { intl } = this.context; |
51 | 53 | ||
@@ -79,6 +81,13 @@ export default class Services extends Component { | |||
79 | openWindow={openWindow} | 81 | openWindow={openWindow} |
80 | reload={() => reload({ serviceId: service.id })} | 82 | reload={() => reload({ serviceId: service.id })} |
81 | isAppMuted={isAppMuted} | 83 | isAppMuted={isAppMuted} |
84 | enable={() => update({ | ||
85 | serviceId: service.id, | ||
86 | serviceData: { | ||
87 | isEnabled: true, | ||
88 | }, | ||
89 | redirect: false, | ||
90 | })} | ||
82 | /> | 91 | /> |
83 | ))} | 92 | ))} |
84 | </div> | 93 | </div> |
diff --git a/src/components/services/content/WebviewCrashHandler.js b/src/components/services/content/WebviewCrashHandler.js index 24903f3c5..d48152c18 100644 --- a/src/components/services/content/WebviewCrashHandler.js +++ b/src/components/services/content/WebviewCrashHandler.js | |||
@@ -25,7 +25,7 @@ const messages = defineMessages({ | |||
25 | }); | 25 | }); |
26 | 26 | ||
27 | @observer | 27 | @observer |
28 | export default class ServiceWebview extends Component { | 28 | export default class WebviewCrashHandler extends Component { |
29 | static propTypes = { | 29 | static propTypes = { |
30 | name: PropTypes.string.isRequired, | 30 | name: PropTypes.string.isRequired, |
31 | reload: PropTypes.func.isRequired, | 31 | reload: PropTypes.func.isRequired, |
diff --git a/src/components/services/tabs/TabBarSortableList.js b/src/components/services/tabs/TabBarSortableList.js index 0146f5b35..2daf55676 100644 --- a/src/components/services/tabs/TabBarSortableList.js +++ b/src/components/services/tabs/TabBarSortableList.js | |||
@@ -16,6 +16,7 @@ class TabBarSortableList extends Component { | |||
16 | toggleAudio: PropTypes.func.isRequired, | 16 | toggleAudio: PropTypes.func.isRequired, |
17 | deleteService: PropTypes.func.isRequired, | 17 | deleteService: PropTypes.func.isRequired, |
18 | disableService: PropTypes.func.isRequired, | 18 | disableService: PropTypes.func.isRequired, |
19 | enableService: PropTypes.func.isRequired, | ||
19 | } | 20 | } |
20 | 21 | ||
21 | render() { | 22 | render() { |
@@ -27,6 +28,7 @@ class TabBarSortableList extends Component { | |||
27 | toggleAudio, | 28 | toggleAudio, |
28 | deleteService, | 29 | deleteService, |
29 | disableService, | 30 | disableService, |
31 | enableService, | ||
30 | openSettings, | 32 | openSettings, |
31 | } = this.props; | 33 | } = this.props; |
32 | 34 | ||
@@ -46,6 +48,7 @@ class TabBarSortableList extends Component { | |||
46 | toggleAudio={() => toggleAudio({ serviceId: service.id })} | 48 | toggleAudio={() => toggleAudio({ serviceId: service.id })} |
47 | deleteService={() => deleteService({ serviceId: service.id })} | 49 | deleteService={() => deleteService({ serviceId: service.id })} |
48 | disableService={() => disableService({ serviceId: service.id })} | 50 | disableService={() => disableService({ serviceId: service.id })} |
51 | enableService={() => enableService({ serviceId: service.id })} | ||
49 | openSettings={openSettings} | 52 | openSettings={openSettings} |
50 | /> | 53 | /> |
51 | ))} | 54 | ))} |
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js index 7b001f6ee..4a37bad57 100644 --- a/src/components/services/tabs/TabItem.js +++ b/src/components/services/tabs/TabItem.js | |||
@@ -40,6 +40,10 @@ const messages = defineMessages({ | |||
40 | id: 'tabs.item.disableService', | 40 | id: 'tabs.item.disableService', |
41 | defaultMessage: '!!!Disable Service', | 41 | defaultMessage: '!!!Disable Service', |
42 | }, | 42 | }, |
43 | enableService: { | ||
44 | id: 'tabs.item.enableService', | ||
45 | defaultMessage: '!!!Enable Service', | ||
46 | }, | ||
43 | deleteService: { | 47 | deleteService: { |
44 | id: 'tabs.item.deleteService', | 48 | id: 'tabs.item.deleteService', |
45 | defaultMessage: '!!!Delete Service', | 49 | defaultMessage: '!!!Delete Service', |
@@ -58,6 +62,7 @@ class TabItem extends Component { | |||
58 | openSettings: PropTypes.func.isRequired, | 62 | openSettings: PropTypes.func.isRequired, |
59 | deleteService: PropTypes.func.isRequired, | 63 | deleteService: PropTypes.func.isRequired, |
60 | disableService: PropTypes.func.isRequired, | 64 | disableService: PropTypes.func.isRequired, |
65 | enableService: PropTypes.func.isRequired, | ||
61 | }; | 66 | }; |
62 | 67 | ||
63 | static contextTypes = { | 68 | static contextTypes = { |
@@ -74,6 +79,7 @@ class TabItem extends Component { | |||
74 | toggleAudio, | 79 | toggleAudio, |
75 | deleteService, | 80 | deleteService, |
76 | disableService, | 81 | disableService, |
82 | enableService, | ||
77 | openSettings, | 83 | openSettings, |
78 | } = this.props; | 84 | } = this.props; |
79 | const { intl } = this.context; | 85 | const { intl } = this.context; |
@@ -121,6 +127,7 @@ class TabItem extends Component { | |||
121 | 'tab-item': true, | 127 | 'tab-item': true, |
122 | 'is-active': service.isActive, | 128 | 'is-active': service.isActive, |
123 | 'has-custom-icon': service.hasCustomIcon, | 129 | 'has-custom-icon': service.hasCustomIcon, |
130 | 'is-disabled': !service.isEnabled, | ||
124 | })} | 131 | })} |
125 | onClick={clickHandler} | 132 | onClick={clickHandler} |
126 | onContextMenu={() => menu.popup(remote.getCurrentWindow())} | 133 | onContextMenu={() => menu.popup(remote.getCurrentWindow())} |
diff --git a/src/components/services/tabs/Tabbar.js b/src/components/services/tabs/Tabbar.js index e8cd80e33..fd4325107 100644 --- a/src/components/services/tabs/Tabbar.js +++ b/src/components/services/tabs/Tabbar.js | |||
@@ -30,20 +30,28 @@ export default class TabBar extends Component { | |||
30 | reorder({ oldIndex, newIndex }); | 30 | reorder({ oldIndex, newIndex }); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | disableService = ({ serviceId }) => { | 33 | toggleService = ({ serviceId, isEnabled }) => { |
34 | const { updateService } = this.props; | 34 | const { updateService } = this.props; |
35 | 35 | ||
36 | if (serviceId) { | 36 | if (serviceId) { |
37 | updateService({ | 37 | updateService({ |
38 | serviceId, | 38 | serviceId, |
39 | serviceData: { | 39 | serviceData: { |
40 | isEnabled: false, | 40 | isEnabled, |
41 | }, | 41 | }, |
42 | redirect: false, | 42 | redirect: false, |
43 | }); | 43 | }); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | disableService({ serviceId }) { | ||
48 | this.toggleService({ serviceId, isEnabled: false }); | ||
49 | } | ||
50 | |||
51 | enableService({ serviceId }) { | ||
52 | this.toggleService({ serviceId, isEnabled: true }); | ||
53 | } | ||
54 | |||
47 | render() { | 55 | render() { |
48 | const { | 56 | const { |
49 | services, | 57 | services, |
@@ -67,7 +75,8 @@ export default class TabBar extends Component { | |||
67 | toggleNotifications={toggleNotifications} | 75 | toggleNotifications={toggleNotifications} |
68 | toggleAudio={toggleAudio} | 76 | toggleAudio={toggleAudio} |
69 | deleteService={deleteService} | 77 | deleteService={deleteService} |
70 | disableService={this.disableService} | 78 | disableService={args => this.disableService(args)} |
79 | enableService={args => this.enableService(args)} | ||
71 | openSettings={openSettings} | 80 | openSettings={openSettings} |
72 | distance={20} | 81 | distance={20} |
73 | axis="y" | 82 | axis="y" |