Skip to content

Commit 48c5069

Browse files
committed
Add flags for language and file menus
Show or hide the language and file menus.
1 parent f2ac39f commit 48c5069

File tree

2 files changed

+84
-70
lines changed

2 files changed

+84
-70
lines changed

src/components/gui/gui.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ const GUIComponent = props => {
6666
backpackVisible,
6767
blocksTabVisible,
6868
cardsVisible,
69+
canChangeLanguage,
6970
canCreateNew,
7071
canEditTitle,
72+
canManageFiles,
7173
canRemix,
7274
canSave,
7375
canCreateCopy,
@@ -202,9 +204,11 @@ const GUIComponent = props => {
202204
authorId={authorId}
203205
authorThumbnailUrl={authorThumbnailUrl}
204206
authorUsername={authorUsername}
207+
canChangeLanguage={canChangeLanguage}
205208
canCreateCopy={canCreateCopy}
206209
canCreateNew={canCreateNew}
207210
canEditTitle={canEditTitle}
211+
canManageFiles={canManageFiles}
208212
canRemix={canRemix}
209213
canSave={canSave}
210214
canShare={canShare}
@@ -359,9 +363,11 @@ GUIComponent.propTypes = {
359363
backpackVisible: PropTypes.bool,
360364
basePath: PropTypes.string,
361365
blocksTabVisible: PropTypes.bool,
366+
canChangeLanguage: PropTypes.bool,
362367
canCreateCopy: PropTypes.bool,
363368
canCreateNew: PropTypes.bool,
364369
canEditTitle: PropTypes.bool,
370+
canManageFiles: PropTypes.bool,
365371
canRemix: PropTypes.bool,
366372
canSave: PropTypes.bool,
367373
canShare: PropTypes.bool,
@@ -411,8 +417,10 @@ GUIComponent.defaultProps = {
411417
backpackHost: null,
412418
backpackVisible: false,
413419
basePath: './',
420+
canChangeLanguage: true,
414421
canCreateNew: false,
415422
canEditTitle: false,
423+
canManageFiles: true,
416424
canRemix: false,
417425
canSave: false,
418426
canCreateCopy: false,

src/components/menu-bar/menu-bar.jsx

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class MenuBar extends React.Component {
331331
onClick={this.props.onClickLogo}
332332
/>
333333
</div>
334-
<div
334+
{(this.props.canChangeLanguage) && (<div
335335
className={classNames(styles.menuBarItem, styles.hoverable, styles.languageMenu)}
336336
>
337337
<div>
@@ -345,82 +345,86 @@ class MenuBar extends React.Component {
345345
/>
346346
</div>
347347
<LanguageSelector label={this.props.intl.formatMessage(ariaMessages.language)} />
348-
</div>
349-
<div
350-
className={classNames(styles.menuBarItem, styles.hoverable, {
351-
[styles.active]: this.props.fileMenuOpen
352-
})}
353-
onMouseUp={this.props.onClickFile}
354-
>
355-
<FormattedMessage
356-
defaultMessage="File"
357-
description="Text for file dropdown menu"
358-
id="gui.menuBar.file"
359-
/>
360-
<MenuBarMenu
361-
className={classNames(styles.menuBarMenu)}
362-
open={this.props.fileMenuOpen}
363-
place={this.props.isRtl ? 'left' : 'right'}
364-
onRequestClose={this.props.onRequestCloseFile}
348+
</div>)}
349+
{(this.props.canManageFiles) && (
350+
<div
351+
className={classNames(styles.menuBarItem, styles.hoverable, {
352+
[styles.active]: this.props.fileMenuOpen
353+
})}
354+
onMouseUp={this.props.onClickFile}
365355
>
366-
<MenuSection>
367-
<MenuItem
368-
isRtl={this.props.isRtl}
369-
onClick={this.handleClickNew}
370-
>
371-
{newProjectMessage}
372-
</MenuItem>
373-
</MenuSection>
374-
{(this.props.canSave || this.props.canCreateCopy || this.props.canRemix) && (
356+
<FormattedMessage
357+
defaultMessage="File"
358+
description="Text for file dropdown menu"
359+
id="gui.menuBar.file"
360+
/>
361+
<MenuBarMenu
362+
className={classNames(styles.menuBarMenu)}
363+
open={this.props.fileMenuOpen}
364+
place={this.props.isRtl ? 'left' : 'right'}
365+
onRequestClose={this.props.onRequestCloseFile}
366+
>
375367
<MenuSection>
376-
{this.props.canSave ? (
377-
<MenuItem onClick={this.handleClickSave}>
378-
{saveNowMessage}
379-
</MenuItem>
380-
) : []}
381-
{this.props.canCreateCopy ? (
382-
<MenuItem onClick={this.handleClickSaveAsCopy}>
383-
{createCopyMessage}
384-
</MenuItem>
385-
) : []}
386-
{this.props.canRemix ? (
387-
<MenuItem onClick={this.handleClickRemix}>
388-
{remixMessage}
389-
</MenuItem>
390-
) : []}
368+
<MenuItem
369+
isRtl={this.props.isRtl}
370+
onClick={this.handleClickNew}
371+
>
372+
{newProjectMessage}
373+
</MenuItem>
391374
</MenuSection>
392-
)}
393-
<MenuSection>
394-
<SBFileUploader
395-
canSave={this.props.canSave}
396-
userOwnsProject={this.props.userOwnsProject}
397-
onUpdateProjectTitle={this.props.onUpdateProjectTitle}
398-
>
399-
{(className, renderFileInput, loadProject) => (
375+
{(this.props.canSave || this.props.canCreateCopy || this.props.canRemix) && (
376+
<MenuSection>
377+
{this.props.canSave ? (
378+
<MenuItem onClick={this.handleClickSave}>
379+
{saveNowMessage}
380+
</MenuItem>
381+
) : []}
382+
{this.props.canCreateCopy ? (
383+
<MenuItem onClick={this.handleClickSaveAsCopy}>
384+
{createCopyMessage}
385+
</MenuItem>
386+
) : []}
387+
{this.props.canRemix ? (
388+
<MenuItem onClick={this.handleClickRemix}>
389+
{remixMessage}
390+
</MenuItem>
391+
) : []}
392+
</MenuSection>
393+
)}
394+
<MenuSection>
395+
<SBFileUploader
396+
canSave={this.props.canSave}
397+
userOwnsProject={this.props.userOwnsProject}
398+
onUpdateProjectTitle={this.props.onUpdateProjectTitle}
399+
>
400+
{(className, renderFileInput, loadProject) => (
401+
<MenuItem
402+
className={className}
403+
onClick={loadProject}
404+
>
405+
{/* eslint-disable max-len */}
406+
{this.props.intl.formatMessage(sharedMessages.loadFromComputerTitle)}
407+
{/* eslint-enable max-len */}
408+
{renderFileInput()}
409+
</MenuItem>
410+
)}
411+
</SBFileUploader>
412+
<SB3Downloader>{(className, downloadProjectCallback) => (
400413
<MenuItem
401414
className={className}
402-
onClick={loadProject}
415+
onClick={this.handleSaveToComputer(downloadProjectCallback)}
403416
>
404-
{this.props.intl.formatMessage(sharedMessages.loadFromComputerTitle)}
405-
{renderFileInput()}
417+
<FormattedMessage
418+
defaultMessage="Save to your computer"
419+
description="Menu bar item for downloading a project to your computer" // eslint-disable-line max-len
420+
id="gui.menuBar.downloadToComputer"
421+
/>
406422
</MenuItem>
407-
)}
408-
</SBFileUploader>
409-
<SB3Downloader>{(className, downloadProjectCallback) => (
410-
<MenuItem
411-
className={className}
412-
onClick={this.handleSaveToComputer(downloadProjectCallback)}
413-
>
414-
<FormattedMessage
415-
defaultMessage="Save to your computer"
416-
description="Menu bar item for downloading a project to your computer"
417-
id="gui.menuBar.downloadToComputer"
418-
/>
419-
</MenuItem>
420-
)}</SB3Downloader>
421-
</MenuSection>
422-
</MenuBarMenu>
423-
</div>
423+
)}</SB3Downloader>
424+
</MenuSection>
425+
</MenuBarMenu>
426+
</div>
427+
)}
424428
<div
425429
className={classNames(styles.menuBarItem, styles.hoverable, {
426430
[styles.active]: this.props.editMenuOpen
@@ -698,9 +702,11 @@ MenuBar.propTypes = {
698702
authorThumbnailUrl: PropTypes.string,
699703
authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
700704
autoUpdateProject: PropTypes.func,
705+
canChangeLanguage: PropTypes.bool,
701706
canCreateCopy: PropTypes.bool,
702707
canCreateNew: PropTypes.bool,
703708
canEditTitle: PropTypes.bool,
709+
canManageFiles: PropTypes.bool,
704710
canRemix: PropTypes.bool,
705711
canSave: PropTypes.bool,
706712
canShare: PropTypes.bool,

0 commit comments

Comments
 (0)