Skip to content

Commit

Permalink
feat(Remove dataset): add warning for when a user removes their own d…
Browse files Browse the repository at this point in the history
…ataset
  • Loading branch information
uhLeeshUh authored Sep 29, 2020
1 parent 493a288 commit 0232823
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// a layout component for the resizable sidebar with main content area
import * as React from 'react'
import { Resizable } from './Resizable'
import NavTopbar from '../components/nav/NavTopBar'
import NavTopbar from '../components/nav/NavTopbar'

interface LayoutProps {
id: string
Expand Down
14 changes: 10 additions & 4 deletions app/components/modals/RemoveDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { connectComponentToProps } from '../../utils/connectComponentToProps'
import { dismissModal } from '../../actions/ui'
import { removeDatasetAndFetch } from '../../actions/api'

import { selectModal } from '../../selections'
import { selectModal, selectSessionUsername } from '../../selections'

import CheckboxInput from '../form/CheckboxInput'
import Modal from './Modal'
Expand All @@ -17,12 +17,13 @@ import Buttons from './Buttons'

interface RemoveDatasetProps {
modal: RemoveDatasetModal
sessionUsername: string
onDismissed: () => void
onSubmit: (username: string, name: string, isLinked: boolean, keepFiles: boolean) => Promise<ApiAction>
}

export const RemoveDatasetComponent: React.FunctionComponent<RemoveDatasetProps> = (props: RemoveDatasetProps) => {
const { modal, onDismissed, onSubmit } = props
const { modal, sessionUsername, onDismissed, onSubmit } = props
const { username, name, fsiPath } = modal

const [keepFiles, setKeepFiles] = React.useState(true)
Expand Down Expand Up @@ -63,7 +64,11 @@ export const RemoveDatasetComponent: React.FunctionComponent<RemoveDatasetProps>
>
<div className='content-wrap'>
<div className='content'>
<div className='content-main'>Are you sure you want to remove <br/> <div className='code-highlight'>{username}/{name}</div>&nbsp;?</div>
<div className='content-main'>
Are you sure you want to remove <br/> <div className='code-highlight'>{username}/{name}</div>&nbsp;?
<br/><br/>
{sessionUsername === username && <div className='warning'>Warning: removing a dataset which belongs to you means you cannot return to that dataset&apos;s history.</div>}
</div>
{ fsiPath &&
<CheckboxInput
name='should-remove-files'
Expand Down Expand Up @@ -95,7 +100,8 @@ export default connectComponentToProps(
(state: any, ownProps: RemoveDatasetProps) => {
return {
...ownProps,
modal: selectModal(state)
modal: selectModal(state),
sessionUsername: selectSessionUsername(state)
}
},
{
Expand Down

0 comments on commit 0232823

Please sign in to comment.