aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJenny Yu <jennyyu212@outlook.com>2022-06-15 19:46:10 -0700
committerJenny Yu <jennyyu212@outlook.com>2022-06-15 19:46:10 -0700
commit6dc7a0d37f055c57135b91d4d54174ee156b61f5 (patch)
tree773979ac856ccbffb7ca2440f8f83ad628a0c0d1 /src
parent51c60d4d349c66432e57255f459c3d175ac3b251 (diff)
share and remove dashboard from context menu
Diffstat (limited to 'src')
-rw-r--r--src/client/util/CurrentUserUtils.ts7
-rw-r--r--src/client/views/DashboardView.tsx19
-rw-r--r--src/client/views/topbar/TopBar.tsx3
3 files changed, 15 insertions, 14 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 199ef701d..c0318e86b 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -1226,6 +1226,13 @@ export class CurrentUserUtils {
Doc.UserDoc().activeDashboard = undefined;
}
+ public static async removeDashboard(dashboard: Doc) {
+ const dashboards = await DocListCastAsync(CurrentUserUtils.MyDashboards.data);
+ if (dashboards && dashboards.length > 0) {
+ Doc.RemoveDocFromList(CurrentUserUtils.MyDashboards, "data", dashboard);
+ }
+ }
+
public static createNewDashboard = async (userDoc: Doc, id?: string, name?: string) => {
console.log(name)
const presentation = Doc.MakeCopy(userDoc.emptyPresentation as Doc, true);
diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index 716653ea5..37a70f165 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -14,6 +14,7 @@ import { DocumentManager } from "../util/DocumentManager";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ContextMenuProps } from "./ContextMenuItem";
import { simulateMouseClick } from "../../Utils";
+import { SharingManager } from "../util/SharingManager";
enum DashboardGroup {
MyDashboards, SharedDashboards
@@ -60,12 +61,6 @@ export class DashboardView extends React.Component {
this.abortCreateNewDashboard();
}
- showContextMenu = (e: React.MouseEvent) => {
- // DocumentViewInternal.SelectAfterContextMenu = false;
- // simulateMouseClick(this._docRef?.ContentDiv, e.clientX, e.clientY + 30, e.screenX, e.screenY + 30);
- // DocumentViewInternal.SelectAfterContextMenu = true;
- }
-
@computed
get namingInterface() {
return <div>
@@ -78,7 +73,7 @@ export class DashboardView extends React.Component {
_downX: number = 0;
_downY: number = 0;
@action
- onContextMenu = (e?: React.MouseEvent, pageX?: number, pageY?: number) => {
+ onContextMenu = (dashboard: Doc, e?: React.MouseEvent, pageX?: number, pageY?: number) => {
// the touch onContextMenu is button 0, the pointer onContextMenu is button 2
if (e) {
e.preventDefault();
@@ -91,12 +86,12 @@ export class DashboardView extends React.Component {
const cm = ContextMenu.Instance;
cm.addItem({
description: "Share Dashboard", event: async () => {
- // ...
+ SharingManager.Instance.open(undefined, dashboard)
}, icon: "edit"
});
cm.addItem({
description: "Delete Dashboard", event: async () => {
- // ...
+ CurrentUserUtils.removeDashboard(dashboard)
}, icon: "trash"
});
cm.displayMenu((e?.pageX || pageX || 0) - 15, (e?.pageY || pageY || 0) - 15);
@@ -116,7 +111,7 @@ export class DashboardView extends React.Component {
{this.getDashboards().map((dashboard) => {
const href = ImageCast((dashboard.thumb as Doc)?.data)?.url.href;
return <div className="dashboard-container" key={dashboard[Id]}
- onContextMenu={this.onContextMenu}
+ onContextMenu={(e) => {this.onContextMenu(dashboard, e)}}
onClick={e => this.clickDashboard(e, dashboard)}>
<img src={href ?? "https://media.istockphoto.com/photos/hot-air-balloons-flying-over-the-botan-canyon-in-turkey-picture-id1297349747?b=1&k=20&m=1297349747&s=170667a&w=0&h=oH31fJty_4xWl_JQ4OIQWZKP8C6ji9Mz7L4XmEnbqRU="}></img>
<div className="info">
@@ -124,7 +119,9 @@ export class DashboardView extends React.Component {
<div className="more" onPointerDown={e => {
this._downX = e.clientX;
this._downY = e.clientY;
- }} onClick={this.onContextMenu}>
+ }}
+ onContextMenu={(e) => {this.onContextMenu(dashboard, e)}}
+ >
<FontAwesomeIcon color="black" size="lg" icon="bars" />
</div>
</div>
diff --git a/src/client/views/topbar/TopBar.tsx b/src/client/views/topbar/TopBar.tsx
index 0665e79ed..e4f48adce 100644
--- a/src/client/views/topbar/TopBar.tsx
+++ b/src/client/views/topbar/TopBar.tsx
@@ -76,9 +76,6 @@ export class TopBar extends React.Component {
</div>
<div className="topbar-right" >
{CurrentUserUtils.ActiveDashboard ? <div className="topbar-button-text" onClick={() => { SharingManager.Instance.open(undefined, activeDashboard) }}>
- {/* TODO: if I have edit access to the dashboard, display share
- if this is a shared dashboard, display "view original or view annotated" */}
- {/* { Doc.GetProto(CurrentUserUtils.ActiveDashboard)?.author === Doc.CurrentUserEmail ? "Share": "view original" } */}
{GetEffectiveAcl(Doc.GetProto(CurrentUserUtils.ActiveDashboard)) === AclAdmin ? "Share" : "view original"}
</div> : (null)}
<div className="topbar-button-icon" onClick={() => window.open(