blob: cf86b5e075bd667fc9bb2a104397177ee2a7e3b2 (
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
|
import { observer } from "mobx-react";
import * as React from "react";
import { AclPrivate, Doc, DocListCast } from "../../../../fields/Doc";
import { GetEffectiveAcl } from "../../../../fields/util";
import { emptyFunction, returnFalse, setupMoveUpEvents } from "../../../../Utils";
import { DragManager } from "../../../util/DragManager";
import "./FontIconBadge.scss";
interface FontIconBadgeProps {
collection: Doc | undefined;
}
@observer
export class FontIconBadge extends React.Component<FontIconBadgeProps> {
_notifsRef = React.createRef<HTMLDivElement>();
onPointerDown = (e: React.PointerEvent) => {
setupMoveUpEvents(this, e,
(e: PointerEvent) => {
const dragData = new DragManager.DocumentDragData([this.props.collection!]);
DragManager.StartDocumentDrag([this._notifsRef.current!], dragData, e.x, e.y);
return true;
},
returnFalse, emptyFunction, false);
}
render() {
if (!(this.props.collection instanceof Doc)) return (null);
const length = DocListCast(this.props.collection.data).filter(d => GetEffectiveAcl(d) !== AclPrivate).length; // Object.keys(d).length).length; // filter out any documents that we can't read
return <div className="fontIconBadge-container" ref={this._notifsRef}>
<div className="fontIconBadge" style={length > 0 ? { "display": "initial" } : { "display": "none" }}
onPointerDown={this.onPointerDown} >
{length}
</div>
</div>;
}
}
|