Show Dropbox unavailable in dev mode (#568)

This commit is contained in:
Rob Garrison 2018-11-20 17:32:03 -06:00 committed by GitHub
parent 33df061b53
commit 17339e933b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -1477,6 +1477,9 @@
"connectingDropbox": {
"message": "Connecting Dropbox..."
},
"connectingDropboxNotAllowed": {
"message": "Connecting to Dropbox is only available in apps installed directly from the webstore"
},
"gettingStyles": {
"message": "Getting all styles..."
},

View File

@ -51,6 +51,12 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
.then(() => new Promise(resolve => setTimeout(resolve, 100)))
.then(() => msg.broadcastExtension({method: 'optionsCustomizeHotkeys'}));
},
installType() {
// types: "admin", "development", "normal", "sideload" & "other"
// "normal" = addon installed from webstore
return chrome.management.getSelf(info => localStorage.installType = info.installType);
}
});
// eslint-disable-next-line no-var
@ -144,6 +150,8 @@ chrome.runtime.onInstalled.addListener(({reason}) => {
});
// themes may change
delete localStorage.codeMirrorThemes;
// save install type
window.API_METHODS.installType();
});
// *************************************************************************

View File

@ -46,8 +46,11 @@ function uploadFileDropbox(client, stylesText) {
}
$('#sync-dropbox-export').onclick = () => {
const mode = localStorage.installType;
const title = t('syncDropboxStyles');
messageProgressBar({title: title, text: t('connectingDropbox')});
const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
messageProgressBar({title, text});
if (mode !== 'normal') return;
hasDropboxAccessToken()
.then(token => token || requestDropboxAccessToken())
@ -116,8 +119,11 @@ $('#sync-dropbox-export').onclick = () => {
};
$('#sync-dropbox-import').onclick = () => {
const mode = localStorage.installType;
const title = t('retrieveDropboxSync');
messageProgressBar({title: title, text: t('connectingDropbox')});
const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
messageProgressBar({title, text});
if (mode !== 'normal') return;
hasDropboxAccessToken()
.then(token => token || requestDropboxAccessToken())