Add copyable draft IDs to cards
Some checks failed
Deploy Dzen assistant / deploy (push) Failing after 3m4s
Some checks failed
Deploy Dzen assistant / deploy (push) Failing after 3m4s
This commit is contained in:
parent
367e772e65
commit
81931cbb35
1 changed files with 44 additions and 10 deletions
|
|
@ -2406,6 +2406,16 @@ export default function App() {
|
|||
window.setTimeout(() => setCopyToast(""), 2200)
|
||||
}
|
||||
|
||||
async function copyDraftId(id: number) {
|
||||
try {
|
||||
await writeClipboardText(String(id))
|
||||
setCopyToast(`ID черновика ${id} скопирован`)
|
||||
} catch (error) {
|
||||
setCopyToast(`Не удалось скопировать ID: ${error instanceof Error ? error.message : error}`)
|
||||
}
|
||||
window.setTimeout(() => setCopyToast(""), 2200)
|
||||
}
|
||||
|
||||
async function deleteArticle(id: number) {
|
||||
const articleTitle = selectedArticle?.id === id ? selectedArticle.title : articles.find((article) => article.id === id)?.title
|
||||
if (!window.confirm(`Удалить статью${articleTitle ? ` «${articleTitle}»` : ""}? Она пропадёт из списка и RSS.`)) return
|
||||
|
|
@ -2679,15 +2689,27 @@ export default function App() {
|
|||
</div>
|
||||
<div className="space-y-1.5">
|
||||
{draftArticles.map((article, index) => (
|
||||
<div key={article.id} className="flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-sm transition hover:bg-background">
|
||||
<button
|
||||
key={article.id}
|
||||
className="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition hover:bg-background"
|
||||
className="flex min-w-0 flex-1 items-center gap-2 text-left"
|
||||
onClick={() => openArticlePreview(article.id)}
|
||||
>
|
||||
<FilePenLine className="size-4 shrink-0 text-muted-foreground" />
|
||||
<span className="shrink-0 text-xs tabular-nums text-muted-foreground">{index + 1}.</span>
|
||||
<span className="min-w-0 flex-1 truncate font-medium">{article.title}</span>
|
||||
</button>
|
||||
<span className="shrink-0 text-xs tabular-nums text-muted-foreground">ID {article.id}</span>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="size-7 shrink-0"
|
||||
title={`Скопировать ID черновика ${article.id}`}
|
||||
aria-label={`Скопировать ID черновика ${article.id}`}
|
||||
onClick={() => void copyDraftId(article.id)}
|
||||
>
|
||||
<Copy className="size-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -2822,9 +2844,21 @@ export default function App() {
|
|||
<StatusBadge status="draft" />
|
||||
<h3 className="min-w-0 flex-1 truncate text-sm font-semibold">{article.title}</h3>
|
||||
</div>
|
||||
<p className="mt-2 text-xs text-muted-foreground">Создано: {formatDateTime(article.createdAt)}</p>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
|
||||
<span>Создано: {formatDateTime(article.createdAt)}</span>
|
||||
<span className="tabular-nums">ID {article.id}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div className="flex shrink-0 gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="outline"
|
||||
title={`Скопировать ID черновика ${article.id}`}
|
||||
aria-label={`Скопировать ID черновика ${article.id}`}
|
||||
onClick={() => void copyDraftId(article.id)}
|
||||
>
|
||||
<Copy className="size-4" />
|
||||
</Button>
|
||||
<Button size="icon" variant="outline" title="Открыть редактор" aria-label="Открыть редактор" onClick={() => void openArticlePreview(article.id)}>
|
||||
<FileText className="size-4" />
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Reference in a new issue