Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(layout/file): open externally & download buttons
Elian Doran20f4990d489c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 107d66e74d..3d9676f722 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -795,7 +795,7 @@"file_type": "File type","file_size": "File size","download": "Download",- "open": "Open",+ "open": "Open externally","upload_new_revision": "Upload new revision","upload_success": "New file revision has been uploaded.","upload_failed": "Upload of a new file revision failed.",diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsxindex 9990ef6fa4..66b6b10b39 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx@@ -8,7 +8,9 @@ import branches from "../../services/branches";import dialog from "../../services/dialog";import { isExperimentalFeatureEnabled } from "../../services/experimental_features";import { t } from "../../services/i18n";+import { downloadFileNote, openNoteExternally } from "../../services/open";import protected_session from "../../services/protected_session";+import protected_session_holder from "../../services/protected_session_holder";import server from "../../services/server";import toast from "../../services/toast";import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/utils";@@ -29,6 +31,7 @@ export default function NoteActions() {const { note, noteContext } = useNoteContext();return (<div className="ribbon-button-container" style={{ contain: "none" }}>+ {note && <FileActions note={note} />}<MovePaneButton direction="left" /><MovePaneButton direction="right" /><ClosePaneButton />@@ -274,3 +277,25 @@ function ConvertToAttachment({ note }: { note: FNote }) {>{t("note_actions.convert_into_attachment")}</FormListItem>);}++function FileActions({ note }: { note: FNote }) {+ const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();++ return (note.type === "file" &&+ <>+ <ActionButton+ icon="bx bx-download"+ text={t("file_properties.download")}+ disabled={!canAccessProtectedNote}+ onClick={() => downloadFileNote(note.noteId)}+ />++ <ActionButton+ icon="bx bx-link-external"+ text={t("file_properties.open")}+ disabled={note.isProtected}+ onClick={() => openNoteExternally(note.noteId, note.mime)}+ />+ </>+ );+}