Skip to content

Commit

Permalink
Add recusrive delete warning
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasnordquist committed Jul 22, 2019
1 parent 39d87d5 commit f690b3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/src/actions/clearTopic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
dispatch: Dispatch<any>,
getState: () => AppState
) => {
const topicsForPurging = recursive ? [topic, ...topic.childTopics()] : [topic]

if (recursive) {
const topicCount = topic.childTopicCount()

Expand All @@ -21,7 +23,7 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
const confirmed = await dispatch(
globalActions.requestConfirmation(
'Confirm delete',
`Do you want to delete "${topic.path()}"${childTopicsMessage}?`
`Do you want to clear "${topic.path()}"${childTopicsMessage}?\n\nThis function will send an empty payload (QoS 0, retain) to this and every subtopic, clearing retained topics in the process. Only use this function if you know what you are doing.`
)
)
if (!confirmed) {
Expand All @@ -36,7 +38,6 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
return
}
const publishEvent = makePublishEvent(connectionId)
const topicsForPurging = recursive ? [topic, ...topic.childTopics()] : [topic]

topicsForPurging
.filter(t => t.path() !== '' && t.hasMessage())
Expand Down
4 changes: 3 additions & 1 deletion app/src/components/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function ConfirmationDialog(props: { confirmationRequests: Array<ConfirmationReq
>
<DialogTitle id="alert-dialog-title">{request.title}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">{request.inquiry}</DialogContentText>
<DialogContentText id="alert-dialog-description" style={{ whiteSpace: 'pre-wrap' }}>
{request.inquiry}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button ref={yesRef as any} variant="contained" onClick={confirm} color="primary" autoFocus>
Expand Down

0 comments on commit f690b3f

Please sign in to comment.