Add recusrive delete warning

This commit is contained in:
Thomas Nordquist
2019-07-23 00:51:26 +02:00
parent 39d87d5a8e
commit f690b3f5a7
2 changed files with 6 additions and 3 deletions

View File

@@ -9,6 +9,8 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
dispatch: Dispatch<any>, dispatch: Dispatch<any>,
getState: () => AppState getState: () => AppState
) => { ) => {
const topicsForPurging = recursive ? [topic, ...topic.childTopics()] : [topic]
if (recursive) { if (recursive) {
const topicCount = topic.childTopicCount() const topicCount = topic.childTopicCount()
@@ -21,7 +23,7 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
const confirmed = await dispatch( const confirmed = await dispatch(
globalActions.requestConfirmation( globalActions.requestConfirmation(
'Confirm delete', '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) { if (!confirmed) {
@@ -36,7 +38,6 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => async
return return
} }
const publishEvent = makePublishEvent(connectionId) const publishEvent = makePublishEvent(connectionId)
const topicsForPurging = recursive ? [topic, ...topic.childTopics()] : [topic]
topicsForPurging topicsForPurging
.filter(t => t.path() !== '' && t.hasMessage()) .filter(t => t.path() !== '' && t.hasMessage())

View File

@@ -42,7 +42,9 @@ function ConfirmationDialog(props: { confirmationRequests: Array<ConfirmationReq
> >
<DialogTitle id="alert-dialog-title">{request.title}</DialogTitle> <DialogTitle id="alert-dialog-title">{request.title}</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText id="alert-dialog-description">{request.inquiry}</DialogContentText> <DialogContentText id="alert-dialog-description" style={{ whiteSpace: 'pre-wrap' }}>
{request.inquiry}
</DialogContentText>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button ref={yesRef as any} variant="contained" onClick={confirm} color="primary" autoFocus> <Button ref={yesRef as any} variant="contained" onClick={confirm} color="primary" autoFocus>