import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Button, FontSize, IconButton, Size } from 'browndash-components'; import { action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { FaBug, FaCamera } from 'react-icons/fa'; import { AclAdmin, Doc, DocListCast } from '../../../fields/Doc'; import { StrCast } from '../../../fields/Types'; import { GetEffectiveAcl } from '../../../fields/util'; import { DocumentManager } from '../../util/DocumentManager'; import { ReportManager } from '../../util/ReportManager'; import { SettingsManager } from '../../util/SettingsManager'; import { SharingManager } from '../../util/SharingManager'; import { UndoManager } from '../../util/UndoManager'; import { CollectionDockingView } from '../collections/CollectionDockingView'; import { ContextMenu } from '../ContextMenu'; import { DashboardView } from '../DashboardView'; import { Borders, Colors } from '../global/globalEnums'; import { MainView } from '../MainView'; import './TopBar.scss'; /** * ABOUT: This is the topbar in Dash, which included the current Dashboard as well as access to information on the user * and settings and help buttons. Future scope for this bar is to include the collaborators that are on the same Dashboard. */ @observer export class TopBar extends React.Component { navigateToHome = () => { (CollectionDockingView.Instance?.CaptureThumbnail() ?? new Promise(res => res())).then(() => { Doc.ActivePage = 'home'; DashboardView.closeActiveDashboard(); // bcz: if we do this, we need some other way to keep track, for user convenience, of the last dashboard in use }); }; @observable textColor: string = Colors.LIGHT_GRAY; @observable backgroundColor: string = Colors.DARK_GRAY; /** * Returns the left hand side of the topbar. * This side of the topbar contains the different modes. * The modes include: * - Explore mode * - Tracking mode */ @computed get topbarLeft() { return (
{Doc.ActiveDashboard ? ( } isCircle={true} hoverStyle="gray" color={this.textColor} /> ) : (
dash logo brown dash
)} {Doc.ActiveDashboard && !Doc.noviceMode && (
); } /** * Returns the center of the topbar * This part of the topbar contains everything related to the current dashboard including: * - Selection of dashboards * - Creating a new dashboard * - Taking a snapshot of a dashboard */ @computed get topbarCenter() { const myDashboards = DocListCast(Doc.MyDashboards.data); const activeDashboard = Doc.ActiveDashboard; // const dashboardItems = myDashboards.map(board => { // const boardTitle = StrCast(board.title); // console.log(boardTitle); // return { // text: boardTitle, // onClick: () => DashboardView.openDashboard(board), // val: board, // }; // }); return activeDashboard ? (
) : null; } /** * Returns the right hand side of the topbar. * This part of the topbar includes information about the current user, * and allows the user to access their account settings etc. */ @computed get topbarRight() { return (
ReportManager.Instance.open()} icon={} /> window.open('https://brown-dash.github.io/Dash-Documentation/', '_blank')} icon={} /> SettingsManager.Instance.open()} icon={} /> {/*
); } // render() { // const activeDashboard = Doc.ActiveDashboard; // return ( // //TODO:glr Add support for light / dark mode //
//
//
// {activeDashboard ? ( // <> //
{ // ContextMenu.Instance.addItem({ description: 'Logout', event: () => window.location.assign(Utils.prepend('/logout')), icon: 'edit' }); // ContextMenu.Instance.displayMenu(e.clientX + 5, e.clientY + 10); // }}> // {Doc.CurrentUserEmail} //
//
// //
// // ) : null} //
//
//
activeDashboard && SelectionManager.SelectView(DocumentManager.Instance.getDocumentView(activeDashboard)!, false)}> // {activeDashboard ? StrCast(activeDashboard.title) : 'Dash'} //
//
{ // const dashView = activeDashboard && DocumentManager.Instance.getDocumentView(activeDashboard); // ContextMenu.Instance.addItem({ description: 'Open Dashboard View', event: this.navigateToHome, icon: 'edit' }); // ContextMenu.Instance.addItem({ // description: 'Snapshot Dashboard', // event: async () => { // const batch = UndoManager.StartBatch('snapshot'); // await DashboardView.snapshotDashboard(); // batch.end(); // }, // icon: 'edit', // }); // dashView?.showContextMenu(e.clientX + 20, e.clientY + 30); // }}> // //
// Browsing mode for directly navigating to documents
} placement="bottom"> //
(MainView.Instance._exploreMode = !MainView.Instance._exploreMode))}> // //
// //
//
// {Doc.ActiveDashboard ? ( //
{ // SharingManager.Instance.open(undefined, activeDashboard); // }}> // {GetEffectiveAcl(Doc.GetProto(Doc.ActiveDashboard)) === AclAdmin ? 'Share' : 'view original'} //
// ) : null} //
ReportManager.Instance.open()}> // //
//
window.open('https://brown-dash.github.io/Dash-Documentation/', '_blank')}> // //
//
SettingsManager.Instance.open()}> // //
//
//
// // ); // } render() { return ( //TODO:glr Add support for light / dark mode
{this.topbarLeft} {this.topbarCenter} {this.topbarRight}
); } }