Browse Source

Added event listeners to folders/files.

Harry Hedger 9 years ago
parent
commit
f0b6738682
3 changed files with 10 additions and 2 deletions
  1. 8 1
      src/plugins/GoogleDrive.js
  2. 1 0
      website/src/examples/drive/app.es6
  3. 1 1
      website/src/examples/env.js

+ 8 - 1
src/plugins/GoogleDrive.js

@@ -21,6 +21,7 @@ export default class Google extends Plugin {
     this.opts = Object.assign({}, defaultOptions, opts)
     this.currentFolder = 'root'
     this.isAuthenticated = false
+    this.el = this.render(this.core.state)
   }
 
   focus () {
@@ -165,6 +166,12 @@ export default class Google extends Plugin {
     }
     const newEl = this.render(state)
     yo.update(this.el, newEl)
+
+    const folders = Utils.qsa('.GoogleDriveFolder')
+    const files = Utils.qsa('.GoogleDriveFile')
+
+    folders.forEach((folder) => folder.addEventListener('click', (e) => this.getFolder(folder.dataset.id)))
+    files.forEach((file) => file.addEventListener('click', (e) => this.getFile(file.dataset.id)))
   }
 
   updateState (newState) {
@@ -175,7 +182,7 @@ export default class Google extends Plugin {
   }
 
   render (state) {
-    if (state.googleDrive.authenticated) {
+    if (!state.googleDrive.authenticated) {
       return this.renderBrowser(state.googleDrive)
     } else {
       return this.renderAuth()

+ 1 - 0
website/src/examples/drive/app.es6

@@ -3,6 +3,7 @@ import { GoogleDrive } from 'uppy/plugins'
 // import ProgressDrawer from '../../../../src/plugins/ProgressDrawer.js'
 import { UPPY_SERVER } from '../env'
 console.log(UPPY_SERVER)
+console.log('beep')
 
 const uppy = new Uppy({debug: true, autoProceed: false})
 uppy

+ 1 - 1
website/src/examples/env.js

@@ -1,4 +1,4 @@
-let uppyServerEndpoint = 'http://localhost:3020'
+let uppyServerEndpoint = 'http://localhost:8080'
 
 if (location.hostname === 'uppy.io') {
   uppyServerEndpoint = 'http://server.uppy.io:3020'