Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
|
|
import { useI18n } from '../../application/i18n/I18nProvider';
|
|
import {
|
|
hostTreeInlineGroupDeleteStore,
|
|
useHostTreeInlineGroupDeleteTarget,
|
|
} from '../../application/state/hostTreeInlineGroupDeleteStore';
|
|
import { Button } from '../ui/button';
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '../ui/dialog';
|
|
|
|
type HostTreeGroupDeleteDialogProps = {
|
|
managedGroupPaths?: Set<string>;
|
|
onConfirmDelete: (groupPath: string, deleteHosts: boolean) => void | Promise<void>;
|
|
};
|
|
|
|
export const HostTreeGroupDeleteDialog: React.FC<HostTreeGroupDeleteDialogProps> = ({
|
|
managedGroupPaths,
|
|
onConfirmDelete,
|
|
}) => {
|
|
const { t } = useI18n();
|
|
const targetPath = useHostTreeInlineGroupDeleteTarget();
|
|
const [deleteHosts, setDeleteHosts] = useState(false);
|
|
const isOpen = Boolean(targetPath);
|
|
const isManaged = Boolean(targetPath && managedGroupPaths?.has(targetPath));
|
|
|
|
useEffect(() => {
|
|
if (!isOpen) {
|
|
setDeleteHosts(false);
|
|
}
|
|
}, [isOpen]);
|
|
|
|
return (
|
|
<Dialog
|
|
open={isOpen}
|
|
onOpenChange={(open) => {
|
|
if (!open) hostTreeInlineGroupDeleteStore.close();
|
|
}}
|
|
>
|
|
<DialogContent className="max-w-[calc(100vw-2rem)] overflow-hidden sm:max-w-lg">
|
|
<DialogHeader className="min-w-0 pr-6">
|
|
<DialogTitle className="truncate">{t('vault.groups.deleteDialogTitle')}</DialogTitle>
|
|
<DialogDescription className="break-words [overflow-wrap:anywhere]">
|
|
{isManaged
|
|
? t('vault.groups.deleteDialog.managedDesc')
|
|
: t('vault.groups.deleteDialog.desc')}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
<div className="min-w-0 space-y-4 py-4">
|
|
{targetPath && (
|
|
<>
|
|
<p className="min-w-0 break-words text-sm text-muted-foreground [overflow-wrap:anywhere]">
|
|
{t('vault.groups.pathLabel')}:{' '}
|
|
<span className="font-mono">{targetPath}</span>
|
|
</p>
|
|
{!isManaged && (
|
|
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
|
<input
|
|
type="checkbox"
|
|
checked={deleteHosts}
|
|
onChange={(event) => setDeleteHosts(event.target.checked)}
|
|
className="rounded border-border"
|
|
/>
|
|
<span>{t('vault.groups.deleteDialog.deleteHosts')}</span>
|
|
</label>
|
|
)}
|
|
</>
|
|
)}
|
|
</div>
|
|
<DialogFooter>
|
|
<Button variant="ghost" onClick={() => hostTreeInlineGroupDeleteStore.close()}>
|
|
{t('common.cancel')}
|
|
</Button>
|
|
<Button
|
|
variant="destructive"
|
|
onClick={() => {
|
|
if (!targetPath) return;
|
|
void Promise.resolve(onConfirmDelete(targetPath, isManaged || deleteHosts)).finally(() => {
|
|
hostTreeInlineGroupDeleteStore.close();
|
|
setDeleteHosts(false);
|
|
});
|
|
}}
|
|
>
|
|
{t('common.delete')}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|