diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-13 12:29:40 +0200 |
commit | 58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch) | |
tree | 1211600c2a5d3b5f81c435c6896618111a611720 /src/components/services/tabs/Tabbar.js | |
download | ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip |
initial commit
Diffstat (limited to 'src/components/services/tabs/Tabbar.js')
-rw-r--r-- | src/components/services/tabs/Tabbar.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/components/services/tabs/Tabbar.js b/src/components/services/tabs/Tabbar.js new file mode 100644 index 000000000..fdb2c0a59 --- /dev/null +++ b/src/components/services/tabs/Tabbar.js | |||
@@ -0,0 +1,77 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer, PropTypes as MobxPropTypes } from 'mobx-react'; | ||
4 | |||
5 | import TabBarSortableList from './TabBarSortableList'; | ||
6 | |||
7 | @observer | ||
8 | export default class TabBar extends Component { | ||
9 | static propTypes = { | ||
10 | services: MobxPropTypes.arrayOrObservableArray.isRequired, | ||
11 | setActive: PropTypes.func.isRequired, | ||
12 | openSettings: PropTypes.func.isRequired, | ||
13 | enableToolTip: PropTypes.func.isRequired, | ||
14 | disableToolTip: PropTypes.func.isRequired, | ||
15 | reorder: PropTypes.func.isRequired, | ||
16 | reload: PropTypes.func.isRequired, | ||
17 | toggleNotifications: PropTypes.func.isRequired, | ||
18 | deleteService: PropTypes.func.isRequired, | ||
19 | updateService: PropTypes.func.isRequired, | ||
20 | } | ||
21 | |||
22 | onSortEnd = ({ oldIndex, newIndex }) => { | ||
23 | const { | ||
24 | enableToolTip, | ||
25 | reorder, | ||
26 | } = this.props; | ||
27 | |||
28 | enableToolTip(); | ||
29 | reorder({ oldIndex, newIndex }); | ||
30 | }; | ||
31 | |||
32 | disableService = ({ serviceId }) => { | ||
33 | const { updateService } = this.props; | ||
34 | |||
35 | if (serviceId) { | ||
36 | updateService({ | ||
37 | serviceId, | ||
38 | serviceData: { | ||
39 | isEnabled: false, | ||
40 | }, | ||
41 | redirect: false, | ||
42 | }); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | render() { | ||
47 | const { | ||
48 | services, | ||
49 | setActive, | ||
50 | openSettings, | ||
51 | disableToolTip, | ||
52 | reload, | ||
53 | toggleNotifications, | ||
54 | deleteService, | ||
55 | } = this.props; | ||
56 | |||
57 | return ( | ||
58 | <div> | ||
59 | <TabBarSortableList | ||
60 | services={services} | ||
61 | setActive={setActive} | ||
62 | onSortEnd={this.onSortEnd} | ||
63 | onSortStart={disableToolTip} | ||
64 | reload={reload} | ||
65 | toggleNotifications={toggleNotifications} | ||
66 | deleteService={deleteService} | ||
67 | disableService={this.disableService} | ||
68 | openSettings={openSettings} | ||
69 | distance={20} | ||
70 | axis="y" | ||
71 | lockAxis="y" | ||
72 | helperClass="is-reordering" | ||
73 | /> | ||
74 | </div> | ||
75 | ); | ||
76 | } | ||
77 | } | ||