blob: c4798e6a93720f64ad89105c881b551908f53947 (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
import * as React from "react";
import { observable, action } from "mobx";
import { SelectionManager } from "./SelectionManager";
import MainViewModal from "../views/MainViewModal";
import { observer } from "mobx-react";
import { Doc, DocListCast } from "../../fields/Doc";
import { List } from "../../fields/List";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as fa from '@fortawesome/free-solid-svg-icons';
import { library } from "@fortawesome/fontawesome-svg-core";
library.add(fa.faWindowClose);
@observer
export default class GroupManager extends React.Component<{}> {
static Instance: GroupManager;
@observable private isOpen: boolean = false; // whether the menu is open or not
@observable private dialogueBoxOpacity: number = 1;
@observable private overlayOpacity: number = 0.4;
constructor(props: Readonly<{}>) {
super(props);
GroupManager.Instance = this;
}
open = action(() => {
SelectionManager.DeselectAll();
this.isOpen = true;
});
close = action(() => {
this.isOpen = false;
});
get GroupManagerDoc(): Doc | undefined {
return Doc.UserDoc().globalGroupDatabase as Doc;
}
getAllGroups(): Doc[] {
const groupDoc = GroupManager.Instance.GroupManagerDoc;
return groupDoc ? DocListCast(groupDoc.data) : [];
}
addGroup(groupDoc: Doc): boolean {
const groupList = GroupManager.Instance.getAllGroups();
groupList.push(groupDoc);
if (GroupManager.Instance.GroupManagerDoc) {
GroupManager.Instance.GroupManagerDoc.data = new List<Doc>(groupList);
return true;
}
return false;
}
deleteGroup(groupDoc: Doc): boolean {
const groupList = GroupManager.Instance.getAllGroups();
const index = groupList.indexOf(groupDoc);
if (index !== -1) {
groupList.splice(index, 1);
if (GroupManager.Instance.GroupManagerDoc) {
GroupManager.Instance.GroupManagerDoc.data = new List<Doc>(groupList);
return true;
}
}
return false;
}
private get groupInterface() {
return (
<div className="settings-interface">
<div className="settings-heading">
<h1>Groups</h1>
<div className={"close-button"} onClick={this.close}>
<FontAwesomeIcon icon={fa.faWindowClose} size={"lg"} />
</div>
</div>
<div className="settings-body">
<div className="settings-type">
<button value="password">reset password</button>
<button value="data">{`toggle novice mode`}</button>
</div>
</div>
</div>
);
}
render() {
return (
<MainViewModal
contents={this.groupInterface}
isDisplayed={this.isOpen}
interactive={true}
dialogueBoxDisplayedOpacity={this.dialogueBoxOpacity}
overlayDisplayedOpacity={this.overlayOpacity}
/>
);
}
}
|