Skip to content

Commit

Permalink
Fix to ensure events are ignored when the viewport isnt initialised. …
Browse files Browse the repository at this point in the history
…Add a delete confirmation for branches
  • Loading branch information
deanhannigan committed Oct 31, 2024
1 parent 30a3013 commit 79970ae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@
// Optimization options
const onViewMouseMove = async e => {
if (!viewPort) {
return
}
const { x, y } = eleXY(e, viewPort)
internalPos.update(() => ({
Expand All @@ -225,25 +229,6 @@
y: y - dragOffset[1],
}))
}
// Needs to handle when the mouse leaves the screen
// Needs to know the direction of movement and accelerate/decelerate
if (y < (viewDims.height / 100) * 20 && $view.dragging) {
// if (!scrollInterval) {
// scrollInterval = setInterval(() => {
// contentPos.update(state => ({
// ...state,
// x: contentPos.x,
// y: contentPos.y + 35,
// }))
// }, 100)
// }
// } else {
// if (scrollInterval) {
// clearInterval(scrollInterval)
// scrollInterval = undefined
// }
}
}
const onViewDragEnd = () => {
Expand Down Expand Up @@ -288,6 +273,9 @@
}
const onMouseMove = async e => {
if (!viewPort) {
return
}
// Update viewDims to get the latest viewport dimensions
viewDims = viewPort.getBoundingClientRect()
Expand Down Expand Up @@ -345,7 +333,7 @@
}
const onMoveContent = e => {
if (down) {
if (down || !viewPort) {
return
}
const { x, y } = eleXY(e, viewPort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
TooltipPosition,
TooltipType,
Button,
Modal,
ModalContent,
} from "@budibase/bbui"
import PropField from "components/automation/SetupPanel/PropField.svelte"
import AutomationBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
Expand All @@ -36,6 +38,7 @@
let drawer
let condition
let open = true
let confirmDeleteModal
$: branch = step.inputs?.branches?.[branchIdx]
$: editableConditionUI = cloneDeep(branch.conditionUI || {})
Expand All @@ -55,6 +58,22 @@
}
</script>

<Modal bind:this={confirmDeleteModal}>
<ModalContent
size="M"
title={"Are you sure you want to delete?"}
confirmText="Delete"
onConfirm={async () => {
await automationStore.actions.deleteBranch(
branchBlockRef.pathTo,
$selectedAutomation.data
)
}}
>
<Body>By deleting this branch, you will delete all of its contents.</Body>
</ModalContent>
</Modal>

<Drawer bind:this={drawer} title="Branch condition" forceModal>
<Button
cta
Expand Down Expand Up @@ -101,10 +120,15 @@
itemName={branch.name}
block={step}
deleteStep={async () => {
await automationStore.actions.deleteBranch(
branchBlockRef.pathTo,
$selectedAutomation.data
)
const branchSteps = step.inputs?.children[branch.id]
if (branchSteps.length) {
confirmDeleteModal.show()
} else {
await automationStore.actions.deleteBranch(
branchBlockRef.pathTo,
$selectedAutomation.data
)
}
}}
on:update={async e => {
let stepUpdate = cloneDeep(step)
Expand Down

0 comments on commit 79970ae

Please sign in to comment.