From 46de0c33f92660266c4e72161e7f4d2f9d8439d1 Mon Sep 17 00:00:00 2001 From: Jenny Yu Date: Thu, 9 Jun 2022 21:20:27 -0700 Subject: feat: toggle my dashboards and shared dashboards --- src/client/views/DashboardView.scss | 9 +++++++++ src/client/views/DashboardView.tsx | 32 ++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/client/views/DashboardView.scss b/src/client/views/DashboardView.scss index 1896d7bfb..67587dd2b 100644 --- a/src/client/views/DashboardView.scss +++ b/src/client/views/DashboardView.scss @@ -17,7 +17,16 @@ } } +.text-button { + padding: 10px 0; + &:hover { + font-weight: 500; + } + &.selected { + font-weight: 700; + } +} .dashboard-container { border-radius: 10px; diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx index b08151c0f..e4e7e2dae 100644 --- a/src/client/views/DashboardView.tsx +++ b/src/client/views/DashboardView.tsx @@ -1,4 +1,4 @@ -import { observable } from "mobx"; +import { action, observable } from "mobx"; import { extname } from 'path'; import { observer } from "mobx-react"; import * as React from 'react'; @@ -9,11 +9,23 @@ import { CurrentUserUtils } from "../util/CurrentUserUtils"; import { UndoManager } from "../util/UndoManager"; import "./DashboardView.scss" +enum DashboardGroup { + MyDashboards, SharedDashboards +} + @observer export class DashboardView extends React.Component { //TODO: delete dashboard, share dashboard, etc. + @observable + private selectedDashboardGroup = DashboardGroup.MyDashboards; + + @action + selectDashboardGroup = (group: DashboardGroup) => { + this.selectedDashboardGroup = group + } + newDashboard = async () => { const batch = UndoManager.StartBatch("new dash"); await CurrentUserUtils.createNewDashboard(Doc.UserDoc()); @@ -27,15 +39,22 @@ export class DashboardView extends React.Component { } } + getDashboards = () => { + const allDashbaords = DocListCast(CurrentUserUtils.MyDashboards.data); + // TODO: filter the dashboards + // return allDashbaords.filter(...) + return allDashbaords + } + render() { - const myDashboards = DocListCast(CurrentUserUtils.MyDashboards.data); return
-
New
-
All Dashboards
+
New
+
this.selectDashboardGroup(DashboardGroup.MyDashboards) }>My Dashboards
+
this.selectDashboardGroup(DashboardGroup.SharedDashboards) }>Shared Dashboards
- {myDashboards.map((dashboard) => { + {this.getDashboards().map((dashboard) => { const url = ImageCast((dashboard.thumb as Doc)?.data)?.url; const ext = url ? extname(url.href):""; const href = url?.href.replace(ext, "_m"+ ext); // need to choose which resolution image to show. options are _s, _m, _l, _o (small/medium/large/original) @@ -45,9 +64,6 @@ export class DashboardView extends React.Component {
})} - {myDashboards.map((dashboard) => { - console.log(dashboard.thumb) - })}
-- cgit v1.2.3-70-g09d2