mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 08:11:24 +02:00
Improved prompt function add add ctx.* functions (#301)
This commit is contained in:
@@ -6,7 +6,13 @@ import { showDialog } from './dialog';
|
||||
type PromptArgs = Pick<DialogProps, 'title' | 'description'> &
|
||||
Omit<PromptProps, 'onClose' | 'onCancel' | 'onResult'> & { id: string };
|
||||
|
||||
export async function showPrompt({ id, title, description, ...props }: PromptArgs) {
|
||||
export async function showPrompt({
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
required = true,
|
||||
...props
|
||||
}: PromptArgs) {
|
||||
return new Promise((resolve: PromptProps['onResult']) => {
|
||||
showDialog({
|
||||
id,
|
||||
@@ -21,6 +27,7 @@ export async function showPrompt({ id, title, description, ...props }: PromptArg
|
||||
},
|
||||
render: ({ hide }) =>
|
||||
Prompt({
|
||||
required,
|
||||
onCancel: () => {
|
||||
// Click cancel button within dialog
|
||||
resolve(null);
|
||||
|
||||
@@ -11,6 +11,7 @@ export async function renameModelWithPrompt(model: Extract<AnyModel, { name: str
|
||||
const name = await showPrompt({
|
||||
id: 'rename-request',
|
||||
title: 'Rename Request',
|
||||
required: false,
|
||||
description:
|
||||
model.name === '' ? (
|
||||
'Enter a new name'
|
||||
|
||||
@@ -20,7 +20,13 @@ export function setWorkspaceSearchParams(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
search: (prev: any) => {
|
||||
// console.log('Navigating to', { prev, search });
|
||||
return { ...prev, ...search };
|
||||
const o = { ...prev, ...search };
|
||||
for (const k of Object.keys(o)) {
|
||||
if (o[k] == null) {
|
||||
delete o[k];
|
||||
}
|
||||
}
|
||||
return o;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user