import FNote from "../../entities/fnote";
import { t } from "../../services/i18n";
import { downloadFileNote, openNoteExternally } from "../../services/open";
import protected_session_holder from "../../services/protected_session_holder";
import ActionButton from "../react/ActionButton";
import { FormFileUploadActionButton } from "../react/FormFileUpload";
import { buildUploadNewFileRevisionListener } from "./FilePropertiesTab";
import { buildUploadNewImageRevisionListener } from "./ImagePropertiesTab";
interface NoteActionsCustomProps {
note: FNote;
}
/**
* Part of {@link NoteActions} on the new layout, but are rendered with a slight spacing
* from the rest of the note items and the buttons differ based on the note type.
*/
export default function NoteActionsCustom({ note }: NoteActionsCustomProps) {
return (
);
}
//#region Note type mappings
function NoteActionsCustomInner(props: NoteActionsCustomProps) {
switch (props.note.type) {
case "file":
return ;
case "image":
return ;
}
}
function FileActions({ note }: NoteActionsCustomProps) {
return (
<>
>
);
}
function ImageActions({ note }: NoteActionsCustomProps) {
return (
<>
>
);
}
//#endregion
//#region Shared buttons
function UploadNewRevisionButton({ note, onChange }: NoteActionsCustomProps & {
onChange: (files: FileList | null) => void;
}) {
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
return (
);
}
function OpenExternallyButton({ note }: NoteActionsCustomProps) {
return (
openNoteExternally(note.noteId, note.mime)}
/>
);
}
function DownloadFileButton({ note }: NoteActionsCustomProps) {
const canAccessProtectedNote = !note?.isProtected || protected_session_holder.isProtectedSessionAvailable();
return (
downloadFileNote(note.noteId)}
/>
);
}
//#endregion