Files
spacedrive/interface/app/$libraryId/Explorer/CopyAsPath.tsx
Utku a94832c1ee [ENG-1502] I18n (#1897)
* 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>
2024-01-08 20:26:46 +00:00

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}.`
});
}
}}
/>
);
};