Skip to content

Commit

Permalink
source delete
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jan 14, 2021
1 parent f1e4966 commit 3070260
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/common/ConceptContainerVersionList.jsx
Expand Up @@ -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()
Expand Down
30 changes: 28 additions & 2 deletions 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';
Expand Down Expand Up @@ -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 (
<header className='home-header col-md-12'>
<div className='col-md-12 container' style={{paddingTop: '10px'}}>
Expand Down Expand Up @@ -86,6 +107,11 @@ const SourceHomeHeader = ({
<EditIcon fontSize='inherit' />
</Button>
</Tooltip>
<Tooltip title='Delete Source'>
<Button onClick={onDelete}>
<DeleteIcon fontSize='inherit' />
</Button>
</Tooltip>
</ButtonGroup>
</span>
}
Expand Down Expand Up @@ -174,7 +200,7 @@ const SourceHomeHeader = ({
onClose={() => setSourceForm(false)}
formComponent={
isVersionedObject &&
<SourceForm edit reloadOnSuccess onCancel={() => setSourceForm(false)} source={source} parentURL={versionedObjectURL} />
<SourceForm edit reloadOnSuccess onCancel={() => setSourceForm(false)} source={source} parentURL={versionedObjectURL} />
}
/>
</header>
Expand Down

0 comments on commit 3070260

Please sign in to comment.