mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
137 lines
4.1 KiB
TypeScript
137 lines
4.1 KiB
TypeScript
import type { FileItem, SSHHost } from "./host-types";
|
|
import {
|
|
TOTPDialog,
|
|
SSHAuthDialog,
|
|
BrowserSignInDialog,
|
|
} from "@termix/plugin-sdk/ui";
|
|
import { PermissionsDialog } from "./components/PermissionsDialog.tsx";
|
|
import { CompressDialog } from "./components/CompressDialog.tsx";
|
|
import { SudoPasswordDialog } from "./SudoPasswordDialog.tsx";
|
|
import type { PendingSudoOperation } from "./file-manager-types.ts";
|
|
|
|
type FileManagerDialogsProps = {
|
|
compressDialogFiles: FileItem[];
|
|
setCompressDialogFiles: (files: FileItem[]) => void;
|
|
handleCompress: (archiveName: string, format: string) => void | Promise<void>;
|
|
totpRequired: boolean;
|
|
totpPrompt: string;
|
|
handleTotpSubmit: (code: string) => void | Promise<void>;
|
|
handleTotpCancel: () => void;
|
|
browserSignInRequired: boolean;
|
|
browserSignInUrl: string;
|
|
browserSignInCode: string;
|
|
browserSignInLabel: string;
|
|
handleBrowserSignInContinue: () => void | Promise<void>;
|
|
handleBrowserSignInCancel: () => void;
|
|
handleBrowserSignInOpenUrl: () => void;
|
|
currentHost: SSHHost | null;
|
|
showAuthDialog: boolean;
|
|
authDialogReason: "no_keyboard" | "auth_failed" | "timeout";
|
|
handleAuthDialogSubmit: (credentials: {
|
|
password?: string;
|
|
sshKey?: string;
|
|
keyPassword?: string;
|
|
}) => void | Promise<void>;
|
|
handleAuthDialogCancel: () => void;
|
|
permissionsDialogFile: FileItem | null;
|
|
setPermissionsDialogFile: (file: FileItem | null) => void;
|
|
handleSavePermissions: (file: FileItem, permissions: string) => Promise<void>;
|
|
sudoDialogOpen: boolean;
|
|
setSudoDialogOpen: (open: boolean) => void;
|
|
setPendingSudoOperation: (operation: PendingSudoOperation | null) => void;
|
|
handleSudoPasswordSubmit: (password: string) => void | Promise<void>;
|
|
};
|
|
|
|
export function FileManagerDialogs({
|
|
compressDialogFiles,
|
|
setCompressDialogFiles,
|
|
handleCompress,
|
|
totpRequired,
|
|
totpPrompt,
|
|
handleTotpSubmit,
|
|
handleTotpCancel,
|
|
browserSignInRequired,
|
|
browserSignInUrl,
|
|
browserSignInCode,
|
|
browserSignInLabel,
|
|
handleBrowserSignInContinue,
|
|
handleBrowserSignInCancel,
|
|
handleBrowserSignInOpenUrl,
|
|
currentHost,
|
|
showAuthDialog,
|
|
authDialogReason,
|
|
handleAuthDialogSubmit,
|
|
handleAuthDialogCancel,
|
|
permissionsDialogFile,
|
|
setPermissionsDialogFile,
|
|
handleSavePermissions,
|
|
sudoDialogOpen,
|
|
setSudoDialogOpen,
|
|
setPendingSudoOperation,
|
|
handleSudoPasswordSubmit,
|
|
}: FileManagerDialogsProps) {
|
|
return (
|
|
<>
|
|
<CompressDialog
|
|
open={compressDialogFiles.length > 0}
|
|
onOpenChange={(open) => !open && setCompressDialogFiles([])}
|
|
fileNames={compressDialogFiles.map((f) => f.name)}
|
|
onCompress={handleCompress}
|
|
/>
|
|
|
|
<TOTPDialog
|
|
isOpen={totpRequired}
|
|
prompt={totpPrompt}
|
|
onSubmit={handleTotpSubmit}
|
|
onCancel={handleTotpCancel}
|
|
backgroundColor="var(--bg-canvas)"
|
|
/>
|
|
|
|
<BrowserSignInDialog
|
|
isOpen={browserSignInRequired}
|
|
label={browserSignInLabel}
|
|
url={browserSignInUrl}
|
|
code={browserSignInCode}
|
|
onContinue={handleBrowserSignInContinue}
|
|
onCancel={handleBrowserSignInCancel}
|
|
onOpenUrl={handleBrowserSignInOpenUrl}
|
|
backgroundColor="var(--bg-canvas)"
|
|
/>
|
|
|
|
{currentHost && (
|
|
<SSHAuthDialog
|
|
isOpen={showAuthDialog}
|
|
reason={authDialogReason}
|
|
onSubmit={handleAuthDialogSubmit}
|
|
onCancel={handleAuthDialogCancel}
|
|
hostInfo={{
|
|
ip: currentHost.ip,
|
|
port: currentHost.port,
|
|
username: currentHost.username,
|
|
name: currentHost.name,
|
|
}}
|
|
backgroundColor="var(--bg-canvas)"
|
|
/>
|
|
)}
|
|
|
|
<PermissionsDialog
|
|
file={permissionsDialogFile}
|
|
open={permissionsDialogFile !== null}
|
|
onOpenChange={(open) => {
|
|
if (!open) setPermissionsDialogFile(null);
|
|
}}
|
|
onSave={handleSavePermissions}
|
|
/>
|
|
|
|
<SudoPasswordDialog
|
|
open={sudoDialogOpen}
|
|
onOpenChange={(open) => {
|
|
setSudoDialogOpen(open);
|
|
if (!open) setPendingSudoOperation(null);
|
|
}}
|
|
onSubmit={handleSudoPasswordSubmit}
|
|
/>
|
|
</>
|
|
);
|
|
}
|