1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { observable, action, configure, reaction, computed } from 'mobx';
import { observer } from "mobx-react";
import * as request from 'request'
@observer
export class WorkspacesMenu extends React.Component {
static Instance: WorkspacesMenu;
@observable private workspacesExposed: boolean = false;
@observable private workspaceIds: Array<string> = [];
constructor(props: Readonly<{}>) {
super(props);
WorkspacesMenu.Instance = this;
}
toggle() {
action(() => {
if (!this.workspacesExposed) {
request.get(window.location.origin + "/getAllWorkspaceIds", (error, response, body) => {
this.workspaceIds = body;
console.log(this.workspaceIds);
})
}
this.workspacesExposed = !this.workspacesExposed;
});
}
render() {
return (
<div
style={{
width: "150px",
height: "150px",
position: "absolute",
top: 75,
right: 0,
background: "grey",
zIndex: 15,
visibility: this.workspacesExposed ? "visible" : "hidden"
}}
>
{this.workspaceIds.map(s => <li key={s} >${s}</li>)}
</div>
);
}
}
|