aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/workspaces/containers/EditWorkspaceScreen.js
blob: 1ddf8dfcb48d832a59a6c804b2e3148bcc239ecd (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
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import PropTypes from 'prop-types';

import ErrorBoundary from '../../../components/util/ErrorBoundary';
import { state } from '../state';
import EditWorkspaceForm from '../components/EditWorkspaceForm';

@inject('stores', 'actions') @observer
class EditWorkspaceScreen extends Component {
  static propTypes = {
    actions: PropTypes.shape({
      workspace: PropTypes.shape({
        delete: PropTypes.func.isRequired,
      }),
    }).isRequired,
  };

  onDelete = () => {
    const { workspaceBeingEdited } = state;
    const { actions } = this.props;
    if (!workspaceBeingEdited) return null;
    actions.workspace.delete({ workspace: workspaceBeingEdited });
  };

  onSave = (values) => {
    console.log('save workspace', values);
  };

  render() {
    const { workspaceBeingEdited } = state;
    if (!workspaceBeingEdited) return null;
    return (
      <ErrorBoundary>
        <EditWorkspaceForm
          workspace={workspaceBeingEdited}
          onDelete={this.onDelete}
          onSave={this.onSave}
          isDeleting={false}
          isSaving={false}
        />
      </ErrorBoundary>
    );
  }
}

export default EditWorkspaceScreen;