mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
feat: implement unarchive functionality for selected ciphers with state management
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import type { ComponentChildren } from 'preact';
|
import type { ComponentChildren } from 'preact';
|
||||||
import { Check, X } from 'lucide-preact';
|
|
||||||
import { t } from '@/lib/i18n';
|
import { t } from '@/lib/i18n';
|
||||||
|
|
||||||
interface ConfirmDialogProps {
|
interface ConfirmDialogProps {
|
||||||
@@ -39,7 +38,6 @@ export default function ConfirmDialog(props: ConfirmDialogProps) {
|
|||||||
className={`btn ${props.danger ? 'btn-danger' : 'btn-primary'} dialog-btn`}
|
className={`btn ${props.danger ? 'btn-danger' : 'btn-primary'} dialog-btn`}
|
||||||
disabled={props.confirmDisabled}
|
disabled={props.confirmDisabled}
|
||||||
>
|
>
|
||||||
<Check size={14} className="btn-icon" />
|
|
||||||
{props.confirmText || t('txt_yes')}
|
{props.confirmText || t('txt_yes')}
|
||||||
</button>
|
</button>
|
||||||
{!props.hideCancel && (
|
{!props.hideCancel && (
|
||||||
@@ -52,7 +50,6 @@ export default function ConfirmDialog(props: ConfirmDialogProps) {
|
|||||||
props.onCancel();
|
props.onCancel();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<X size={14} className="btn-icon" />
|
|
||||||
{props.cancelText || t('txt_no')}
|
{props.cancelText || t('txt_no')}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -700,6 +700,27 @@ function folderName(id: string | null | undefined): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleUnarchiveSelected(cipher: Cipher): Promise<void> {
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await props.onUnarchive(cipher);
|
||||||
|
if (sidebarFilter.kind === 'archive') {
|
||||||
|
const remaining = filteredCiphers.filter((item) => item.id !== cipher.id);
|
||||||
|
setSelectedMap((prev) => {
|
||||||
|
const next = { ...prev };
|
||||||
|
delete next[cipher.id];
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
setSelectedCipherId(remaining[0]?.id || '');
|
||||||
|
if (isMobileLayout && remaining.length === 0) {
|
||||||
|
setMobilePanel('list');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function confirmBulkArchive(): Promise<void> {
|
async function confirmBulkArchive(): Promise<void> {
|
||||||
const ids = Object.entries(selectedMap)
|
const ids = Object.entries(selectedMap)
|
||||||
.filter(([, selected]) => selected)
|
.filter(([, selected]) => selected)
|
||||||
@@ -906,7 +927,7 @@ function folderName(id: string | null | undefined): string {
|
|||||||
onStartEdit={startEdit}
|
onStartEdit={startEdit}
|
||||||
onDelete={setPendingDelete}
|
onDelete={setPendingDelete}
|
||||||
onArchive={(cipher) => setPendingArchive(cipher)}
|
onArchive={(cipher) => setPendingArchive(cipher)}
|
||||||
onUnarchive={props.onUnarchive}
|
onUnarchive={(cipher) => void handleUnarchiveSelected(cipher)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user