mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { useEffect } from "react";
|
|
import { useSettings } from "@termix/plugin-sdk/frontend";
|
|
import { SnippetVariablesDialog } from "./SnippetVariablesDialog";
|
|
import { readSnippetSettings } from "./settings";
|
|
import { setConfirmExecution, usePendingPrompt } from "./prompt-store";
|
|
|
|
/**
|
|
* Always mounted at the shell's root (the shell.overlay slot), so a snippet
|
|
* started from the command palette, a keybinding or a host button can ask
|
|
* for its inputs after whatever started it has closed.
|
|
*/
|
|
export function SnippetOverlay() {
|
|
const settings = useSettings("user");
|
|
const prompt = usePendingPrompt();
|
|
const confirmExecution = readSnippetSettings(
|
|
settings.values,
|
|
).confirmExecution;
|
|
|
|
useEffect(() => {
|
|
setConfirmExecution(confirmExecution);
|
|
}, [confirmExecution]);
|
|
|
|
if (!prompt) return null;
|
|
return (
|
|
<SnippetVariablesDialog
|
|
snippet={prompt.snippet}
|
|
host={prompt.host}
|
|
onCancel={() => prompt.settle(null)}
|
|
onConfirm={(_resolved, values) => prompt.settle(values)}
|
|
/>
|
|
);
|
|
}
|