Move a bunch of git ops to use the git binary (#302)

This commit is contained in:
Gregory Schier
2025-11-17 15:22:39 -08:00
committed by GitHub
parent 84219571e8
commit 9c52652a5e
43 changed files with 1238 additions and 1176 deletions

View File

@@ -0,0 +1,39 @@
import type { DialogProps } from '../components/core/Dialog';
import type { PromptProps } from '../components/core/Prompt';
import { Prompt } from '../components/core/Prompt';
import { showDialog } from './dialog';
type FormArgs = Pick<DialogProps, 'title' | 'description'> &
Omit<PromptProps, 'onClose' | 'onCancel' | 'onResult'> & {
id: string;
};
export async function showPromptForm({ id, title, description, ...props }: FormArgs) {
return new Promise((resolve: PromptProps['onResult']) => {
showDialog({
id,
title,
description,
hideX: true,
size: 'sm',
disableBackdropClose: true, // Prevent accidental dismisses
onClose: () => {
// Click backdrop, close, or escape
resolve(null);
},
render: ({ hide }) =>
Prompt({
onCancel: () => {
// Click cancel button within dialog
resolve(null);
hide();
},
onResult: (v) => {
resolve(v);
hide();
},
...props,
}),
});
});
}

View File

@@ -1,7 +1,13 @@
import type { FormInput, PromptTextRequest } from '@yaakapp-internal/plugins';
import type { ReactNode } from 'react';
import type { DialogProps } from '../components/core/Dialog';
import type { PromptProps } from '../components/core/Prompt';
import { Prompt } from '../components/core/Prompt';
import { showDialog } from './dialog';
import { showPromptForm } from './prompt-form';
type PromptProps = Omit<PromptTextRequest, 'id' | 'title' | 'description'> & {
description?: ReactNode;
onCancel: () => void;
onResult: (value: string | null) => void;
};
type PromptArgs = Pick<DialogProps, 'title' | 'description'> &
Omit<PromptProps, 'onClose' | 'onCancel' | 'onResult'> & { id: string };
@@ -10,35 +16,26 @@ export async function showPrompt({
id,
title,
description,
required = true,
cancelText,
confirmText,
...props
}: PromptArgs) {
return new Promise((resolve: PromptProps['onResult']) => {
showDialog({
id,
title,
description,
hideX: true,
size: 'sm',
disableBackdropClose: true, // Prevent accidental dismisses
onClose: () => {
// Click backdrop, close, or escape
resolve(null);
},
render: ({ hide }) =>
Prompt({
required,
onCancel: () => {
// Click cancel button within dialog
resolve(null);
hide();
},
onResult: (v) => {
resolve(v);
hide();
},
...props,
}),
});
const inputs: FormInput[] = [
{
type: 'text',
name: 'value',
...props,
},
];
const result = await showPromptForm({
id,
title,
description,
inputs,
cancelText,
confirmText,
});
return result?.value ? String(result.value) : null;
}