aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/button/FontIconBadge.tsx
diff options
context:
space:
mode:
authorgeireann <geireann.lindfield@gmail.com>2021-08-14 13:29:46 -0400
committergeireann <geireann.lindfield@gmail.com>2021-08-14 13:29:46 -0400
commitf5c126ba41bb15837c3527e588ba6fb3c79f3e89 (patch)
tree00b673b046f05fd5e2beaa4e83d14edcad4b43f5 /src/client/views/nodes/button/FontIconBadge.tsx
parent6d9c65bf95091b0d5ee7e3097995fc9e2ead4415 (diff)
code reorganising and updates
Diffstat (limited to 'src/client/views/nodes/button/FontIconBadge.tsx')
-rw-r--r--src/client/views/nodes/button/FontIconBadge.tsx37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client/views/nodes/button/FontIconBadge.tsx b/src/client/views/nodes/button/FontIconBadge.tsx
new file mode 100644
index 000000000..3be723052
--- /dev/null
+++ b/src/client/views/nodes/button/FontIconBadge.tsx
@@ -0,0 +1,37 @@
+
+import { AclPrivate, Doc, DocListCast } from '../../../../fields/Doc';
+import { GetEffectiveAcl } from '../../../../fields/util';
+import { emptyFunction, returnFalse, setupMoveUpEvents } from "../../../../Utils";
+import { DragManager } from '../../../util/DragManager';
+import './FontIconBox.scss';
+import { observer } from 'mobx-react';
+import React from 'react';
+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" style={{ width: 15, height: 15, top: 12 }} ref={this._notifsRef}>
+ <div className="fontIconBadge" style={length > 0 ? { "display": "initial" } : { "display": "none" }}
+ onPointerDown={this.onPointerDown} >
+ {length}
+ </div>
+ </div>;
+ }
+} \ No newline at end of file