From 146f8622d5bac2edc6b09f57c173bd057dfbcfad Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 8 Jul 2022 00:17:26 -0400 Subject: restructured currentUserUtils to avoid having import cycles. --- src/client/views/collections/CollectionView.tsx | 75 +++++++------------------ 1 file changed, 21 insertions(+), 54 deletions(-) (limited to 'src/client/views/collections/CollectionView.tsx') diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx index 1576ec40f..f38efe578 100644 --- a/src/client/views/collections/CollectionView.tsx +++ b/src/client/views/collections/CollectionView.tsx @@ -9,12 +9,13 @@ import { BoolCast, Cast, ScriptCast, StrCast } from '../../../fields/Types'; import { TraceMobx } from '../../../fields/util'; import { returnEmptyString } from '../../../Utils'; import { DocUtils } from '../../documents/Documents'; +import { CollectionViewType } from '../../documents/DocumentTypes'; import { BranchCreate, BranchTask } from '../../documents/Gitlike'; -import { CurrentUserUtils } from '../../util/CurrentUserUtils'; import { ImageUtils } from '../../util/Import & Export/ImageUtils'; import { InteractionUtils } from '../../util/InteractionUtils'; import { ContextMenu } from '../ContextMenu'; import { ContextMenuProps } from '../ContextMenuItem'; +import { DashboardView } from '../DashboardView'; import { ViewBoxAnnotatableComponent, ViewBoxAnnotatableProps } from '../DocComponent'; import { FieldView, FieldViewProps } from '../nodes/FieldView'; import { CollectionCarousel3DView } from './CollectionCarousel3DView'; @@ -35,26 +36,6 @@ import './CollectionView.scss'; export const COLLECTION_BORDER_WIDTH = 2; const path = require('path'); -export enum CollectionViewType { - Invalid = 'invalid', - Freeform = 'freeform', - Schema = 'schema', - Docking = 'docking', - Tree = 'tree', - Stacking = 'stacking', - Masonry = 'masonry', - Multicolumn = 'multicolumn', - Multirow = 'multirow', - Time = 'time', - Carousel = 'carousel', - Carousel3D = '3D Carousel', - Linear = 'linear', - //Staff = "staff", - Map = 'map', - Grid = 'grid', - Pile = 'pileup', - StackedTimeline = 'stacked timeline', -} interface CollectionViewProps_ extends FieldViewProps { isAnnotationOverlay?: boolean; // is the collection an annotation overlay (eg an overlay on an image/video/etc) isAnnotationOverlayScrollable?: boolean; // whether the annotation overlay can be vertically scrolled (just for tree views, currently) @@ -127,39 +108,26 @@ export class CollectionView extends ViewBoxAnnotatableComponent (this.props.renderDepth ? this.props.ScreenToLocalTransform() : this.props.ScreenToLocalTransform().scale(this.props.PanelWidth() / this.bodyPanelWidth())); + // prettier-ignore private renderSubView = (type: CollectionViewType | undefined, props: SubCollectionViewProps) => { TraceMobx(); if (type === undefined) return null; switch (type) { default: - case CollectionViewType.Freeform: - return ; - case CollectionViewType.Schema: - return ; - case CollectionViewType.Docking: - return ; - case CollectionViewType.Tree: - return ; - case CollectionViewType.Multicolumn: - return ; - case CollectionViewType.Multirow: - return ; - case CollectionViewType.Linear: - return ; - case CollectionViewType.Pile: - return ; - case CollectionViewType.Carousel: - return ; - case CollectionViewType.Carousel3D: - return ; - case CollectionViewType.Stacking: - return ; - case CollectionViewType.Masonry: - return ; - case CollectionViewType.Time: - return ; - case CollectionViewType.Grid: - return ; + case CollectionViewType.Freeform: return ; + case CollectionViewType.Schema: return ; + case CollectionViewType.Docking: return ; + case CollectionViewType.Tree: return ; + case CollectionViewType.Multicolumn: return ; + case CollectionViewType.Multirow: return ; + case CollectionViewType.Linear: return ; + case CollectionViewType.Pile: return ; + case CollectionViewType.Carousel: return ; + case CollectionViewType.Carousel3D: return ; + case CollectionViewType.Stacking: return ; + case CollectionViewType.Masonry: return ; + case CollectionViewType.Time: return ; + case CollectionViewType.Grid: return ; //case CollectionViewType.Staff: return ; } }; @@ -193,7 +161,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent { const cm = ContextMenu.Instance; if (e.nativeEvent.cancelBubble) return; // nested calls to React to render can cause the same event to trigger in the outer view even if the inner view has handled it. This avoid CollectionDockingView menu options from being added when the event has been handled by a sub-document. - if (cm && !e.isPropagationStopped() && this.rootDoc[Id] !== CurrentUserUtils.MainDocId) { + if (cm && !e.isPropagationStopped() && this.rootDoc[Id] !== Doc.MainDocId) { // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7 this.setupViewTypes( 'UI Controls...', @@ -235,7 +203,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent CurrentUserUtils.createNewDashboard(), icon: 'project-diagram' }); + optionItems.push({ description: 'Create Dashboard', event: () => DashboardView.createNewDashboard(), icon: 'project-diagram' }); } !options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'hand-point-right' }); @@ -286,9 +254,8 @@ export class CollectionView extends ViewBoxAnnotatableComponent { - return this.props.isContentActive(); - }; + isContentActive = (outsideReaction?: boolean) => this.props.isContentActive(); + render() { TraceMobx(); const props: SubCollectionViewProps = { -- cgit v1.2.3-70-g09d2