in webapp/src/editortoolbar.tsx [300:403]
renderCore() {
const { tutorialOptions, projectName, compiling, isSaving, simState, debugging, editorState } = this.props.parent.state;
const header = this.getData(`header:${this.props.parent.state.header.id}`) ?? this.props.parent.state.header;
const targetTheme = pxt.appTarget.appTheme;
const isController = pxt.shell.isControllerMode();
const readOnly = pxt.shell.isReadOnly();
const tutorial = tutorialOptions ? tutorialOptions.tutorial : false;
const simOpts = pxt.appTarget.simulator;
const headless = simOpts.headless;
const flyoutOnly = editorState && editorState.hasCategories === false;
const disableFileAccessinMaciOs = targetTheme.disableFileAccessinMaciOs && (pxt.BrowserUtils.isIOS() || pxt.BrowserUtils.isMac());
const disableFileAccessinAndroid = pxt.appTarget.appTheme.disableFileAccessinAndroid && pxt.BrowserUtils.isAndroid();
const ghid = header && pxt.github.parseRepoId(header.githubId);
const hasRepository = !!ghid;
const showSave = !readOnly && !isController && !targetTheme.saveInMenu
&& !tutorial && !debugging && !disableFileAccessinMaciOs && !disableFileAccessinAndroid
&& !hasRepository;
const showProjectRename = !tutorial && !readOnly && !isController
&& !targetTheme.hideProjectRename && !debugging;
const showProjectRenameReadonly = false; // always allow renaming, even for github projects
const compile = pxt.appTarget.compile;
const compileBtn = compile.hasHex || compile.saveAsPNG || compile.useUF2;
const compileTooltip = lf("Download your code to the {0}", targetTheme.boardName);
const compileLoading = !!compiling;
const running = simState == pxt.editor.SimState.Running;
const starting = simState == pxt.editor.SimState.Starting;
const showUndoRedo = !readOnly && !debugging && !flyoutOnly;
const showZoomControls = !flyoutOnly;
const showGithub = !!pxt.appTarget.cloud
&& !!pxt.appTarget.cloud.githubPackages
&& targetTheme.githubEditor
&& !pxt.winrt.isWinRT() // not supported in windows 10
&& !pxt.BrowserUtils.isPxtElectron()
&& !readOnly && !isController && !debugging && !tutorial;
const downloadIcon = pxt.appTarget.appTheme.downloadIcon || "download";
const bigRunButtonTooltip = (() => {
switch (simState) {
case pxt.editor.SimState.Stopped:
return lf("Start");
case pxt.editor.SimState.Pending:
case pxt.editor.SimState.Starting:
return lf("Starting");
default:
return lf("Stop");
}
})();
const mobile = View.Mobile;
const computer = View.Computer;
let downloadButtonClasses = "";
let saveButtonClasses = "";
if (isSaving) {
downloadButtonClasses = "disabled";
saveButtonClasses = "loading disabled";
} else if (compileLoading) {
downloadButtonClasses = "loading disabled";
saveButtonClasses = "disabled";
}
return <div id="editortools" className="ui" role="region" aria-label={lf("Editor toolbar")}>
<div id="downloadArea" role="menu" className="ui column items">{headless &&
<div className="ui item">
<div className="ui icon large buttons">
{compileBtn && <EditorToolbarButton icon={downloadIcon} className={`primary large download-button mobile tablet hide ${downloadButtonClasses}`} title={compileTooltip} onButtonClick={this.compile} view='computer' />}
</div>
</div>}
{/* TODO clean this; make it just getCompileButton, and set the buttons fontsize to 0 / the icon itself back to normal to just hide text */}
{!headless && <div className="ui item portrait hide">
{compileBtn && this.getCompileButton(computer)}
</div>}
{!headless && <div className="ui portrait only">
{compileBtn && this.getCompileButton(mobile)}
</div>}
</div>
{(showProjectRename || showGithub || identity.CloudSaveStatus.wouldRender(header.id)) &&
<div id="projectNameArea" role="menu" className="ui column items">
<div className={`ui right ${showSave ? "labeled" : ""} input projectname-input projectname-computer`}>
{showProjectRename && this.getSaveInput(showSave, "fileNameInput2", projectName, showProjectRenameReadonly)}
{showGithub && <githubbutton.GithubButton parent={this.props.parent} key={`githubbtn${computer}`} />}
<identity.CloudSaveStatus headerId={header.id} />
</div>
</div>}
<div id="editorToolbarArea" role="menu" className="ui column items">
{showUndoRedo && <div className="ui icon buttons">{this.getUndoRedo(computer)}</div>}
{showZoomControls && <div className="ui icon buttons mobile hide">{this.getZoomControl(computer)}</div>}
{targetTheme.bigRunButton &&
<div className="big-play-button-wrapper">
<EditorToolbarButton
className={`big-play-button play-button ${running ? "stop" : "play"}`}
key='runmenubtn' disabled={starting}
icon={running ? "stop" : "play"}
title={bigRunButtonTooltip} onButtonClick={this.startStopSimulator}
view='computer'
/>
</div>}
</div>
</div>;
}