mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 16:03:27 +00:00
* fix(frontend): Handle empty error message in toast + hide GridEditorMenu when the component is not visible * fix(frontend): Handle empty error message in toast + hide GridEditorMenu when the component is not visible * fix(frontend): use the right id
62 lines
1.6 KiB
Svelte
62 lines
1.6 KiB
Svelte
<script lang="ts">
|
|
import { getContext } from 'svelte'
|
|
import type { AppEditorContext, AppViewerContext } from '../../types'
|
|
import { deleteGridItem, findComponentSettings } from '../appUtils'
|
|
import { push } from '$lib/history'
|
|
|
|
export let onDelete: (() => void) | undefined = undefined
|
|
export let noGrid = false
|
|
|
|
const {
|
|
app,
|
|
runnableComponents,
|
|
selectedComponent,
|
|
worldStore,
|
|
focusedGrid,
|
|
errorByComponent,
|
|
componentControl
|
|
} = getContext<AppViewerContext>('AppViewerContext')
|
|
|
|
const { history, movingcomponents } = getContext<AppEditorContext>('AppEditorContext')
|
|
|
|
export function removeGridElement() {
|
|
const id = $selectedComponent?.[0]
|
|
const componentSetting = findComponentSettings($app, id)
|
|
push(history, $app)
|
|
|
|
const onDeleteComponentControl = id ? $componentControl[id]?.onDelete : undefined
|
|
if (onDeleteComponentControl) {
|
|
onDeleteComponentControl()
|
|
}
|
|
if (onDelete) {
|
|
onDelete()
|
|
}
|
|
|
|
if (id) {
|
|
delete $worldStore.outputsById[id]
|
|
delete $errorByComponent[id]
|
|
|
|
if ($movingcomponents?.includes(id)) {
|
|
$movingcomponents = $movingcomponents.filter((_id) => _id !== id)
|
|
}
|
|
}
|
|
|
|
$selectedComponent = undefined
|
|
$focusedGrid = undefined
|
|
if (componentSetting?.item && !noGrid) {
|
|
let ids = deleteGridItem($app, componentSetting?.item.data, componentSetting?.parent)
|
|
for (const key of ids) {
|
|
delete $runnableComponents[key]
|
|
}
|
|
}
|
|
|
|
if (componentSetting?.item?.data?.id) {
|
|
delete $runnableComponents[componentSetting?.item?.data?.id]
|
|
}
|
|
$app = $app
|
|
$runnableComponents = $runnableComponents
|
|
|
|
onDelete?.()
|
|
}
|
|
</script>
|