diff options
author | 2017-11-05 23:31:21 +0100 | |
---|---|---|
committer | 2017-11-05 23:31:21 +0100 | |
commit | 84bff14bf649969b3729b2c751b423d33e508f0b (patch) | |
tree | a585b92b88fa10998a7100b78152b2a18f388968 /src/components/services/tabs/TabBarSortableList.js | |
parent | Merge pull request #213 from alecive/master (diff) | |
parent | bump version to beta 12 (diff) | |
download | ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.tar.gz ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.tar.zst ferdium-app-84bff14bf649969b3729b2c751b423d33e508f0b.zip |
Merge pull request #217 from meetfranz/developv5.0.0-beta.125.0.0-beta.12
Beta 12
Diffstat (limited to 'src/components/services/tabs/TabBarSortableList.js')
-rw-r--r-- | src/components/services/tabs/TabBarSortableList.js | 110 |
1 files changed, 72 insertions, 38 deletions
diff --git a/src/components/services/tabs/TabBarSortableList.js b/src/components/services/tabs/TabBarSortableList.js index c0a68d1a5..e5ae36419 100644 --- a/src/components/services/tabs/TabBarSortableList.js +++ b/src/components/services/tabs/TabBarSortableList.js | |||
@@ -1,44 +1,78 @@ | |||
1 | import React from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import { observer } from 'mobx-react'; | 2 | import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; |
3 | import PropTypes from 'prop-types'; | ||
3 | import { SortableContainer } from 'react-sortable-hoc'; | 4 | import { SortableContainer } from 'react-sortable-hoc'; |
5 | import { defineMessages, intlShape } from 'react-intl'; | ||
4 | 6 | ||
5 | import TabItem from './TabItem'; | 7 | import TabItem from './TabItem'; |
6 | import { ctrlKey } from '../../../environment'; | 8 | import { ctrlKey } from '../../../environment'; |
7 | 9 | ||
8 | export default SortableContainer(observer(({ | 10 | const messages = defineMessages({ |
9 | services, | 11 | addNewService: { |
10 | setActive, | 12 | id: 'sidebar.addNewService', |
11 | reload, | 13 | defaultMessage: '!!!Add new service', |
12 | toggleNotifications, | 14 | }, |
13 | deleteService, | 15 | }); |
14 | disableService, | 16 | |
15 | openSettings, | 17 | @observer |
16 | }) => ( | 18 | class TabBarSortableList extends Component { |
17 | <ul | 19 | static propTypes = { |
18 | className="tabs" | 20 | services: MobxPropTypes.arrayOrObservableArray.isRequired, |
19 | > | 21 | setActive: PropTypes.func.isRequired, |
20 | {services.map((service, index) => ( | 22 | openSettings: PropTypes.func.isRequired, |
21 | <TabItem | 23 | reload: PropTypes.func.isRequired, |
22 | key={service.id} | 24 | toggleNotifications: PropTypes.func.isRequired, |
23 | clickHandler={() => setActive({ serviceId: service.id })} | 25 | deleteService: PropTypes.func.isRequired, |
24 | service={service} | 26 | disableService: PropTypes.func.isRequired, |
25 | index={index} | 27 | } |
26 | shortcutIndex={index + 1} | 28 | |
27 | reload={() => reload({ serviceId: service.id })} | 29 | static contextTypes = { |
28 | toggleNotifications={() => toggleNotifications({ serviceId: service.id })} | 30 | intl: intlShape, |
29 | deleteService={() => deleteService({ serviceId: service.id })} | 31 | }; |
30 | disableService={() => disableService({ serviceId: service.id })} | 32 | |
31 | openSettings={openSettings} | 33 | render() { |
32 | /> | 34 | const { |
33 | ))} | 35 | services, |
34 | <li> | 36 | setActive, |
35 | <button | 37 | reload, |
36 | className="sidebar__add-service" | 38 | toggleNotifications, |
37 | onClick={() => openSettings({ path: 'recipes' })} | 39 | deleteService, |
38 | data-tip={`Add new service (${ctrlKey}+N)`} | 40 | disableService, |
41 | openSettings, | ||
42 | } = this.props; | ||
43 | |||
44 | const { intl } = this.context; | ||
45 | |||
46 | return ( | ||
47 | <ul | ||
48 | className="tabs" | ||
39 | > | 49 | > |
40 | <span className="mdi mdi-plus" /> | 50 | {services.map((service, index) => ( |
41 | </button> | 51 | <TabItem |
42 | </li> | 52 | key={service.id} |
43 | </ul> | 53 | clickHandler={() => setActive({ serviceId: service.id })} |
44 | ))); | 54 | service={service} |
55 | index={index} | ||
56 | shortcutIndex={index + 1} | ||
57 | reload={() => reload({ serviceId: service.id })} | ||
58 | toggleNotifications={() => toggleNotifications({ serviceId: service.id })} | ||
59 | deleteService={() => deleteService({ serviceId: service.id })} | ||
60 | disableService={() => disableService({ serviceId: service.id })} | ||
61 | openSettings={openSettings} | ||
62 | /> | ||
63 | ))} | ||
64 | <li> | ||
65 | <button | ||
66 | className="sidebar__add-service" | ||
67 | onClick={() => openSettings({ path: 'recipes' })} | ||
68 | data-tip={`${intl.formatMessage(messages.addNewService)} (${ctrlKey}+N)`} | ||
69 | > | ||
70 | <span className="mdi mdi-plus" /> | ||
71 | </button> | ||
72 | </li> | ||
73 | </ul> | ||
74 | ); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | export default SortableContainer(TabBarSortableList); | ||