@ -10,7 +10,6 @@ var Treeview = require('../ui/TreeView')
var modalDialog = require ( '../ui/modaldialog' )
var EventManager = require ( '../../lib/events' )
var contextMenu = require ( '../ui/contextMenu' )
var addTooltip = require ( '../ui/tooltip' )
var css = require ( './styles/file-explorer-styles' )
var globalRegistry = require ( '../../global/registry' )
var queryParams = new QueryParams ( )
@ -63,6 +62,8 @@ function fileExplorer (localRegistry, files, menuItems) {
fileManager : self . _components . registry . get ( 'filemanager' ) . api
}
self . _components . registry . put ( { api : self , name : ` fileexplorer/ ${ self . files . type } ` } )
// warn if file changed outside of Remix
function remixdDialog ( ) {
return yo ` <div>This file has been changed outside of Remix IDE.</div> `
@ -175,12 +176,12 @@ function fileExplorer (localRegistry, files, menuItems) {
MENU _HANDLE && MENU _HANDLE . hide ( null , true )
MENU _HANDLE = contextMenu ( event , {
'Rename' : ( ) => {
if ( self . files . readonly ) { return addT ooltip( 'cannot rename folder. ' + self . files . type + ' is a read only explorer' ) }
if ( self . files . readonly ) { return t ooltip( 'cannot rename folder. ' + self . files . type + ' is a read only explorer' ) }
var name = label . querySelector ( 'label[data-path="' + key + '"]' )
if ( name ) editModeOn ( name )
} ,
'Delete' : ( ) => {
if ( self . files . readonly ) { return addT ooltip( 'cannot delete folder. ' + self . files . type + ' is a read only explorer' ) }
if ( self . files . readonly ) { return t ooltip( 'cannot delete folder. ' + self . files . type + ' is a read only explorer' ) }
modalDialogCustom . confirm ( null , 'Do you want to delete this folder?' , ( ) => { files . remove ( key ) } , ( ) => { } )
}
} )
@ -191,12 +192,12 @@ function fileExplorer (localRegistry, files, menuItems) {
MENU _HANDLE && MENU _HANDLE . hide ( null , true )
MENU _HANDLE = contextMenu ( event , {
'Rename' : ( ) => {
if ( self . files . readonly ) { return addT ooltip( 'cannot rename file. ' + self . files . type + ' is a read only explorer' ) }
if ( self . files . readonly ) { return t ooltip( 'cannot rename file. ' + self . files . type + ' is a read only explorer' ) }
var name = label . querySelector ( 'label[data-path="' + key + '"]' )
if ( name ) editModeOn ( name )
} ,
'Delete' : ( ) => {
if ( self . files . readonly ) { return addT ooltip( 'cannot delete file. ' + self . files . type + ' is a read only explorer' ) }
if ( self . files . readonly ) { return t ooltip( 'cannot delete file. ' + self . files . type + ' is a read only explorer' ) }
modalDialogCustom . confirm ( null , 'Do you want to delete this file?' , ( ) => { files . remove ( key ) } , ( ) => { } )
}
} )
@ -427,7 +428,7 @@ fileExplorer.prototype.packageFiles = function (filesProvider, callback) {
else {
async . eachSeries ( Object . keys ( files ) , ( path , cb ) => {
filesProvider . get ( path , ( error , content ) => {
if ( /^\s+$/ . test ( content ) ) {
if ( /^\s+$/ . test ( content ) || ! content . length ) {
content = '// this line is added to create a gist. Empty file is not allowed.'
}
if ( error ) cb ( error )
@ -507,7 +508,7 @@ fileExplorer.prototype.renderMenuItems = function () {
items = this . menuItems . map ( ( { action , title , icon } ) => {
if ( action === 'uploadFile' ) {
return yo `
< label class = "${icon} ${css.newFile}" >
< label class = "${icon} ${css.newFile}" title = "${title}" >
< input type = "file" onchange = $ { ( event ) => {
event . stopPropagation ( )
this . uploadFile ( event )
@ -516,14 +517,12 @@ fileExplorer.prototype.renderMenuItems = function () {
`
} else {
return yo `
< span onclick = $ { ( event ) => { event . stopPropagation ( ) ; this [ action ] ( ) } } class = "newFile ${css.newFile}" title = $ { title } >
< i class = $ { icon } > < / i >
< / s p a n >
< span onclick = $ { ( event ) => { event . stopPropagation ( ) ; this [ action ] ( ) } } class = "newFile ${icon} ${css.newFile}" title = $ { title } > < / s p a n >
`
}
} )
}
return yo ` <span class= ${ css . menu } > ${ items } </span> `
return yo ` <span class=" ${ css . menu } " >${ items } </span> `
}
fileExplorer . prototype . ensureRoot = function ( cb ) {