mirror of
https://github.com/zadam/trilium.git
synced 2025-12-17 21:59:55 +01:00
feat(layout/file): open externally & download buttons
This commit is contained in:
@@ -795,7 +795,7 @@
|
|||||||
"file_type": "File type",
|
"file_type": "File type",
|
||||||
"file_size": "File size",
|
"file_size": "File size",
|
||||||
"download": "Download",
|
"download": "Download",
|
||||||
"open": "Open",
|
"open": "Open externally",
|
||||||
"upload_new_revision": "Upload new revision",
|
"upload_new_revision": "Upload new revision",
|
||||||
"upload_success": "New file revision has been uploaded.",
|
"upload_success": "New file revision has been uploaded.",
|
||||||
"upload_failed": "Upload of a new file revision failed.",
|
"upload_failed": "Upload of a new file revision failed.",
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import branches from "../../services/branches";
|
|||||||
import dialog from "../../services/dialog";
|
import dialog from "../../services/dialog";
|
||||||
import { isExperimentalFeatureEnabled } from "../../services/experimental_features";
|
import { isExperimentalFeatureEnabled } from "../../services/experimental_features";
|
||||||
import { t } from "../../services/i18n";
|
import { t } from "../../services/i18n";
|
||||||
|
import { downloadFileNote, openNoteExternally } from "../../services/open";
|
||||||
import protected_session from "../../services/protected_session";
|
import protected_session from "../../services/protected_session";
|
||||||
|
import protected_session_holder from "../../services/protected_session_holder";
|
||||||
import server from "../../services/server";
|
import server from "../../services/server";
|
||||||
import toast from "../../services/toast";
|
import toast from "../../services/toast";
|
||||||
import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/utils";
|
import { isElectron as getIsElectron, isMac as getIsMac } from "../../services/utils";
|
||||||
@@ -29,6 +31,7 @@ export default function NoteActions() {
|
|||||||
const { note, noteContext } = useNoteContext();
|
const { note, noteContext } = useNoteContext();
|
||||||
return (
|
return (
|
||||||
<div className="ribbon-button-container" style={{ contain: "none" }}>
|
<div className="ribbon-button-container" style={{ contain: "none" }}>
|
||||||
|
{note && <FileActions note={note} />}
|
||||||
<MovePaneButton direction="left" />
|
<MovePaneButton direction="left" />
|
||||||
<MovePaneButton direction="right" />
|
<MovePaneButton direction="right" />
|
||||||
<ClosePaneButton />
|
<ClosePaneButton />
|
||||||
@@ -274,3 +277,25 @@ function ConvertToAttachment({ note }: { note: FNote }) {
|
|||||||
>{t("note_actions.convert_into_attachment")}</FormListItem>
|
>{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)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user