From 2263f412817d6d2d36372e7617feb0d97fa57af8 Mon Sep 17 00:00:00 2001
From: Jules Laplace <julescarbon@gmail.com>
Date: Tue, 4 Jul 2017 02:11:44 +0200
Subject: break out browser and tasks

---
 client/components/Browser/Folders/Folders.jsx | 56 +++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 client/components/Browser/Folders/Folders.jsx

(limited to 'client/components/Browser/Folders/Folders.jsx')

diff --git a/client/components/Browser/Folders/Folders.jsx b/client/components/Browser/Folders/Folders.jsx
new file mode 100644
index 0000000..2c85e80
--- /dev/null
+++ b/client/components/Browser/Folders/Folders.jsx
@@ -0,0 +1,56 @@
+import { h, Component } from 'preact'
+
+import Modal from '../../UI/Modal.jsx'
+import FolderForm from './FolderForm.jsx'
+
+import client from '../../../client.js'
+
+export default class Folders extends Component {
+  constructor(props) {
+    super()
+    this.state = {
+      adding: false,
+    }
+  }
+  openModal() {
+    this.setState({ adding: true })
+  }
+  closeModal() {
+    this.setState({ adding: false })
+  }
+  toggle(folder) {
+    folder.open = ! folder.open
+    if (folder.open && ! folder.files) {
+      client.file.index({ 'folder_id': folder.id }).then( files => {
+        console.log(files)
+        folder.files = files
+        this.props.openFolder(folder)
+      })
+    }
+  }
+  render() {
+    const folders = (this.props.folders || []).map( (folder,i) => {
+      return (
+        <div key={i} onClick={() => this.toggle(folder)}>
+          <span class='name'>{folder.name}</span>
+        </div>
+      )
+    })
+    return (
+      <div class='window'>
+        <div class='heading'>
+          <b>browser</b>
+          <div class='buttons'>
+            <button onClick={() => this.openModal()}>+ folder</button>
+          </div>
+        </div>
+        <div class='list'>
+          {folders}
+        </div>
+        <Modal visible={this.state.adding} onClose={() => this.closeModal()}>
+          <FolderForm addFolder={this.props.addFolder} onClose={() => this.closeModal()} />
+        </Modal>
+      </div>
+    )
+  }
+}
-- 
cgit v1.2.3-70-g09d2

