aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/settings/services/ServiceItem.js
blob: 20d8581d055b18d6652a1e2aeffffdb13d053ae6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, intlShape } from 'react-intl';
import ReactTooltip from 'react-tooltip';
import { observer } from 'mobx-react';
import classnames from 'classnames';

import ServiceModel from '../../../models/Service';

const messages = defineMessages({
  tooltipIsDisabled: {
    id: 'settings.services.tooltip.isDisabled',
    defaultMessage: '!!!Service is disabled',
  },
  tooltipNotificationsDisabled: {
    id: 'settings.services.tooltip.notificationsDisabled',
    defaultMessage: '!!!Notifications are disabled',
  },
});

@observer
export default class ServiceItem extends Component {
  static propTypes = {
    service: PropTypes.instanceOf(ServiceModel).isRequired,
    goToServiceForm: PropTypes.func.isRequired,
  };
  static contextTypes = {
    intl: intlShape,
  };

  render() {
    const {
      service,
      // toggleAction,
      goToServiceForm,
    } = this.props;
    const { intl } = this.context;

    return (
      <tr
        className={classnames({
          'service-table__row': true,
          'service-table__row--disabled': !service.isEnabled,
        })}
      >
        <td
          className="service-table__column-icon"
          onClick={goToServiceForm}
        >
          <img
            src={service.icon}
            className={classnames({
              'service-table__icon': true,
              'has-custom-icon': service.hasCustomIcon,
            })}
            alt=""
          />
        </td>
        <td
          className="service-table__column-name"
          onClick={goToServiceForm}
        >
          {service.name !== '' ? service.name : service.recipe.name}
        </td>
        <td
          className="service-table__column-info"
          onClick={goToServiceForm}
        >
          {!service.isEnabled && (
            <span
              className="mdi mdi-power"
              data-tip={intl.formatMessage(messages.tooltipIsDisabled)}
            />
          )}
        </td>
        <td
          className="service-table__column-info"
          onClick={goToServiceForm}
        >
          {!service.isNotificationEnabled && (
            <span
              className="mdi mdi-message-bulleted-off"
              data-tip={intl.formatMessage(messages.tooltipNotificationsDisabled)}
            />
          )}
          <ReactTooltip place="top" type="dark" effect="solid" />
        </td>
        {/* <td className="service-table__column-action">
          <input
            type="checkbox"
            onChange={toggleAction}
            checked={service.isEnabled}
          />
        </td> */}
      </tr>
    );
  }
}