remotestorage-widget
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "remotestorage-widget", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "remoteStorage.js connect widget", | ||
@@ -5,0 +5,0 @@ "main": "build/widget.js", |
@@ -45,4 +45,4 @@ # remotestorage-widget | ||
npm run dev | ||
npm start | ||
The demo app will then be served at http://localhost:8008 |
@@ -70,5 +70,3 @@ /** | ||
this.online = false; | ||
this.rsWidget.classList.remove('rs-backend-remotestorage'); | ||
this.rsWidget.classList.remove('rs-backend-dropbox'); | ||
this.rsWidget.classList.remove('rs-backend-googledrive'); | ||
this.setBackendClass(); // removes all backend CSS classes | ||
this.setState('initial'); | ||
@@ -89,3 +87,3 @@ break; | ||
this.rsConnectedUser.innerHTML = connectedUser; | ||
this.rsWidget.classList.add(`rs-backend-${this.rs.backend}`); | ||
this.setBackendClass(this.rs.backend); | ||
this.setState('connected'); | ||
@@ -104,2 +102,4 @@ break; | ||
case 'error': | ||
this.setBackendClass(this.rs.backend); | ||
if (msg.name === 'DiscoveryError') { | ||
@@ -186,3 +186,3 @@ this.handleDiscoveryError(msg); | ||
this.rsChooseGoogleDriveButton = document.querySelector('button.rs-choose-googledrive'); | ||
this.rsErrorBox = document.querySelector('.rs-box-error'); | ||
this.rsErrorBox = document.querySelector('.rs-box-error .rs-error-message'); | ||
@@ -205,2 +205,5 @@ // check if apiKeys is set for Dropbox or Google [googledrive, dropbox] | ||
this.rsErrorReconnectLink = document.querySelector('.rs-box-error a.rs-reconnect'); | ||
this.rsErrorDisconnectButton = document.querySelector('.rs-box-error button.rs-disconnect'); | ||
this.rsConnectedUser = document.querySelector('.rs-connected-text h1.rs-user'); | ||
@@ -292,2 +295,5 @@ }, | ||
this.rsErrorReconnectLink.addEventListener('click', () => this.rs.reconnect() ); | ||
this.rsErrorDisconnectButton.addEventListener('click', () => this.rs.disconnect() ); | ||
// Sync button | ||
@@ -337,3 +343,3 @@ if (this.rs.hasFeature('Sync')) { | ||
this.setState(this.active ? 'connected' : 'initial'); | ||
this.shouldCloseWhenSyncDone = false; | ||
this.shouldCloseWhenSyncDone = false; // prevent auto-closing when user opened the widget | ||
}, | ||
@@ -348,2 +354,5 @@ | ||
closeWidget () { | ||
// don't do anything when we have an error | ||
if (this.state === 'error') { return; } | ||
if (!this.leaveOpen && this.active) { | ||
@@ -357,2 +366,20 @@ this.setState('close'); | ||
/** | ||
* Set the remoteStorage backend type to show the appropriate icon. | ||
* If no backend is given, all existing backend CSS classes will be removed. | ||
* | ||
* @param {string} [backend] | ||
* | ||
* @private | ||
*/ | ||
setBackendClass (backend) { | ||
this.rsWidget.classList.remove('rs-backend-remotestorage'); | ||
this.rsWidget.classList.remove('rs-backend-dropbox'); | ||
this.rsWidget.classList.remove('rs-backend-googledrive'); | ||
if (backend) { | ||
this.rsWidget.classList.add(`rs-backend-${backend}`); | ||
} | ||
}, | ||
showErrorBox (errorMsg) { | ||
@@ -377,14 +404,15 @@ this.rsErrorBox.innerHTML = errorMsg; | ||
// console.debug('Encountered SyncError', error); | ||
this.openWidget(); | ||
this.showErrorBox('App sync error'); | ||
}, | ||
handleUnauthorized () { | ||
// console.debug('RS UNAUTHORIZED'); | ||
// console.debug('Bearer token not valid anymore'); | ||
// this.rs.stopSync(); | ||
// this.rsWidget.classList.add('rs-state-unauthorized'); | ||
this.showErrorBox('App authorization expired or revoked'); | ||
// this.lastSyncedUpdateLoop = setInterval(() => { | ||
// this.updateLastSyncedOutput(); | ||
// }, 5000); | ||
handleUnauthorized (error) { | ||
if (error.code && error.code === 'access_denied') { | ||
this.rs.disconnect(); | ||
} else { | ||
this.openWidget(); | ||
this.showErrorBox(error.message + " "); | ||
this.rsErrorBox.appendChild(this.rsErrorReconnectLink); | ||
this.rsErrorReconnectLink.classList.remove('hidden'); | ||
} | ||
}, | ||
@@ -391,0 +419,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
344883
971