diff --git a/src/components/common/ConceptContainerVersionList.jsx b/src/components/common/ConceptContainerVersionList.jsx index 868e4474..5e2fb48a 100644 --- a/src/components/common/ConceptContainerVersionList.jsx +++ b/src/components/common/ConceptContainerVersionList.jsx @@ -45,7 +45,7 @@ const ConceptContainerVersionList = ({ versions, resource, canEdit }) => { } const onEditCancel = () => setVersionForm(false); const onDeleteClick = version => { - const title = `Delete Version : ${version.short_code} [${version.id}]`; + const title = `Delete Source Version : ${version.short_code} [${version.id}]`; const message = `Are you sure you want to permanently delete this source version ${version.id}? This action cannot be undone! This will delete the version and all of its details. Concepts and mappings in this source version will not be affected.` const confirm = alertifyjs.confirm() diff --git a/src/components/sources/SourceHomeHeader.jsx b/src/components/sources/SourceHomeHeader.jsx index d4889873..9abb6c50 100644 --- a/src/components/sources/SourceHomeHeader.jsx +++ b/src/components/sources/SourceHomeHeader.jsx @@ -1,8 +1,10 @@ import React from 'react'; +import alertifyjs from 'alertifyjs'; import { List as ListIcon, FileCopy as CopyIcon, - Edit as EditIcon + Edit as EditIcon, + Delete as DeleteIcon, } from '@material-ui/icons'; import { Tooltip, IconButton, ButtonGroup, Button } from '@material-ui/core'; import { includes, isEmpty, keys, map, startCase, get } from 'lodash'; @@ -52,6 +54,25 @@ const SourceHomeHeader = ({ }) } + const deleteSource = () => { + APIService.new().overrideURL(source.url).delete().then(response => { + if(get(response, 'status') === 204) + alertifyjs.success('Source Deleted', 1, () => window.location.hash = source.owner_url) + else + alertifyjs.error('Something bad happened!') + }) + } + + const onDelete = () => { + const title = `Delete Source : ${source.short_code}`; + const message = `Are you sure you want to permanently delete this source ${source.short_code}? This action cannot be undone! This action cannot be undone! This will delete the entire source and all of its associated versions, concepts and mappings.` + const confirm = alertifyjs.confirm() + confirm.setHeader(title); + confirm.setMessage(message); + confirm.set('onok', deleteSource); + confirm.show(); + } + return (
@@ -86,6 +107,11 @@ const SourceHomeHeader = ({ + + + } @@ -174,7 +200,7 @@ const SourceHomeHeader = ({ onClose={() => setSourceForm(false)} formComponent={ isVersionedObject && - setSourceForm(false)} source={source} parentURL={versionedObjectURL} /> + setSourceForm(false)} source={source} parentURL={versionedObjectURL} /> } />