Skip to content

Commit

Permalink
add dialog for confirming deletes
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Feb 5, 2025
1 parent 36ee78c commit 6df2264
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
addTab: (tab: QueryTab) => ({ tab }),
createTab: (query?: string, view?: DataWarehouseSavedQuery) => ({ query, view }),
deleteTab: (tab: QueryTab) => ({ tab }),
_deleteTab: (tab: QueryTab) => ({ tab }),
removeTab: (tab: QueryTab) => ({ tab }),
selectTab: (tab: QueryTab) => ({ tab }),
setLocalState: (key: string, value: any) => ({ key, value }),
Expand Down Expand Up @@ -250,6 +251,21 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
path && actions.setLocalState(activeModelStateKey(props.key), path)
},
deleteTab: ({ tab: tabToRemove }) => {
if (values.queryInput !== '') {
LemonDialog.open({
title: 'Delete query',
description: 'Are you sure you want to delete this query?',
primaryButton: {
children: 'Delete',
status: 'danger',
onClick: () => actions._deleteTab(tabToRemove),
},
})
} else {
actions._deleteTab(tabToRemove)
}
},
_deleteTab: ({ tab: tabToRemove }) => {
if (props.monaco) {
const model = props.monaco.editor.getModel(tabToRemove.uri)
if (tabToRemove.uri.toString() === values.activeModelUri?.uri.toString()) {
Expand Down Expand Up @@ -475,7 +491,7 @@ export const multitabEditorLogic = kea<multitabEditorLogicType>([
deleteDataWarehouseSavedQuerySuccess: ({ payload: viewId }) => {
const tabToRemove = values.allTabs.find((tab) => tab.view?.id === viewId)
if (tabToRemove) {
actions.deleteTab(tabToRemove)
actions._deleteTab(tabToRemove)
}
lemonToast.success('View deleted')
},
Expand Down

0 comments on commit 6df2264

Please sign in to comment.