diff --git a/frontend/components/Layout/Layout.js b/frontend/components/Layout/Layout.js index bdb5abe9..92ec84c2 100644 --- a/frontend/components/Layout/Layout.js +++ b/frontend/components/Layout/Layout.js @@ -75,11 +75,11 @@ type Props = { } handleCreateCollection = () => { - this.props.ui.setActiveModal('create-collection'); + this.props.ui.setActiveModal('collection-new'); }; handleEditCollection = () => { - this.props.ui.setActiveModal('edit-collection'); + this.props.ui.setActiveModal('collection-edit'); }; render() { diff --git a/frontend/components/Layout/components/Modals.js b/frontend/components/Layout/components/Modals.js index 96ef4430..43e2c4da 100644 --- a/frontend/components/Layout/components/Modals.js +++ b/frontend/components/Layout/components/Modals.js @@ -5,6 +5,8 @@ import Modal from 'components/Modal'; import UiStore from 'stores/UiStore'; import CollectionNew from 'scenes/CollectionNew'; import CollectionEdit from 'scenes/CollectionEdit'; +import CollectionDelete from 'scenes/CollectionDelete'; +import DocumentDelete from 'scenes/DocumentDelete'; import KeyboardShortcuts from 'scenes/KeyboardShortcuts'; import Settings from 'scenes/Settings'; @@ -23,19 +25,33 @@ import Settings from 'scenes/Settings'; return ( + + + + + + { const { collection } = this.props; - this.props.ui.setActiveModal('edit-collection', { collection }); + this.props.ui.setActiveModal('collection-edit', { collection }); }; onDelete = () => { const { collection } = this.props; - this.props.ui.setActiveModal('delete-collection', { collection }); + this.props.ui.setActiveModal('collection-delete', { collection }); }; render() { diff --git a/frontend/menus/DocumentMenu.js b/frontend/menus/DocumentMenu.js index 1dc9d9b9..e87ebc00 100644 --- a/frontend/menus/DocumentMenu.js +++ b/frontend/menus/DocumentMenu.js @@ -25,7 +25,7 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu'; onDelete = () => { const { document } = this.props; - this.props.ui.setActiveModal('delete-document', { document }); + this.props.ui.setActiveModal('document-delete', { document }); }; onExport = () => { diff --git a/frontend/scenes/CollectionDelete/CollectionDelete.js b/frontend/scenes/CollectionDelete/CollectionDelete.js new file mode 100644 index 00000000..e3066cb9 --- /dev/null +++ b/frontend/scenes/CollectionDelete/CollectionDelete.js @@ -0,0 +1,60 @@ +// @flow +import React, { Component } from 'react'; +import { observable } from 'mobx'; +import { observer } from 'mobx-react'; +import { homeUrl } from 'utils/routeHelpers'; +import Button from 'components/Button'; +import Flex from 'components/Flex'; +import HelpText from 'components/HelpText'; +import Collection from 'models/Collection'; +import CollectionsStore from 'stores/CollectionsStore'; + +type Props = { + history: Object, + collection: Collection, + collections: CollectionsStore, + onSubmit: () => void, +}; + +@observer class CollectionDelete extends Component { + props: Props; + @observable isDeleting: boolean; + + handleSubmit = async (ev: SyntheticEvent) => { + ev.preventDefault(); + this.isDeleting = true; + const success = await this.props.collection.delete(); + + if (success) { + this.props.collections.remove(this.props.collection.id); + this.props.history.push(homeUrl()); + this.props.onSubmit(); + } + + this.isDeleting = false; + }; + + render() { + const { collection } = this.props; + + return ( + +
+ + Are you sure? Deleting the + {' '} + {collection.name} + {' '} + collection is permanant and will also delete all of the documents within + it, so be careful with that. + + +
+
+ ); + } +} + +export default CollectionDelete; diff --git a/frontend/scenes/CollectionDelete/index.js b/frontend/scenes/CollectionDelete/index.js new file mode 100644 index 00000000..e86f5889 --- /dev/null +++ b/frontend/scenes/CollectionDelete/index.js @@ -0,0 +1,3 @@ +// @flow +import CollectionDelete from './CollectionDelete'; +export default CollectionDelete; diff --git a/frontend/scenes/CollectionEdit/CollectionEdit.js b/frontend/scenes/CollectionEdit/CollectionEdit.js index e3718808..249a1eb0 100644 --- a/frontend/scenes/CollectionEdit/CollectionEdit.js +++ b/frontend/scenes/CollectionEdit/CollectionEdit.js @@ -2,7 +2,6 @@ import React, { Component } from 'react'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; -import { homeUrl } from 'utils/routeHelpers'; import Button from 'components/Button'; import Input from 'components/Input'; import Flex from 'components/Flex'; @@ -20,8 +19,6 @@ type Props = { @observer class CollectionEdit extends Component { props: Props; @observable name: string; - @observable isConfirming: boolean; - @observable isDeleting: boolean; @observable isSaving: boolean; componentWillMount() { @@ -46,34 +43,12 @@ type Props = { this.name = ev.target.value; }; - confirmDelete = () => { - this.isConfirming = true; - }; - - cancelDelete = () => { - this.isConfirming = false; - }; - - confirmedDelete = async (ev: SyntheticEvent) => { - ev.preventDefault(); - this.isDeleting = true; - const success = await this.props.collection.delete(); - - if (success) { - this.props.collections.remove(this.props.collection.id); - this.props.history.push(homeUrl()); - this.props.onSubmit(); - } - - this.isDeleting = false; - }; - render() { return (
- You can edit a collection name at any time, but doing so might + You can edit a collections name at any time, however doing so might confuse your team mates.
-
-
- - Deleting a collection will also delete all of the documents within - it, so be careful with that. - - {!this.isConfirming && - } - {this.isConfirming && - - - - } -
); } diff --git a/frontend/scenes/DocumentDelete/DocumentDelete.js b/frontend/scenes/DocumentDelete/DocumentDelete.js new file mode 100644 index 00000000..a37dd777 --- /dev/null +++ b/frontend/scenes/DocumentDelete/DocumentDelete.js @@ -0,0 +1,59 @@ +// @flow +import React, { Component } from 'react'; +import { observable } from 'mobx'; +import { observer } from 'mobx-react'; +import { homeUrl } from 'utils/routeHelpers'; +import Button from 'components/Button'; +import Flex from 'components/Flex'; +import HelpText from 'components/HelpText'; +import Document from 'models/Document'; +import DocumentsStore from 'stores/DocumentsStore'; + +type Props = { + history: Object, + document: Document, + documents: DocumentsStore, + onSubmit: () => void, +}; + +@observer class DocumentDelete extends Component { + props: Props; + @observable isDeleting: boolean; + + handleSubmit = async (ev: SyntheticEvent) => { + ev.preventDefault(); + this.isDeleting = true; + const success = await this.props.document.delete(); + + if (success) { + this.props.documents.remove(this.props.document.id); + this.props.history.push(homeUrl()); + this.props.onSubmit(); + } + + this.isDeleting = false; + }; + + render() { + const { document } = this.props; + + return ( + +
+ + Are you sure? Deleting the + {' '} + {document.title} + {' '} + document is permanant and will also delete all of its history. + + +
+
+ ); + } +} + +export default DocumentDelete; diff --git a/frontend/scenes/DocumentDelete/index.js b/frontend/scenes/DocumentDelete/index.js new file mode 100644 index 00000000..90e2e111 --- /dev/null +++ b/frontend/scenes/DocumentDelete/index.js @@ -0,0 +1,3 @@ +// @flow +import DocumentDelete from './DocumentDelete'; +export default DocumentDelete;