<commit_before>MenuBar = React.createFactory require './menu-bar-view'
ProviderTabbedDialog = React.createFactory require './provider-tabbed-dialog-view'

tr = require '../utils/translate'

{div, iframe} = React.DOM

InnerApp = React.createFactory React.createClass

  displayName: 'CloudFileManagerInnerApp'

  shouldComponentUpdate: (nextProps) ->
    nextProps.app isnt @props.app

  render: ->
    (div {className: 'innerApp'},
      (iframe {src: @props.app})
    )

App = React.createClass

  displayName: 'CloudFileManager'

  getFilename: ->
    if @props.client.state.metadata?.hasOwnProperty('name') then @props.client.state.metadata.name else (tr "~MENUBAR.UNTITLE_DOCUMENT")

  getInitialState: ->
    filename: @getFilename()
    menuItems: @props.client._ui.menu?.items or []
    menuOptions: @props.menuBar or {}
    providerDialog: null
    dirty: false

  componentWillMount: ->
    @props.client.listen (event) =>
      fileStatus = if event.state.saving
        {message: 'Saving...', type: 'info'}
      else if event.state.saved
        {message: 'Saved', type: 'info'}
      else if event.state.dirty
        {message: 'Unsaved', type: 'alert'}
      else
        null
      @setState
        filename: @getFilename()
        fileStatus: fileStatus

      switch event.type
        when 'connected'
          @setState menuItems: @props.client._ui.menu?.items or []

    @props.client._ui.listen (event) =>
      switch event.type
        when 'showProviderDialog'
          @setState providerDialog: event.data
        when 'appendMenuItem'
          @state.menuItems.push event.data
          @setState menuItems: @state.menuItems
        when 'setMenuBarInfo'
          @state.menuOptions.info = event.data
          @setState menuOptions: @state.menuOptions

  closeProviderDialog: ->
    @setState providerDialog: null

  render: ->
    if @props.usingIframe
      (div {className: 'app'},
        (MenuBar {filename: @state.filename, fileStatus: @state.fileStatus, options: @state.menuOptions})
        (InnerApp {app: @props.app})
        if @state.providerDialog
          (ProviderTabbedDialog {client: @props.client, dialog: @state.providerDialog, close: @closeProviderDialog})
      )
    else
      if @state.providerDialog
        (div {className: 'app'},
          (ProviderTabbedDialog {client: @props.client, dialog: @state.providerDialog, close: @closeProviderDialog})
        )
      else
        null

module.exports = App
<commit_msg>Added back missing menu items removed in last commit<commit_after>MenuBar = React.createFactory require './menu-bar-view'
ProviderTabbedDialog = React.createFactory require './provider-tabbed-dialog-view'

tr = require '../utils/translate'

{div, iframe} = React.DOM

InnerApp = React.createFactory React.createClass

  displayName: 'CloudFileManagerInnerApp'

  shouldComponentUpdate: (nextProps) ->
    nextProps.app isnt @props.app

  render: ->
    (div {className: 'innerApp'},
      (iframe {src: @props.app})
    )

App = React.createClass

  displayName: 'CloudFileManager'

  getFilename: ->
    if @props.client.state.metadata?.hasOwnProperty('name') then @props.client.state.metadata.name else (tr "~MENUBAR.UNTITLE_DOCUMENT")

  getInitialState: ->
    filename: @getFilename()
    menuItems: @props.client._ui.menu?.items or []
    menuOptions: @props.menuBar or {}
    providerDialog: null
    dirty: false

  componentWillMount: ->
    @props.client.listen (event) =>
      fileStatus = if event.state.saving
        {message: 'Saving...', type: 'info'}
      else if event.state.saved
        {message: 'Saved', type: 'info'}
      else if event.state.dirty
        {message: 'Unsaved', type: 'alert'}
      else
        null
      @setState
        filename: @getFilename()
        fileStatus: fileStatus

      switch event.type
        when 'connected'
          @setState menuItems: @props.client._ui.menu?.items or []

    @props.client._ui.listen (event) =>
      switch event.type
        when 'showProviderDialog'
          @setState providerDialog: event.data
        when 'appendMenuItem'
          @state.menuItems.push event.data
          @setState menuItems: @state.menuItems
        when 'setMenuBarInfo'
          @state.menuOptions.info = event.data
          @setState menuOptions: @state.menuOptions

  closeProviderDialog: ->
    @setState providerDialog: null

  render: ->
    if @props.usingIframe
      (div {className: 'app'},
        (MenuBar {filename: @state.filename, fileStatus: @state.fileStatus, items: @state.menuItems, options: @state.menuOptions})
        (InnerApp {app: @props.app})
        if @state.providerDialog
          (ProviderTabbedDialog {client: @props.client, dialog: @state.providerDialog, close: @closeProviderDialog})
      )
    else
      if @state.providerDialog
        (div {className: 'app'},
          (ProviderTabbedDialog {client: @props.client, dialog: @state.providerDialog, close: @closeProviderDialog})
        )
      else
        null

module.exports = App

{'fraction_non_alphanumeric': 0.12001594896331738, 'fraction_numerical': 0.0, 'mean_word_length': 2.871141975308642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2622161', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1446, 'n_words': 338}