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:
@@ -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 })}
|
||||
|
||||
Reference in New Issue
Block a user