aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/containers/TodosScreen.js
blob: 536810d2d053c47d4a069c4621fa5d4058bba8ea (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
import { Component } from 'react';
import { observer, inject } from 'mobx-react';
import PropTypes from 'prop-types';

import FeaturesStore from '../../../stores/FeaturesStore';
import TodosWebview from '../components/TodosWebview';
import ErrorBoundary from '../../../components/util/ErrorBoundary';
import { todosStore } from '..';
import { TODOS_MIN_WIDTH } from '../../../config';
import { todoActions } from '../actions';
import ServicesStore from '../../../stores/ServicesStore';

@inject('stores', 'actions')
@observer
class TodosScreen extends Component {
  render() {
    if (
      !todosStore ||
      !todosStore.isFeatureActive ||
      todosStore.isTodosPanelForceHidden
    ) {
      return null;
    }

    return (
      <ErrorBoundary>
        <TodosWebview
          isTodosServiceActive={
            this.props.stores.services.isTodosServiceActive || false
          }
          isVisible={todosStore.isTodosPanelVisible}
          togglePanel={todoActions.toggleTodosPanel}
          handleClientMessage={todoActions.handleClientMessage}
          setTodosWebview={webview => todoActions.setTodosWebview({ webview })}
          width={todosStore.width}
          minWidth={TODOS_MIN_WIDTH}
          resize={width => todoActions.resize({ width })}
          userAgent={todosStore.userAgent}
          todoUrl={todosStore.todoUrl}
          isTodoUrlValid={todosStore.isTodoUrlValid}
        />
      </ErrorBoundary>
    );
  }
}

export default TodosScreen;

TodosScreen.wrappedComponent.propTypes = {
  stores: PropTypes.shape({
    features: PropTypes.instanceOf(FeaturesStore).isRequired,
    services: PropTypes.instanceOf(ServicesStore).isRequired,
  }).isRequired,
};