From e5d7c2410fba8b4746217699333c9b7a3661e418 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Wed, 27 Feb 2019 11:29:55 -0500 Subject: workspaces toggle now loads ids --- .../authentication/controllers/WorkspacesMenu.tsx | 55 +++++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'src/server/authentication/controllers/WorkspacesMenu.tsx') diff --git a/src/server/authentication/controllers/WorkspacesMenu.tsx b/src/server/authentication/controllers/WorkspacesMenu.tsx index 77e3a9778..23a3d35da 100644 --- a/src/server/authentication/controllers/WorkspacesMenu.tsx +++ b/src/server/authentication/controllers/WorkspacesMenu.tsx @@ -3,6 +3,7 @@ import * as ReactDOM from 'react-dom'; import { observable, action, configure, reaction, computed } from 'mobx'; import { observer } from "mobx-react"; import * as request from 'request' +import './WorkspacesMenu.css' @observer export class WorkspacesMenu extends React.Component { @@ -15,33 +16,61 @@ export class WorkspacesMenu extends React.Component { WorkspacesMenu.Instance = this; } + @action toggle() { - action(() => { - if (!this.workspacesExposed) { - request.get(window.location.origin + "/getAllWorkspaceIds", (error, response, body) => { - this.workspaceIds = body; - console.log(this.workspaceIds); - }) + if (this.workspacesExposed) { + this.workspacesExposed = !this.workspacesExposed; + } else { + request.get(window.location.origin + "/getAllWorkspaceIds", this.idCallback) + } + } + + @action.bound + idCallback: request.RequestCallback = (error, response, body) => { + this.workspaceIds = []; + let ids: Array = JSON.parse(body) as Array; + if (ids) { + for (let i = 0; i < ids.length; i++) { + this.workspaceIds.push(ids[i]); } + console.log(this.workspaceIds); this.workspacesExposed = !this.workspacesExposed; - }); + } + } + + setWorkspaceId = (e: React.MouseEvent) => { + } render() { return (
- {this.workspaceIds.map(s =>
  • ${s}
  • )} + {this.workspaceIds.map(s => +
  • {s}
  • + )}
    ); } -- cgit v1.2.3-70-g09d2