From 5b2f422c6390d777c8a256db9882200c6071c081 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 26 Sep 2019 23:05:38 +0200 Subject: [PATCH] push to gist --- src/app/files/file-explorer.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/app/files/file-explorer.js b/src/app/files/file-explorer.js index 44be2a4e66..ab14aae341 100644 --- a/src/app/files/file-explorer.js +++ b/src/app/files/file-explorer.js @@ -190,6 +190,16 @@ function fileExplorer (localRegistry, files, menuItems) { } }) + /** + * Extracts furst two folders as a subpath from the path. + **/ + function extractExternalFolder (path) { + const firstSlIndex = path.indexOf('/', 1) + if (firstSlIndex === -1) return '' + const secondSlIndex = path.indexOf('/', firstSlIndex + 1) + if (secondSlIndex === -1) return '' + return path.substring(0, secondSlIndex) + } self.treeView.event.register('nodeRightClick', function (key, data, label, event) { if (self.files.readonly) return if (key === self.files.type) return @@ -206,9 +216,19 @@ function fileExplorer (localRegistry, files, menuItems) { ) } } else { - // extracts first two folders - const firstTwoFolders = key.substring(0, key.indexOf('/', key.indexOf('/', 1) + 1)) - if (!provider.isExternalFolder(firstTwoFolders)) { + const folderPath = extractExternalFolder(key) + if (folderPath === 'browser/gists') { + const id = key.substr(key.lastIndexOf('/'), key.length - 1) + actions['Push changes to gist'] = () => { + modalDialogCustom.confirm( + 'Push back to Gist', + 'Are you sure you want to push all your changes back to Gist?', + () => { this.toGist(id) }, + () => {} + ) + } + } + if (!provider.isExternalFolder(key)) { actions['Rename'] = () => { if (self.files.isReadOnly(key)) { return tooltip('cannot rename folder. ' + self.files.type + ' is a read only explorer') } var name = label.querySelector('span[data-path="' + key + '"]')