feat(layout/file): open externally & download buttons

This commit is contained in:
Elian Doran
2025-12-14 22:07:25 +02:00
parent 8c793bf0fe
commit 20f4990d48
2 changed files with 26 additions and 1 deletions

View File

@@ -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.",

View File

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