license import { Menu , MenuDivider , MenuItem } from "@blueprintjs/core" ; import React from "react" ; import { Auth } from "./auth" ; interface Props { auth : Auth | null ; canCreateNew : boolean ; canExport : boolean ; canSave : boolean ; canSaveAs : boolean ; songURL : string | null ; colourScheme : "vs-dark" | "vs" ; onExportLy ( ) : any ; onExportMIDI ( ) : any ; onExportPDF ( ) : any ; onDeleteSong ( song ) : void ; onLoadSong ( song ) : void ; onShowAbout ( ) : void ; onShowClone ( ) : void ; onShowOpen ( ) : void ; onShowNew ( ) : void ; onShowPublish ( ) : void ; onSignIn ( ) : void ; onSignOut ( ) : void ; setColourScheme ( colourScheme ) : void ; } /**
 * Renders the File menu.
 * The menu button is rendered by <Header />
 */ export default class FileMenu extends React . PureComponent < Props > { render ( ) { const { auth , canCreateNew , canExport , canSave , canSaveAs , onSignOut , onShowAbout , onShowClone , onShowOpen , onExportLy , onExportMIDI , onExportPDF , onShowNew , onShowPublish , songURL , } = this . props ; let signOut ; if ( auth ) { signOut = < MenuItem onClick = { onSignOut } icon = "log-out" text = "Sign out" / > ; } const tutorial = ( < MenuItem href = "http://lilypond.org/doc/v2.18/Documentation/learning/index" rel = "noopener noreferrer" target = "_blank" text = "LilyPond manual&hellip;" icon = "help" / > ) ; const about = ( < MenuItem onClick = { onShowAbout } text = "About Hacklily" icon = "info-sign" / > ) ; return ( < Menu > < MenuItem icon = "add" text = "New song" onClick = { onShowNew } disabled = { ! canCreateNew } /> < MenuDivider / > < MenuItem icon = "document-open" text = "Open&hellip;" onClick = { onShowOpen } / > < MenuItem icon = "import" text = "Import MusicXML&hellip;" href = "/musicxml2ly.html" / > < MenuItem icon = "floppy-disk" text = "Save" disabled = { ! canSave } onClick = { onShowPublish } / > < MenuItem icon = "duplicate" text = "Save as&hellip;" onClick = { onShowClone } disabled = { ! canSaveAs } /> < MenuItem icon = "download" text = "Export" disabled = { ! canExport } > < MenuItem onClick = { onExportLy } icon = "code" text = "LilyPond source" / > < MenuItem onClick = { onExportPDF } icon = "document-share" text = "PDF" / > < MenuItem onClick = { onExportMIDI } icon = "music" text = "MIDI" / > { songURL && < MenuDivider />} { songURL && ( < MenuItem href = { songURL . replace ( /\.ly$/ , ".pdf" ) } icon = "git-repo" text = "View on GitHub" / > ) } < /MenuItem> < MenuDivider / > { this . renderSetColourScheme ( ) } { signOut } < MenuDivider /> { tutorial } { about } < /Menu>); } private handleColourSchemeToggled = ( ) : void => { const newColourScheme = this . props . colourScheme === "vs-dark" ? "vs" : "vs-dark" ; this . props . setColourScheme ( newColourScheme ) ; } ; private renderSetColourScheme ( ) { const text = this . props . colourScheme === "vs-dark" ? "Use light colour scheme" : "Use dark colour scheme" ; return ( < MenuItem onClick = { this . handleColourSchemeToggled } icon = "lightbulb" text = { text } / > ) ; } }