mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -04:00
* you know, you could just work on first try * fix extension * configure plugin and fix few translation issues * more * more keys * and more * more keys and sort * commit msg * we like keys here * end my suffering * jk i just love keys * key fix * add turkish * add german * Entendido * Demnächst * Mettre une étoile sur GitHub * 成功 * pnpm-lock * vite plugin * remove i18next backends --------- Co-authored-by: Brendan Allan <brendonovich@outlook.com>
37 lines
881 B
TypeScript
37 lines
881 B
TypeScript
import { ClipboardText } from '@phosphor-icons/react';
|
|
import { toast } from '@sd/ui';
|
|
import { Menu } from '~/components/Menu';
|
|
import { useLocale } from '~/hooks';
|
|
|
|
export const CopyAsPathBase = (
|
|
props: { path: string } | { getPath: () => Promise<string | null> }
|
|
) => {
|
|
const { t } = useLocale();
|
|
|
|
return (
|
|
<Menu.Item
|
|
label={t('copy_as_path')}
|
|
icon={ClipboardText}
|
|
onClick={async () => {
|
|
try {
|
|
const path = 'path' in props ? props.path : await props.getPath();
|
|
{
|
|
/* 'path' in props
|
|
? props.path
|
|
: await libraryClient.query(['files.getPath', props.filePath.id]); */
|
|
}
|
|
|
|
if (path == null) throw new Error('No file path available');
|
|
|
|
navigator.clipboard.writeText(path);
|
|
} catch (error) {
|
|
toast.error({
|
|
title: t('failed_to_copy_file_path'),
|
|
body: `Error: ${error}.`
|
|
});
|
|
}
|
|
}}
|
|
/>
|
|
);
|
|
};
|