feat(filters): "Share view" link button in the sidebar
Add a share button next to Clear all that copies a link reproducing the current filter view (filters, sort, scope) to the clipboard, with a confirmation toast. This is the opt-in replacement for the old always-on URL mirroring. Trilingual.
This commit is contained in:
parent
eef64ef811
commit
78182f3ba6
4 changed files with 31 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
Pencil,
|
||||
RefreshCw,
|
||||
RotateCcw,
|
||||
Share2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
|
|
@ -33,6 +34,8 @@ import {
|
|||
type SidebarLayout,
|
||||
type WidgetId,
|
||||
} from "../lib/sidebarLayout";
|
||||
import { shareUrl } from "../lib/urlState";
|
||||
import { notify } from "../lib/notifications";
|
||||
|
||||
// Filter ids; display labels resolved at render time via t("sidebar.sort.<id>") etc.
|
||||
const SORT_IDS = [
|
||||
|
|
@ -196,6 +199,15 @@ export default function Sidebar({
|
|||
(dateActive ? 1 : 0);
|
||||
const active = activeCount > 0;
|
||||
|
||||
async function shareView() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareUrl(filters));
|
||||
notify({ message: t("sidebar.shareCopied") });
|
||||
} catch {
|
||||
notify({ level: "warning", message: t("sidebar.shareFailed") });
|
||||
}
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
setCustomDates(false);
|
||||
setFilters({ ...DEFAULT_SIDEBAR_FILTERS, q: filters.q, scope: filters.scope });
|
||||
|
|
@ -486,6 +498,16 @@ export default function Sidebar({
|
|||
{t("sidebar.clearAll")}
|
||||
</button>
|
||||
)}
|
||||
{!editing && (
|
||||
<button
|
||||
onClick={shareView}
|
||||
title={t("sidebar.shareView")}
|
||||
aria-label={t("sidebar.shareView")}
|
||||
className="p-1.5 rounded-lg text-muted hover:text-fg hover:bg-card transition"
|
||||
>
|
||||
<Share2 className="w-4 h-4" />
|
||||
</button>
|
||||
)}
|
||||
{editing && (
|
||||
<button
|
||||
onClick={() => setLayout({ ...DEFAULT_LAYOUT })}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
"clearDates": "Daten löschen",
|
||||
"reshuffle": "Neu mischen",
|
||||
"noMatchingTags": "Keine passenden Tags",
|
||||
"shareView": "Link zu dieser Ansicht kopieren",
|
||||
"shareCopied": "Ansichts-Link in die Zwischenablage kopiert",
|
||||
"shareFailed": "Link konnte nicht kopiert werden",
|
||||
"widget": {
|
||||
"show": "Anzeigen",
|
||||
"sort": "Sortierung",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
"clearDates": "clear dates",
|
||||
"reshuffle": "Reshuffle",
|
||||
"noMatchingTags": "No matching tags here",
|
||||
"shareView": "Copy a link to this view",
|
||||
"shareCopied": "View link copied to clipboard",
|
||||
"shareFailed": "Couldn't copy the link",
|
||||
"widget": {
|
||||
"show": "Show",
|
||||
"sort": "Sort",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
"clearDates": "dátumok törlése",
|
||||
"reshuffle": "Újrakeverés",
|
||||
"noMatchingTags": "Nincs ide illő címke",
|
||||
"shareView": "Hivatkozás másolása erre a nézetre",
|
||||
"shareCopied": "Nézet-hivatkozás a vágólapra másolva",
|
||||
"shareFailed": "Nem sikerült a hivatkozás másolása",
|
||||
"widget": {
|
||||
"show": "Megjelenítés",
|
||||
"sort": "Rendezés",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue