Share copy-link helper and fix UK plurals
List rows and the viewer toolbar used the same clipboard toast path; Ukrainian moreRegions needs one/few/many forms. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
import { Toast } from "@base-ui/react/toast";
|
|
||||||
import { LinkSimpleIcon } from "@phosphor-icons/react";
|
import { LinkSimpleIcon } from "@phosphor-icons/react";
|
||||||
import { Checkbox } from "@probo/ui/src/v2/Checkbox/Checkbox";
|
import { Checkbox } from "@probo/ui/src/v2/Checkbox/Checkbox";
|
||||||
import { IconButton } from "@probo/ui/src/v2/IconButton/IconButton";
|
import { IconButton } from "@probo/ui/src/v2/IconButton/IconButton";
|
||||||
@@ -29,6 +28,8 @@ import type { ReactNode } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link as RouterLink } from "react-router";
|
import { Link as RouterLink } from "react-router";
|
||||||
|
|
||||||
|
import { useCopyDocumentLink } from "../_lib/useCopyDocumentLink";
|
||||||
|
|
||||||
import { DocumentAccessAction } from "./DocumentAccessAction";
|
import { DocumentAccessAction } from "./DocumentAccessAction";
|
||||||
import { documentEntry } from "./variants";
|
import { documentEntry } from "./variants";
|
||||||
|
|
||||||
@@ -70,7 +71,7 @@ export function DocumentEntry({
|
|||||||
onSelectedChange,
|
onSelectedChange,
|
||||||
}: DocumentEntryProps) {
|
}: DocumentEntryProps) {
|
||||||
const { t } = useTranslation("documents");
|
const { t } = useTranslation("documents");
|
||||||
const toast = Toast.useToastManager();
|
const copyDocumentLink = useCopyDocumentLink();
|
||||||
const slots = documentEntry();
|
const slots = documentEntry();
|
||||||
|
|
||||||
// Only locked rows (not yet authorized, no pending request) can be requested,
|
// Only locked rows (not yet authorized, no pending request) can be requested,
|
||||||
@@ -85,11 +86,7 @@ export function DocumentEntry({
|
|||||||
: t("actions.getAccess");
|
: t("actions.getAccess");
|
||||||
|
|
||||||
const handleCopyLink = () => {
|
const handleCopyLink = () => {
|
||||||
const url = new URL(viewHref, window.location.origin);
|
copyDocumentLink(new URL(viewHref, window.location.origin).href);
|
||||||
navigator.clipboard.writeText(url.href).then(
|
|
||||||
() => toast.add({ title: t("viewer.linkCopied"), type: "success" }),
|
|
||||||
() => {},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
import { Toast } from "@base-ui/react/toast";
|
|
||||||
import {
|
import {
|
||||||
CaretLeftIcon,
|
CaretLeftIcon,
|
||||||
CaretRightIcon,
|
CaretRightIcon,
|
||||||
@@ -34,6 +33,7 @@ import { Text } from "@probo/ui/src/v2/typography/Text";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
import { downloadDataUri } from "../_lib/dataUri";
|
import { downloadDataUri } from "../_lib/dataUri";
|
||||||
|
import { useCopyDocumentLink } from "../_lib/useCopyDocumentLink";
|
||||||
|
|
||||||
import { documentViewerToolbar } from "./variants";
|
import { documentViewerToolbar } from "./variants";
|
||||||
|
|
||||||
@@ -72,14 +72,11 @@ export function DocumentViewerToolbar({
|
|||||||
downloadName,
|
downloadName,
|
||||||
}: DocumentViewerToolbarProps) {
|
}: DocumentViewerToolbarProps) {
|
||||||
const { t } = useTranslation("documents");
|
const { t } = useTranslation("documents");
|
||||||
const toast = Toast.useToastManager();
|
const copyDocumentLink = useCopyDocumentLink();
|
||||||
const slots = documentViewerToolbar();
|
const slots = documentViewerToolbar();
|
||||||
|
|
||||||
const handleCopyLink = () => {
|
const handleCopyLink = () => {
|
||||||
navigator.clipboard.writeText(window.location.href).then(
|
copyDocumentLink(window.location.href);
|
||||||
() => toast.add({ title: t("viewer.linkCopied"), type: "success" }),
|
|
||||||
() => {},
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDownload = () => {
|
const handleDownload = () => {
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
|
||||||
|
import { Toast } from "@base-ui/react/toast";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
// Copies a document URL to the clipboard and toasts on success. Shared by list
|
||||||
|
// rows and the viewer toolbar so feedback stays in sync.
|
||||||
|
export function useCopyDocumentLink() {
|
||||||
|
const { t } = useTranslation("documents");
|
||||||
|
const toast = Toast.useToastManager();
|
||||||
|
|
||||||
|
return (url: string) => {
|
||||||
|
void navigator.clipboard.writeText(url).then(
|
||||||
|
() => {
|
||||||
|
toast.add({ title: t("viewer.linkCopied"), type: "success" });
|
||||||
|
},
|
||||||
|
() => {},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -15,7 +15,10 @@
|
|||||||
"regions": {
|
"regions": {
|
||||||
"global": "Глобально",
|
"global": "Глобально",
|
||||||
"eu": "Європейський Союз",
|
"eu": "Європейський Союз",
|
||||||
"moreRegions": "Показати ще {{count}} регіонів"
|
"moreRegions_one": "Показати ще {{count}} регіон",
|
||||||
|
"moreRegions_few": "Показати ще {{count}} регіони",
|
||||||
|
"moreRegions_many": "Показати ще {{count}} регіонів",
|
||||||
|
"moreRegions_other": "Показати ще {{count}} регіонів"
|
||||||
},
|
},
|
||||||
"categories": {
|
"categories": {
|
||||||
"ANALYTICS": {
|
"ANALYTICS": {
|
||||||
|
|||||||
Reference in New Issue
Block a user