<commit_before>###
The Menu bar across the top

File, Edit, etc....
###

{ButtonGroup, Dropdown, MenuItem} = require('react-bootstrap')

{Icon} = require('../r_misc')

{React, ReactDOM, rclass, rtypes}  = require('../smc-react')

{KeyboardShortcut} = require('./keyboard-shortcuts')

misc_page = require('../misc_page')

misc = require('smc-util/misc')
{required, defaults} = misc

OPACITY='.9'

TITLE_STYLE =
    color           : '#666'
    border          : 0
    backgroundColor : 'rgb(247,247,247)'

SELECTED_STYLE =
    color      : '#2196F3'
    fontWeight : 'bold'

exports.TopMenubar = rclass ({name}) ->
    reduxProps :
        "#{name}" :
            kernels             : rtypes.immutable.List
            kernel              : rtypes.string
            kernel_state        : rtypes.string
            has_unsaved_changes : rtypes.bool
            kernel_info         : rtypes.immutable.Map
            backend_kernel_info : rtypes.immutable.Map
            cells               : rtypes.immutable.Map
            cur_id              : rtypes.string
            trust               : rtypes.bool
            view_mode           : rtypes.string
            toolbar             : rtypes.bool
            cell_toolbar        : rtypes.string
            read_only           : rtypes.bool
        "page" :
            fullscreen          : rtypes.string

    shouldComponentUpdate: (next) ->
        return next.has_unsaved_changes != @props.has_unsaved_changes or \
            next.read_only != @props.read_only or \
            next.kernels != @props.kernels or \
            next.kernel != @props.kernel or \
            next.kernel_state != @props.kernel_state or \
            next.backend_kernel_info != @props.backend_kernel_info or \
            next.cur_id != @props.cur_id or \
            next.cells != @props.cells or \
            next.trust != @props.trust or \
            next.toolbar != @props.toolbar or \
            next.cell_toolbar != @props.cell_toolbar or \
            next.view_mode != @props.view_mode

    propTypes :
        actions : rtypes.object.isRequired

    render_file: ->
        ext = @props.backend_kernel_info?.getIn(['language_info', 'file_extension'])
        if ext?
            m = misc.capitalize(@props.backend_kernel_info.getIn(['language_info', 'name']))
            script_entry = {name:'>nbconvert script', display:"#{m} (#{ext})..."}
        else
            script_entry = '>nbconvert script'

        if @props.trust
            trust = {name:"<trust notebook", display:"Trusted notebook"}
        else
            trust = {name:"trust notebook", display:"Trust notebook..."}

        save = 'save notebook'
        if not @props.has_unsaved_changes or @props.read_only
            save = '<' + save

        rename = 'rename notebook'
        if not @props.has_unsaved_changes or @props.read_only
            rename = '<' + rename

        close_and_halt = 'close and halt'
        if @props.read_only
            close_and_halt = '<' + close_and_halt

        names = [
                'new notebook', 'open file', close_and_halt, '', \
                'duplicate notebook', rename, save, 'time travel', '', \
                'print preview', '<Download as...', '>nbconvert ipynb',  script_entry, '>nbconvert html', '>nbconvert markdown', '>nbconvert rst', '>nbconvert tex', '>nbconvert pdf',  '>nbconvert sagews', '', '>nbconvert slides', '>nbconvert asciidoc', '', \
                trust]
        if @props.fullscreen != 'kiosk'
            names.push('')
            names.push('switch to classical notebook')

        @render_menu
            heading : 'File'
            names   : names

    render_edit: ->
        cell_type = @props.cells?.get(@props.cur_id)?.get('cell_type')<commit_msg>fix bug in Rename menu option (rename sucks anyways, but still)<commit_after>###
The Menu bar across the top

File, Edit, etc....
###

{ButtonGroup, Dropdown, MenuItem} = require('react-bootstrap')

{Icon} = require('../r_misc')

{React, ReactDOM, rclass, rtypes}  = require('../smc-react')

{KeyboardShortcut} = require('./keyboard-shortcuts')

misc_page = require('../misc_page')

misc = require('smc-util/misc')
{required, defaults} = misc

OPACITY='.9'

TITLE_STYLE =
    color           : '#666'
    border          : 0
    backgroundColor : 'rgb(247,247,247)'

SELECTED_STYLE =
    color      : '#2196F3'
    fontWeight : 'bold'

exports.TopMenubar = rclass ({name}) ->
    reduxProps :
        "#{name}" :
            kernels             : rtypes.immutable.List
            kernel              : rtypes.string
            kernel_state        : rtypes.string
            has_unsaved_changes : rtypes.bool
            kernel_info         : rtypes.immutable.Map
            backend_kernel_info : rtypes.immutable.Map
            cells               : rtypes.immutable.Map
            cur_id              : rtypes.string
            trust               : rtypes.bool
            view_mode           : rtypes.string
            toolbar             : rtypes.bool
            cell_toolbar        : rtypes.string
            read_only           : rtypes.bool
        "page" :
            fullscreen          : rtypes.string

    shouldComponentUpdate: (next) ->
        return next.has_unsaved_changes != @props.has_unsaved_changes or \
            next.read_only != @props.read_only or \
            next.kernels != @props.kernels or \
            next.kernel != @props.kernel or \
            next.kernel_state != @props.kernel_state or \
            next.backend_kernel_info != @props.backend_kernel_info or \
            next.cur_id != @props.cur_id or \
            next.cells != @props.cells or \
            next.trust != @props.trust or \
            next.toolbar != @props.toolbar or \
            next.cell_toolbar != @props.cell_toolbar or \
            next.view_mode != @props.view_mode

    propTypes :
        actions : rtypes.object.isRequired

    render_file: ->
        ext = @props.backend_kernel_info?.getIn(['language_info', 'file_extension'])
        if ext?
            m = misc.capitalize(@props.backend_kernel_info.getIn(['language_info', 'name']))
            script_entry = {name:'>nbconvert script', display:"#{m} (#{ext})..."}
        else
            script_entry = '>nbconvert script'

        if @props.trust
            trust = {name:"<trust notebook", display:"Trusted notebook"}
        else
            trust = {name:"trust notebook", display:"Trust notebook..."}

        save = 'save notebook'
        if not @props.has_unsaved_changes or @props.read_only
            save = '<' + save

        rename = 'rename notebook'
        if @props.has_unsaved_changes or @props.read_only
            rename = '<' + rename

        close_and_halt = 'close and halt'
        if @props.read_only
            close_and_halt = '<' + close_and_halt

        names = [
                'new notebook', 'open file', close_and_halt, '', \
                'duplicate notebook', rename, save, 'time travel', '', \
                'print preview', '<Download as...', '>nbconvert ipynb',  script_entry, '>nbconvert html', '>nbconvert markdown', '>nbconvert rst', '>nbconvert tex', '>nbconvert pdf',  '>nbconvert sagews', '', '>nbconvert slides', '>nbconvert asciidoc', '', \
                trust]
        if @props.fullscreen != 'kiosk'
            names.push('')
            names.push('switch to classical notebook')

        @render_menu
            heading : 'File'
            names   : names

    render_edit: ->
        cell_type = @props.cells?.get(@props.cur_id)?.get('cell_type')
{'fraction_non_alphanumeric': 0.12516521279407877, 'fraction_numerical': 0.0050224689399947136, 'mean_word_length': 1.875, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3419279', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2180, 'n_words': 466}