fixes after review

standard
pull/1/head
LianaHus 5 years ago
parent bc10720aeb
commit 70fbfbe227
  1. 12
      src/app/files/file-explorer.js
  2. 10
      src/app/files/fileProvider.js

@ -211,7 +211,8 @@ function fileExplorer (localRegistry, files, menuItems) {
if (key === self.files.type) return
MENU_HANDLE && MENU_HANDLE.hide(null, true)
let actions = {}
if (!self.files.readonly) {
const provider = self._deps.fileManager.fileProviderOf(key)
if (!provider.isReadOnly(key)) {
actions['Rename'] = () => {
if (self.files.readonly) { return tooltip('cannot rename file. ' + self.files.type + ' is a read only explorer') }
var name = label.querySelector('span[data-path="' + key + '"]')
@ -221,8 +222,7 @@ function fileExplorer (localRegistry, files, menuItems) {
if (self.files.readonly) { return tooltip('cannot delete file. ' + self.files.type + ' is a read only explorer') }
modalDialogCustom.confirm('Delete a file', 'Are you sure you want to delete this file?', () => { files.remove(key) }, () => {})
}
}
if (self.files.type !== 'browser') {
} else {
actions['Copy to Browser explorer'] = () => {
files.get(key, (error, content) => {
if (error) return tooltip(error)
@ -245,13 +245,13 @@ function fileExplorer (localRegistry, files, menuItems) {
// register to main app, trigger when the current file in the editor changed
self._deps.fileManager.events.on('currentFileChanged', (newFile) => {
const explorer = self._deps.fileManager.fileProviderOf(newFile)
const provider = self._deps.fileManager.fileProviderOf(newFile)
if (self.focusElement && self.focusPath !== newFile) {
self.focusElement.classList.remove('bg-secondary')
self.focusElement = null
self.focusPath = null
}
if (explorer && (explorer.type === files.type)) {
if (provider && (provider.type === files.type)) {
self.focusElement = self.treeView.labelAt(newFile)
if (self.focusElement) {
self.focusElement.classList.add('bg-secondary')
@ -350,7 +350,7 @@ fileExplorer.prototype.init = function () {
fileExplorer.prototype.publishToGist = function () {
modalDialogCustom.confirm(
'Create a public gist',
'Are you sure you want to publish all your files in browser directory anonymously as a public gist on github.com?',
'Are you sure you want to publish all your files in browser directory anonymously as a public gist on github.com? Note: this will not include directories.',
() => { this.toGist() }
)
}

@ -36,6 +36,10 @@ class FileProvider {
set (path, content, cb) {
cb = cb || function () {}
if (this.isReadOnly(path)) {
cb(new Error('It is not possible to modify a readonly item'))
return false
}
var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath)
if (!exists && unprefixedpath.indexOf('/') !== -1) {
@ -67,13 +71,13 @@ class FileProvider {
}
addReadOnly (path, content, url) {
this.readonlyItems.push(path)
if (url !== undefined) this.normalizedNames[url] = path
this.readonlyItems.push('browser/' + path)
if (!url) this.normalizedNames[url] = path
return this.set(path, content)
}
isReadOnly (path) {
return !this.readonlyItems.includes(path)
return this.readonlyItems.includes(path)
}
remove (path) {

Loading…
Cancel
Save