     next_page : ->
         @props.actions.setState(page_number : @props.page_number + 1)
 
+    create_file : (ext) ->
+        if not ext? and @props.file_search?.lastIndexOf('.') <= @props.file_search?.lastIndexOf('/')
+            ext = "sagews"
+        @props.actions.create_file
+            name         : @props.file_search
+            ext          : ext
+            current_path : @props.current_path
+            on_download  : ((a) => @setState(download: a))
+            on_error     : ((a) => @setState(error: a))
+        @props.actions.setState(file_search : '', page_number: 0)
+
+    create_folder : ->
+        @props.actions.create_folder(@props.file_search, @props.current_path, (a) => setState(error: a))
+        @props.actions.setState(file_search : '', page_number: 0)
+
     render_paging_buttons : (num_pages) ->
         if num_pages > 1
             <Row>

            # Tell state to render an error in file search
            @props.actions.setState(create_file_alert : true)
        else
            @create_file(ext)

    # Go to new file tab if no file is specified
    handle_file_click : ->
        if @props.file_search.length == 0
            @props.actions.set_focused_page('project-new-file')
        else
            @create_file()

    create_file : (ext) ->
        if not ext and @props.file_search?.indexOf('.') == -1
            ext = "sagews"
        @props.actions.create_file
            name         : @props.file_search
            ext          : ext
            current_path : @props.current_path
            on_download  : ((a) => @setState(download: a))
            on_error     : ((a) => @setState(error: a))
        @props.actions.setState(file_search : '', page_number: 0)

    create_folder : ->
        @props.actions.create_folder(@props.file_search, @props.current_path, (a) => @setState(error: a))

    render : ->
        # This div prevents the split button from line-breaking when the page is small

NoFiles = rclass
    propTypes :
        actions     : rtypes.object.isRequired
        create_folder : rtypes.func.isRequired
        create_file   : rtypes.func.isRequired
        public_view : rtypes.bool
        file_search : rtypes.string
        current_path: rtypes.string

    displayName : 'ProjectFiles-NoFiles'

    # Determines whether or not an extension is given
    ext_defaulter : ->
