blob: 1b13bc2d4051be04720b3876eb2fd4b47dc2654a (
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
|
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import PropTypes from 'prop-types';
import ErrorBoundary from '../../../components/util/ErrorBoundary';
import EditWorkspaceForm from '../components/EditWorkspaceForm';
import { workspacesState } from '../state';
import ServicesStore from '../../../stores/ServicesStore';
import Workspace from '../models/Workspace';
@inject('stores', 'actions') @observer
class EditWorkspaceScreen extends Component {
static propTypes = {
actions: PropTypes.shape({
workspace: PropTypes.shape({
delete: PropTypes.func.isRequired,
}),
}).isRequired,
stores: PropTypes.shape({
services: PropTypes.instanceOf(ServicesStore).isRequired,
}).isRequired,
};
onDelete = () => {
const { workspaceBeingEdited } = workspacesState;
const { actions } = this.props;
if (!workspaceBeingEdited) return null;
actions.workspaces.delete({ workspace: workspaceBeingEdited });
};
onSave = (values) => {
const { workspaceBeingEdited } = workspacesState;
const { actions } = this.props;
const workspace = new Workspace(
Object.assign({}, workspaceBeingEdited, values),
);
actions.workspaces.update({ workspace });
};
render() {
const { workspaceBeingEdited } = workspacesState;
const { stores } = this.props;
if (!workspaceBeingEdited) return null;
return (
<ErrorBoundary>
<EditWorkspaceForm
workspace={workspaceBeingEdited}
services={stores.services.all}
onDelete={this.onDelete}
onSave={this.onSave}
isDeleting={false}
isSaving={false}
/>
</ErrorBoundary>
);
}
}
export default EditWorkspaceScreen;
|