- fixes import with github, http,reslver-engine

- fixes tooltip for publish to gist
- add readonly mode(is not finished yet)
pull/5370/head
LianaHus 5 years ago
parent c0f6ee57f1
commit e272f8bd27
  1. 2
      src/app/files/file-explorer.js
  2. 15
      src/app/files/fileProvider.js
  3. 6
      src/app/ui/landing-page/landing-page.js

@ -350,7 +350,7 @@ fileExplorer.prototype.init = function () {
fileExplorer.prototype.publishToGist = function () { fileExplorer.prototype.publishToGist = function () {
modalDialogCustom.confirm( modalDialogCustom.confirm(
'Create a public gist', 'Create a public gist',
'Are you sure you want to publish all your files 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?',
() => { this.toGist() } () => { this.toGist() }
) )
} }

@ -6,6 +6,8 @@ class FileProvider {
constructor (name) { constructor (name) {
this.event = new EventManager() this.event = new EventManager()
this.type = name this.type = name
this.normalizedNames = {} // contains the raw url associated with the displayed path
this.readonlyItems = ['browser']
} }
exists (path, cb) { exists (path, cb) {
@ -23,6 +25,7 @@ class FileProvider {
get (path, cb) { get (path, cb) {
cb = cb || function () {} cb = cb || function () {}
if (this.normalizedNames[path]) path = this.normalizedNames[path] // ensure we actually use the normalized path from here
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
var exists = window.remixFileSystem.existsSync(unprefixedpath) var exists = window.remixFileSystem.existsSync(unprefixedpath)
if (!exists) return cb(null, null) if (!exists) return cb(null, null)
@ -63,15 +66,23 @@ class FileProvider {
return true return true
} }
addReadOnly (path, content) { addReadOnly (path, content, url) {
this.readonlyItems.push(path)
if (url !== undefined) this.normalizedNames[url] = path
return this.set(path, content) return this.set(path, content)
} }
isReadOnly (path) { isReadOnly (path) {
return false return !this.readonlyItems.includes(path)
} }
remove (path) { remove (path) {
// remove from readonly list
const indexToRemove = this.readonlyItems.indexOf(path)
if (indexToRemove !== -1) {
this.readonlyItems.splice(indexToRemove, 1)
}
var unprefixedpath = this.removePrefix(path) var unprefixedpath = this.removePrefix(path)
if (!this._exists(unprefixedpath)) { if (!this._exists(unprefixedpath)) {
return false return false

@ -110,10 +110,8 @@ export class LandingPage extends ViewPlugin {
if (error) { if (error) {
modalDialogCustom.alert(error) modalDialogCustom.alert(error)
} else { } else {
if (fileProviders[type]) { fileProviders['browser'].addReadOnly(type + '/' + cleanUrl, content, url)
fileProviders[type].addReadOnly(cleanUrl, content, url) globalRegistry.get('verticalicon').api.select('fileExplorers')
globalRegistry.get('verticalicon').api.select('fileExplorers')
}
} }
} }
) )

Loading…
Cancel
Save