mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 01:08:28 +02:00
Fix model deletion
This commit is contained in:
@@ -174,15 +174,12 @@ const BaseInput = forwardRef<EditorView, InputProps>(function InputBase(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const isValid = useMemo(() => {
|
const isValid = useMemo(() => {
|
||||||
console.log('CHECKING VALIDITY', validate);
|
|
||||||
if (required && !validateRequire(defaultValue ?? '')) return false;
|
if (required && !validateRequire(defaultValue ?? '')) return false;
|
||||||
if (typeof validate === 'boolean') return validate;
|
if (typeof validate === 'boolean') return validate;
|
||||||
if (typeof validate === 'function' && !validate(defaultValue ?? '')) return false;
|
if (typeof validate === 'function' && !validate(defaultValue ?? '')) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [required, defaultValue, validate]);
|
}, [required, defaultValue, validate]);
|
||||||
|
|
||||||
console.log('IS VALID', isValid, defaultValue);
|
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
onChange?.(value);
|
onChange?.(value);
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { duplicateModelById, getModel, workspacesAtom } from '@yaakapp-internal/models';
|
||||||
deleteModelById,
|
|
||||||
duplicateModelById,
|
|
||||||
getModel,
|
|
||||||
workspacesAtom,
|
|
||||||
} from '@yaakapp-internal/models';
|
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useCreateDropdownItems } from '../../hooks/useCreateDropdownItems';
|
import { useCreateDropdownItems } from '../../hooks/useCreateDropdownItems';
|
||||||
@@ -134,7 +129,9 @@ export function SidebarItemContextMenu({ child, show, close }: Props) {
|
|||||||
hotKeyAction: 'sidebar.delete_selected_item',
|
hotKeyAction: 'sidebar.delete_selected_item',
|
||||||
hotKeyLabelOnly: true,
|
hotKeyLabelOnly: true,
|
||||||
leftSlot: <Icon icon="trash" />,
|
leftSlot: <Icon icon="trash" />,
|
||||||
onSelect: async () => deleteModelById(child.model, child.id),
|
onSelect: async () => {
|
||||||
|
await deleteModelWithConfirm(getModel(child.model, child.id));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function deleteModelWithConfirm(model: AnyModel | null): Promise<bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
const confirmed = await showConfirmDelete({
|
const confirmed = await showConfirmDelete({
|
||||||
id: 'delete-model-' + model.model,
|
id: 'delete-model-' + model.id,
|
||||||
title: 'Delete ' + modelTypeLabel(model),
|
title: 'Delete ' + modelTypeLabel(model),
|
||||||
description: (
|
description: (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user