aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/MainView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-14 18:35:49 -0400
committerbobzel <zzzman@gmail.com>2025-04-14 18:35:49 -0400
commitd818ef151ca65008e5c6bb5e92b709decb3026d8 (patch)
treeae1d821c717cfb4b38c36b519d03b45ed90e9831 /src/client/views/MainView.tsx
parent1525fe600142d955fa24e939322f45cbca9d1cba (diff)
fixed how templates are expanded to avoid template sub-component conflicts by changing how field keys are named. fixed various Cast functions to be more typesafe by including undefined as part of return type. overhaul of Doc.MakeClone, MakeCopy, FindRefernces - makeClone is no longer async. fixed inlined docs in text docs.
Diffstat (limited to 'src/client/views/MainView.tsx')
-rw-r--r--src/client/views/MainView.tsx42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index be6e2fecb..ad6bb09c7 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -93,7 +93,7 @@ export class MainView extends ObservableReactComponent<object> {
@observable private _dashUIWidth: number = 0; // width of entire main dashboard region including left menu buttons and properties panel (but not including the dashboard selector button row)
@observable private _dashUIHeight: number = 0; // height of entire main dashboard region including top menu buttons
@observable private _panelContent: string = 'none';
- @observable private _sidebarContent: Doc = Doc.MyLeftSidebarPanel;
+ @observable private _sidebarContent?: Doc = Doc.MyLeftSidebarPanel;
@observable private _leftMenuFlyoutWidth: number = 0;
@computed get _hideUI() {
return SnappingManager.HideUI || (this.mainDoc && this.mainDoc._type_collection !== CollectionViewType.Docking);
@@ -173,7 +173,7 @@ export class MainView extends ObservableReactComponent<object> {
views => views.length > 1 && document.activeElement instanceof HTMLElement && document.activeElement?.blur()
);
reaction(
- () => Doc.MyDockedBtns.linearView_IsOpen,
+ () => Doc.MyDockedBtns?.linearView_IsOpen,
open => SnappingManager.SetPrintToConsole(!!open)
);
const scriptTag = document.createElement('script');
@@ -199,7 +199,7 @@ export class MainView extends ObservableReactComponent<object> {
ele.outerHTML = '';
}, 1000);
}
- this._sidebarContent.proto = undefined;
+ this._sidebarContent && (this._sidebarContent.proto = undefined);
if (!MainView.Live) {
DocServer.setLivePlaygroundFields([
'dataTransition',
@@ -636,8 +636,10 @@ export class MainView extends ObservableReactComponent<object> {
openPresentation = (pres: Doc) => {
if (pres.type === DocumentType.PRES) {
CollectionDockingView.AddSplit(pres, OpenWhereMod.right, undefined, PresBox.PanelName);
- Doc.MyTrails && (Doc.ActivePresentation = pres);
- Doc.AddDocToList(Doc.MyTrails, 'data', pres);
+ if (Doc.MyTrails) {
+ Doc.ActivePresentation = pres;
+ Doc.AddDocToList(Doc.MyTrails, 'data', pres);
+ }
this.closeFlyout();
}
};
@@ -645,16 +647,16 @@ export class MainView extends ObservableReactComponent<object> {
@action
createNewFolder = async () => {
const folder = Docs.Create.TreeDocument([], { title: 'Untitled folder', _dragOnlyWithinContainer: true, isFolder: true });
- Doc.AddDocToList(Doc.MyFilesystem, 'data', folder);
+ Doc.MyFilesystem && Doc.AddDocToList(Doc.MyFilesystem, 'data', folder);
};
waitForDoubleClick = () => (SnappingManager.ExploreMode ? 'never' : undefined);
headerBarScreenXf = () => new Transform(-this.leftScreenOffsetOfMainDocView - this.leftMenuFlyoutWidth(), -this.headerBarDocHeight(), 1);
mainScreenToLocalXf = () => new Transform(-this.leftScreenOffsetOfMainDocView - this.leftMenuFlyoutWidth(), -this.topOfMainDocContent, 1);
- addHeaderDoc = (docs: Doc | Doc[]) => toList(docs).reduce((done, doc) => Doc.AddDocToList(this.headerBarDoc, 'data', doc), true);
- removeHeaderDoc = (docs: Doc | Doc[]) => toList(docs).reduce((done, doc) => Doc.RemoveDocFromList(this.headerBarDoc, 'data', doc), true);
+ addHeaderDoc = (docs: Doc | Doc[]) => toList(docs).reduce((done, doc) => !!this.headerBarDoc && Doc.AddDocToList(this.headerBarDoc, 'data', doc), true);
+ removeHeaderDoc = (docs: Doc | Doc[]) => toList(docs).reduce((done, doc) => !!this.headerBarDoc && Doc.RemoveDocFromList(this.headerBarDoc, 'data', doc), true);
@computed get headerBarDocView() {
- return (
+ return !this.headerBarDoc ? null : (
<div className="mainView-headerBar" style={{ height: this.headerBarDocHeight() }}>
<DocumentView
key="headerBarDoc"
@@ -792,16 +794,16 @@ export class MainView extends ObservableReactComponent<object> {
<div key="flyout" className="mainView-libraryFlyout-out">
{this.docButtons}
</div>
- ) : (
+ ) : !this._sidebarContent ? null : (
<div key="libFlyout" className="mainView-libraryFlyout" style={{ minWidth: this._leftMenuFlyoutWidth, width: this._leftMenuFlyoutWidth }}>
<div className="mainView-contentArea">
<DocumentView
- Document={DocCast(this._sidebarContent.proto, this._sidebarContent)}
+ Document={DocCast(this._sidebarContent?.proto, this._sidebarContent)!}
addDocument={undefined}
addDocTab={DocumentViewInternal.addDocTabFunc}
pinToPres={DocumentView.PinDoc}
containerViewPath={returnEmptyDocViewList}
- styleProvider={this._sidebarContent.proto === Doc.MyDashboards || this._sidebarContent.proto === Doc.MyFilesystem || this._sidebarContent.proto === Doc.MyTrails ? DashboardStyleProvider : DefaultStyleProvider}
+ styleProvider={this._sidebarContent?.proto === Doc.MyDashboards || this._sidebarContent.proto === Doc.MyFilesystem || this._sidebarContent.proto === Doc.MyTrails ? DashboardStyleProvider : DefaultStyleProvider}
removeDocument={returnFalse}
ScreenToLocalTransform={this.mainContainerXf}
PanelWidth={this.leftMenuFlyoutWidth}
@@ -821,7 +823,7 @@ export class MainView extends ObservableReactComponent<object> {
}
@computed get leftMenuPanel() {
- return (
+ return !Doc.MyLeftSidebarMenu ? null : (
<div key="menu" className="mainView-leftMenuPanel" style={{ background: SnappingManager.userBackgroundColor, display: DocumentView.LightboxDoc() ? 'none' : undefined }}>
<DocumentView
Document={Doc.MyLeftSidebarMenu}
@@ -861,7 +863,7 @@ export class MainView extends ObservableReactComponent<object> {
break;
default:
this._leftMenuFlyoutWidth = this._leftMenuFlyoutWidth || 250;
- this._sidebarContent.proto = DocCast(button.target);
+ this._sidebarContent && (this._sidebarContent.proto = DocCast(button.target));
SnappingManager.SetLastPressedBtn(button[Id]);
}
}
@@ -875,8 +877,10 @@ export class MainView extends ObservableReactComponent<object> {
*/
addHotKey = (hotKey: string) => {
const filterIcons = DocCast(DocCast(Doc.UserDoc().myContextMenuBtns)?.Filter);
- const menuDoc = CurrentUserUtils.setupContextMenuBtn(CurrentUserUtils.filterBtnDesc(ToTagName(hotKey), 'question'), filterIcons);
- Doc.AddToFilterHotKeys(menuDoc);
+ if (filterIcons) {
+ const menuDoc = CurrentUserUtils.setupContextMenuBtn(CurrentUserUtils.filterBtnDesc(ToTagName(hotKey), 'question'), filterIcons);
+ Doc.AddToFilterHotKeys(menuDoc);
+ }
};
@computed get mainInnerContent() {
@@ -941,13 +945,13 @@ export class MainView extends ObservableReactComponent<object> {
closeFlyout = action(() => {
SnappingManager.SetLastPressedBtn('');
this._panelContent = 'none';
- this._sidebarContent.proto = undefined;
+ this._sidebarContent && (this._sidebarContent.proto = undefined);
this._leftMenuFlyoutWidth = 0;
});
- remButtonDoc = (docs: Doc | Doc[]) => toList(docs).reduce((flg: boolean, doc) => flg && !doc.dragOnlyWithinContainer && Doc.RemoveDocFromList(Doc.MyDockedBtns, 'data', doc), true);
+ remButtonDoc = (docs: Doc | Doc[]) => toList(docs).reduce((flg: boolean, doc) => flg && !doc.dragOnlyWithinContainer && !!Doc.MyDockedBtns && Doc.RemoveDocFromList(Doc.MyDockedBtns!, 'data', doc), true);
moveButtonDoc = (docs: Doc | Doc[], targetCol: Doc | undefined, addDocument: (document: Doc | Doc[]) => boolean) => this.remButtonDoc(docs) && addDocument(docs);
- addButtonDoc = (docs: Doc | Doc[]) => toList(docs).reduce((flg: boolean, doc) => flg && Doc.AddDocToList(Doc.MyDockedBtns, 'data', doc), true);
+ addButtonDoc = (docs: Doc | Doc[]) => toList(docs).reduce((flg: boolean, doc) => flg && !!Doc.MyDockedBtns && Doc.AddDocToList(Doc.MyDockedBtns!, 'data', doc), true);
buttonBarXf = () => {
if (!this._docBtnRef.current) return Transform.Identity();