@deephaven/dashboard 0.17.1-beta.2 → 0.17.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dashboard.d.ts +3 -2
- package/dist/Dashboard.d.ts.map +1 -1
- package/dist/Dashboard.js +1 -1
- package/dist/Dashboard.js.map +1 -1
- package/dist/DashboardLayout.d.ts +2 -1
- package/dist/DashboardLayout.d.ts.map +1 -1
- package/dist/DashboardLayout.js.map +1 -1
- package/dist/PanelErrorBoundary.d.ts +1 -1
- package/dist/PanelErrorBoundary.d.ts.map +1 -1
- package/dist/PanelErrorBoundary.js.map +1 -1
- package/dist/PanelManager.d.ts +2 -1
- package/dist/PanelManager.d.ts.map +1 -1
- package/dist/PanelManager.js.map +1 -1
- package/dist/layout/GoldenLayout.css +460 -0
- package/dist/layout/GoldenLayout.css.map +1 -1
- package/dist/layout/GoldenLayout.module.css +460 -0
- package/dist/layout/GoldenLayout.module.css.map +1 -1
- package/dist/layout/LayoutUtils.d.ts +2 -1
- package/dist/layout/LayoutUtils.d.ts.map +1 -1
- package/dist/layout/LayoutUtils.js.map +1 -1
- package/package.json +9 -10
- package/dist/layout/ReactDOM.d.ts +0 -2
- package/dist/layout/ReactDOM.d.ts.map +0 -1
- package/dist/layout/ReactDOM.js +0 -6
- package/dist/layout/ReactDOM.js.map +0 -1
- package/dist/layout/golden-layout.d.ts +0 -7
- package/dist/layout/golden-layout.d.ts.map +0 -1
- package/dist/layout/golden-layout.js +0 -7
- package/dist/layout/golden-layout.js.map +0 -1
- package/dist/layout/jquery.d.ts +0 -2
- package/dist/layout/jquery.d.ts.map +0 -1
- package/dist/layout/jquery.js +0 -5
- package/dist/layout/jquery.js.map +0 -1
package/dist/Dashboard.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
-
import GoldenLayout
|
|
3
|
-
import '
|
|
2
|
+
import GoldenLayout from '@deephaven/golden-layout';
|
|
3
|
+
import type { ItemConfigType } from '@deephaven/golden-layout';
|
|
4
|
+
import './layout/GoldenLayout.scss';
|
|
4
5
|
import { PanelDehydrateFunction, PanelHydrateFunction, PanelProps } from './DashboardPlugin';
|
|
5
6
|
import './Dashboard.scss';
|
|
6
7
|
export declare type DashboardProps = {
|
package/dist/Dashboard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../src/Dashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,yBAAyB,EACzB,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,YAAY,
|
|
1
|
+
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../src/Dashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,yBAAyB,EACzB,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,4BAA4B,CAAC;AAIpC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,kBAAkB,CAAC;AAQ1B,oBAAY,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC/C,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5D,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,yBAAyB,CAC3C,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAC3C,CAAC;IACF,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,SAAS,4KAYnB,cAAc,KAAG,WAwFnB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/Dashboard.js
CHANGED
|
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import throttle from 'lodash.throttle';
|
|
9
9
|
import GoldenLayout from '@deephaven/golden-layout';
|
|
10
|
-
import "./layout/
|
|
10
|
+
import "./layout/GoldenLayout.css";
|
|
11
11
|
import LayoutUtils from "./layout/LayoutUtils.js";
|
|
12
12
|
import PanelPlaceholder from "./PanelPlaceholder.js";
|
|
13
13
|
import DashboardLayout from "./DashboardLayout.js";
|
package/dist/Dashboard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.js","names":["React","useEffect","useMemo","useRef","useState","throttle","GoldenLayout","LayoutUtils","PanelPlaceholder","DashboardLayout","RESIZE_THROTTLE","DEFAULT_CALLBACK","undefined","EMPTY_OBJECT","Object","freeze","Dashboard","id","children","emptyDashboard","layoutConfig","layoutSettings","onLayoutConfigChange","onGoldenLayoutChange","onLayoutInitialized","fallbackComponent","hydrate","dehydrate","layoutElement","isInitialized","setIsInitialized","layout","setLayout","initDashboard","current","config","makeDefaultLayout","assign","settings","content","newLayout","onInit","off","on","setFallbackComponent","init","destroy","handleResize","isInitialised","updateSize","initResizeEventListner","window","addEventListener","removeEventListener"],"sources":["../src/Dashboard.tsx"],"sourcesContent":["import React, {\n ForwardRefExoticComponent,\n RefAttributes,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport GoldenLayout
|
|
1
|
+
{"version":3,"file":"Dashboard.js","names":["React","useEffect","useMemo","useRef","useState","throttle","GoldenLayout","LayoutUtils","PanelPlaceholder","DashboardLayout","RESIZE_THROTTLE","DEFAULT_CALLBACK","undefined","EMPTY_OBJECT","Object","freeze","Dashboard","id","children","emptyDashboard","layoutConfig","layoutSettings","onLayoutConfigChange","onGoldenLayoutChange","onLayoutInitialized","fallbackComponent","hydrate","dehydrate","layoutElement","isInitialized","setIsInitialized","layout","setLayout","initDashboard","current","config","makeDefaultLayout","assign","settings","content","newLayout","onInit","off","on","setFallbackComponent","init","destroy","handleResize","isInitialised","updateSize","initResizeEventListner","window","addEventListener","removeEventListener"],"sources":["../src/Dashboard.tsx"],"sourcesContent":["import React, {\n ForwardRefExoticComponent,\n RefAttributes,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport throttle from 'lodash.throttle';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type { ItemConfigType } from '@deephaven/golden-layout';\nimport './layout/GoldenLayout.scss';\nimport LayoutUtils from './layout/LayoutUtils';\nimport PanelPlaceholder from './PanelPlaceholder';\nimport DashboardLayout from './DashboardLayout';\nimport {\n PanelDehydrateFunction,\n PanelHydrateFunction,\n PanelProps,\n} from './DashboardPlugin';\nimport './Dashboard.scss';\n\nconst RESIZE_THROTTLE = 100;\n\nconst DEFAULT_CALLBACK = () => undefined;\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nexport type DashboardProps = {\n id?: string;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n layoutConfig?: ItemConfigType[];\n layoutSettings?: Record<string, unknown>;\n onLayoutConfigChange?: () => void;\n onGoldenLayoutChange?: (goldenLayout: GoldenLayout) => void;\n onLayoutInitialized?: () => void;\n fallbackComponent?: ForwardRefExoticComponent<\n PanelProps & RefAttributes<HTMLDivElement>\n >;\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n};\n\nexport const Dashboard = ({\n id = 'default',\n children,\n emptyDashboard,\n layoutConfig,\n layoutSettings = EMPTY_OBJECT,\n onLayoutConfigChange = DEFAULT_CALLBACK,\n onGoldenLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n fallbackComponent = PanelPlaceholder,\n hydrate,\n dehydrate,\n}: DashboardProps): JSX.Element => {\n const layoutElement = useRef<HTMLDivElement>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [layout, setLayout] = useState<GoldenLayout>();\n\n useEffect(\n function initDashboard() {\n if (!layoutElement.current) {\n setLayout(undefined);\n return;\n }\n const config: GoldenLayout.Config = {\n ...LayoutUtils.makeDefaultLayout(),\n };\n Object.assign(config.settings, layoutSettings);\n // Load our content later after plugins have registered\n config.content = [];\n\n const newLayout = new GoldenLayout(config, layoutElement.current);\n\n const onInit = () => {\n newLayout.off('initialised', onInit);\n setIsInitialized(true);\n };\n newLayout.on('initialised', onInit);\n\n if (fallbackComponent) {\n newLayout.setFallbackComponent(fallbackComponent);\n }\n\n newLayout.init();\n\n setLayout(newLayout);\n\n onGoldenLayoutChange(newLayout);\n\n return () => {\n newLayout.destroy();\n };\n },\n [\n layoutSettings,\n fallbackComponent,\n onGoldenLayoutChange,\n setIsInitialized,\n setLayout,\n ]\n );\n\n const handleResize = useMemo(\n () =>\n throttle(() => {\n if (layout?.isInitialised) {\n layout?.updateSize();\n }\n }, RESIZE_THROTTLE),\n [layout]\n );\n\n useEffect(\n function initResizeEventListner() {\n window.addEventListener('resize', handleResize);\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n },\n [handleResize]\n );\n\n return (\n <div className=\"dashboard-container w-100 h-100\">\n <div className=\"w-100 h-100\" ref={layoutElement} />\n {isInitialized && layout && (\n <DashboardLayout\n emptyDashboard={emptyDashboard}\n id={id}\n layout={layout}\n layoutConfig={layoutConfig}\n onLayoutChange={onLayoutConfigChange}\n onLayoutInitialized={onLayoutInitialized}\n hydrate={hydrate}\n dehydrate={dehydrate}\n >\n {children}\n </DashboardLayout>\n )}\n </div>\n );\n};\n\nexport default Dashboard;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAGEC,SAHF,EAIEC,OAJF,EAKEC,MALF,EAMEC,QANF,QAOO,OAPP;AAQA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;;OAGOC,W;OACAC,gB;OACAC,e;;AAQP,IAAMC,eAAe,GAAG,GAAxB;;AAEA,IAAMC,gBAAgB,GAAG,MAAMC,SAA/B;;AAEA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,CAArB;AAkBA,OAAO,IAAMC,SAAS,GAAG,QAYU;EAAA,IAZT;IACxBC,EAAE,GAAG,SADmB;IAExBC,QAFwB;IAGxBC,cAHwB;IAIxBC,YAJwB;IAKxBC,cAAc,GAAGR,YALO;IAMxBS,oBAAoB,GAAGX,gBANC;IAOxBY,oBAAoB,GAAGZ,gBAPC;IAQxBa,mBAAmB,GAAGb,gBARE;IASxBc,iBAAiB,GAAGjB,gBATI;IAUxBkB,OAVwB;IAWxBC;EAXwB,CAYS;EACjC,IAAMC,aAAa,GAAGzB,MAAM,CAAiB,IAAjB,CAA5B;EACA,IAAM,CAAC0B,aAAD,EAAgBC,gBAAhB,IAAoC1B,QAAQ,CAAC,KAAD,CAAlD;EACA,IAAM,CAAC2B,MAAD,EAASC,SAAT,IAAsB5B,QAAQ,EAApC;EAEAH,SAAS,CACP,SAASgC,aAAT,GAAyB;IACvB,IAAI,CAACL,aAAa,CAACM,OAAnB,EAA4B;MAC1BF,SAAS,CAACpB,SAAD,CAAT;MACA;IACD;;IACD,IAAMuB,MAA2B,qBAC5B5B,WAAW,CAAC6B,iBAAZ,EAD4B,CAAjC;;IAGAtB,MAAM,CAACuB,MAAP,CAAcF,MAAM,CAACG,QAArB,EAA+Bj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AA6B,GAAG,EAAEnB;EAAlC,EADF,EAEGC,aAAa,IAAIE,MAAjB,iBACC,oBAAC,eAAD;IACE,cAAc,EAAEZ,cADlB;IAEE,EAAE,EAAEF,EAFN;IAGE,MAAM,EAAEc,MAHV;IAIE,YAAY,EAAEX,YAJhB;IAKE,cAAc,EAAEE,oBALlB;IAME,mBAAmB,EAAEE,mBANvB;IAOE,OAAO,EAAEE,OAPX;IAQE,SAAS,EAAEC;EARb,GAUGT,QAVH,CAHJ,CADF;AAmBD,CApGM;AAsGP,eAAeF,SAAf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import GoldenLayout
|
|
3
|
+
import GoldenLayout from '@deephaven/golden-layout';
|
|
4
|
+
import type { ItemConfigType } from '@deephaven/golden-layout';
|
|
4
5
|
import { ClosedPanels } from './PanelManager';
|
|
5
6
|
import { PanelDehydrateFunction, PanelHydrateFunction } from './DashboardPlugin';
|
|
6
7
|
export declare type DashboardLayoutConfig = ItemConfigType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardLayout.d.ts","sourceRoot":"","sources":["../src/DashboardLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,
|
|
1
|
+
{"version":3,"file":"DashboardLayout.d.ts","sourceRoot":"","sources":["../src/DashboardLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAKlC,OAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU5D,OAAO,EAEL,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,oBAAY,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAarD,aAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,EAAE,EAAE,MAAM,CAAC;IAGX,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACnE,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC/C,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;uHAUzB,oBAAoB,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;;;CA6NpC,CAAC;AAaF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","Provider","useDispatch","useSelector","useStore","PanelManager","PanelErrorBoundary","LayoutUtils","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","hydrateMap","Map","dehydrateMap","store","registerComponent","name","componentType","componentHydrate","componentDehydrate","debug2","renderComponent","ref","CType","glContainer","glEventHub","wrappedComponent","forwardRef","cleanup","set","hydrateComponent","get","dehydrateComponent","config","panelManager","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","length","handleLayoutItemPickedUp","handleLayoutItemDropped","handleComponentCreated","item","component","element","cssComponent","replace","toLowerCase","cssClass","addClass","eventHub","TITLE_CHANGED","previousLayoutConfig","loadNewConfig","hydrateLayoutConfig","remove","i","addChild","Children","map","child","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport GoldenLayout, {\n Container,\n EventEmitter,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious } from '@deephaven/react-hooks';\nimport { RootState } from '@deephaven/redux';\nimport { Provider, useDispatch, useSelector, useStore } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n dehydrate as dehydrateDefault,\n hydrate as hydrateDefault,\n} from './DashboardUtils';\nimport PanelEvent from './PanelEvent';\nimport { GLPropTypes, useListener } from './layout';\nimport { getDashboardData, updateDashboardData } from './redux';\nimport {\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from './DashboardPlugin';\n\nexport type DashboardLayoutConfig = ItemConfigType[];\n\nconst log = Log.module('DashboardLayout');\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst DEFAULT_LAYOUT_CONFIG: DashboardLayoutConfig = [];\n\nconst DEFAULT_CALLBACK = () => undefined;\n\n// If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later\nconst FALLBACK_CALLBACK = (props: unknown) => props;\n\ntype DashboardData = {\n closed?: ClosedPanels;\n};\n\ninterface DashboardLayoutProps {\n id: string;\n\n // Default hydrate/dehydration functions\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n layout: GoldenLayout;\n layoutConfig?: DashboardLayoutConfig;\n onLayoutChange?: (dehydratedLayout: DashboardLayoutConfig) => void;\n onLayoutInitialized?: () => void;\n data?: DashboardData;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n}\n\n/**\n * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.\n */\nexport const DashboardLayout = ({\n id,\n children,\n emptyDashboard = <div>Dashboard is empty.</div>,\n layout,\n layoutConfig = DEFAULT_LAYOUT_CONFIG,\n onLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n hydrate = hydrateDefault,\n dehydrate = dehydrateDefault,\n}: DashboardLayoutProps): JSX.Element => {\n const dispatch = useDispatch();\n const data =\n useSelector<RootState>(state => getDashboardData(state, id)) ??\n EMPTY_OBJECT;\n\n const [isDashboardEmpty, setIsDashboardEmpty] = useState(false);\n const [isItemDragging, setIsItemDragging] = useState(false);\n const [lastConfig, setLastConfig] = useState<DashboardLayoutConfig>();\n const [initialClosedPanels] = useState<ReactComponentConfig[] | undefined>(\n (data as DashboardData)?.closed ?? []\n );\n const [isDashboardInitialized, setIsDashboardInitialized] = useState(false);\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\n const store = useStore();\n const registerComponent = useCallback(\n (\n name: string,\n componentType: PanelComponentType,\n componentHydrate = hydrate,\n componentDehydrate = dehydrate\n ) => {\n log.debug2(\n 'registerComponent',\n name,\n componentType,\n componentHydrate,\n componentDehydrate\n );\n\n function renderComponent(\n props: { glContainer: Container; glEventHub: EventEmitter },\n ref: unknown\n ) {\n // Cast it to an `any` type so we can pass the ref in correctly.\n // ComponentType doesn't seem to work right, ReactNode is also incorrect\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n\n // Props supplied by GoldenLayout\n // eslint-disable-next-line react/prop-types\n const { glContainer, glEventHub } = props;\n return (\n <Provider store={store}>\n <PanelErrorBoundary\n glContainer={glContainer}\n glEventHub={glEventHub}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <CType {...props} ref={ref} />\n </PanelErrorBoundary>\n </Provider>\n );\n }\n\n const wrappedComponent = React.forwardRef(renderComponent);\n const cleanup = layout.registerComponent(name, wrappedComponent);\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, store]\n );\n const hydrateComponent = useCallback(\n (name, props) => (hydrateMap.get(name) ?? FALLBACK_CALLBACK)(props, id),\n [hydrateMap, id]\n );\n const dehydrateComponent = useCallback(\n (name, config) => (dehydrateMap.get(name) ?? FALLBACK_CALLBACK)(config, id),\n [dehydrateMap, id]\n );\n const panelManager = useMemo(\n () =>\n new PanelManager(\n layout,\n hydrateComponent,\n dehydrateComponent,\n new Map(),\n initialClosedPanels,\n ({ closed, openedMap }) => {\n dispatch(updateDashboardData(id, { closed, openedMap }));\n }\n ),\n [\n dehydrateComponent,\n dispatch,\n hydrateComponent,\n id,\n initialClosedPanels,\n layout,\n ]\n );\n\n const handleLayoutStateChanged = useCallback(() => {\n // we don't want to emit stateChanges that happen during item drags or else\n // we risk the last saved state being one without that panel in the layout entirely\n if (isItemDragging) return;\n\n if (!isDashboardInitialized) {\n onLayoutInitialized();\n setIsDashboardInitialized(true);\n }\n\n const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug(\n 'handleLayoutStateChanged',\n hasChanged,\n contentConfig,\n dehydratedLayoutConfig\n );\n\n if (hasChanged) {\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n\n setLastConfig(dehydratedLayoutConfig);\n\n onLayoutChange(dehydratedLayoutConfig);\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(() => {\n setIsItemDragging(true);\n }, []);\n\n const handleLayoutItemDropped = useCallback(() => {\n setIsItemDragging(false);\n }, []);\n\n const handleComponentCreated = useCallback(item => {\n log.debug2('handleComponentCreated', item);\n\n if (!item || !item.config || !item.config.component || !item.element) {\n return;\n }\n\n const cssComponent = item.config.component\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n const cssClass = `${cssComponent}-component`;\n item.element.addClass(cssClass);\n }, []);\n\n useListener(layout, 'stateChanged', handleLayoutStateChanged);\n useListener(layout, 'itemPickedUp', handleLayoutItemPickedUp);\n useListener(layout, 'itemDropped', handleLayoutItemDropped);\n useListener(layout, 'componentCreated', handleComponentCreated);\n useListener(\n layout.eventHub,\n PanelEvent.TITLE_CHANGED,\n handleLayoutStateChanged\n );\n\n const previousLayoutConfig = usePrevious(layoutConfig);\n useEffect(\n function loadNewConfig() {\n if (\n previousLayoutConfig !== layoutConfig &&\n layoutConfig !== lastConfig\n ) {\n log.debug('Setting new layout content...');\n const content = LayoutUtils.hydrateLayoutConfig(\n layoutConfig,\n hydrateComponent\n );\n // Remove the old layout before add the new one\n while (layout.root.contentItems.length > 0) {\n layout.root.contentItems[0].remove();\n }\n\n // Add the new content. It is usally just one item from the root\n for (let i = 0; i < content.length; i += 1) {\n layout.root.addChild(content[i]);\n }\n\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n }\n },\n [\n hydrateComponent,\n layout,\n layoutConfig,\n lastConfig,\n panelManager,\n previousLayoutConfig,\n ]\n );\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {React.Children.map(children, child =>\n child\n ? React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })\n : null\n )}\n </>\n );\n};\n\nDashboardLayout.propTypes = {\n id: PropTypes.string.isRequired,\n children: PropTypes.node,\n data: PropTypes.shape({}),\n emptyDashboard: PropTypes.node,\n layout: GLPropTypes.Layout.isRequired,\n layoutConfig: PropTypes.arrayOf(PropTypes.shape({})),\n onLayoutChange: PropTypes.func,\n onLayoutInitialized: PropTypes.func,\n};\n\nexport default DashboardLayout;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAEEC,WAFF,EAGEC,SAHF,EAIEC,OAJF,EAKEC,QALF,QAMO,OANP;AAOA,OAAOC,SAAP,MAAsB,YAAtB;AAOA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,SAASC,WAAT,QAA4B,wBAA5B;AAEA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,WAAhC,EAA6CC,QAA7C,QAA6D,aAA7D;OACOC,Y;OACAC,kB;OACAC,W;SAELC,SAAS,IAAIC,gB,EACbC,OAAO,IAAIC,c;OAENC,U;SACEC,W,EAAaC,W;SACbC,gB,EAAkBC,mB;AAS3B,IAAMC,GAAG,GAAGlB,GAAG,CAACmB,MAAJ,CAAW,iBAAX,CAAZ;AAEA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,CAArB;AAEA,IAAMC,qBAA4C,GAAG,EAArD;;AAEA,IAAMC,gBAAgB,GAAG,MAAMC,SAA/B,C,CAEA;;;AACA,IAAMC,iBAAiB,GAAIC,KAAD,IAAoBA,KAA9C;;AAqBA;AACA;AACA;AACA,OAAO,IAAMC,eAAe,GAAG,QAUU;EAAA;;EAAA,IAVT;IAC9BC,EAD8B;IAE9BC,QAF8B;IAG9BC,cAAc,gBAAG,uDAHa;IAI9BC,MAJ8B;IAK9BC,YAAY,GAAGV,qBALe;IAM9BW,c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,SAAS,CAACkH,IAFM;EAG1B5E,IAAI,EAAEtC,SAAS,CAACmH,KAAV,CAAgB,EAAhB,CAHoB;EAI1BnF,cAAc,EAAEhC,SAAS,CAACkH,IAJA;EAK1BjF,MAAM,EAAElB,WAAW,CAACqG,MAAZ,CAAmBH,UALD;EAM1B/E,YAAY,EAAElC,SAAS,CAACqH,OAAV,CAAkBrH,SAAS,CAACmH,KAAV,CAAgB,EAAhB,CAAlB,CANY;EAO1BhF,cAAc,EAAEnC,SAAS,CAACsH,IAPA;EAQ1BlF,mBAAmB,EAAEpC,SAAS,CAACsH;AARL,CAA5B;AAWA,eAAezF,eAAf"}
|
|
1
|
+
{"version":3,"file":"DashboardLayout.js","names":["React","useCallback","useEffect","useMemo","useState","PropTypes","Log","usePrevious","Provider","useDispatch","useSelector","useStore","PanelManager","PanelErrorBoundary","LayoutUtils","dehydrate","dehydrateDefault","hydrate","hydrateDefault","PanelEvent","GLPropTypes","useListener","getDashboardData","updateDashboardData","log","module","EMPTY_OBJECT","Object","freeze","DEFAULT_LAYOUT_CONFIG","DEFAULT_CALLBACK","undefined","FALLBACK_CALLBACK","props","DashboardLayout","id","children","emptyDashboard","layout","layoutConfig","onLayoutChange","onLayoutInitialized","dispatch","data","state","isDashboardEmpty","setIsDashboardEmpty","isItemDragging","setIsItemDragging","lastConfig","setLastConfig","initialClosedPanels","closed","isDashboardInitialized","setIsDashboardInitialized","hydrateMap","Map","dehydrateMap","store","registerComponent","name","componentType","componentHydrate","componentDehydrate","debug2","renderComponent","ref","CType","glContainer","glEventHub","wrappedComponent","forwardRef","cleanup","set","hydrateComponent","get","dehydrateComponent","config","panelManager","openedMap","handleLayoutStateChanged","glConfig","toConfig","contentConfig","content","dehydratedLayoutConfig","dehydrateLayoutConfig","hasChanged","isEqual","debug","root","contentItems","length","handleLayoutItemPickedUp","handleLayoutItemDropped","handleComponentCreated","item","component","element","cssComponent","replace","toLowerCase","cssClass","addClass","eventHub","TITLE_CHANGED","previousLayoutConfig","loadNewConfig","hydrateLayoutConfig","remove","i","addChild","Children","map","child","cloneElement","propTypes","string","isRequired","node","shape","Layout","arrayOf","func"],"sources":["../src/DashboardLayout.tsx"],"sourcesContent":["import React, {\n ReactElement,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport PropTypes from 'prop-types';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n Container,\n EventEmitter,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport { usePrevious } from '@deephaven/react-hooks';\nimport { RootState } from '@deephaven/redux';\nimport { Provider, useDispatch, useSelector, useStore } from 'react-redux';\nimport PanelManager, { ClosedPanels } from './PanelManager';\nimport PanelErrorBoundary from './PanelErrorBoundary';\nimport LayoutUtils from './layout/LayoutUtils';\nimport {\n dehydrate as dehydrateDefault,\n hydrate as hydrateDefault,\n} from './DashboardUtils';\nimport PanelEvent from './PanelEvent';\nimport { GLPropTypes, useListener } from './layout';\nimport { getDashboardData, updateDashboardData } from './redux';\nimport {\n PanelComponentType,\n PanelDehydrateFunction,\n PanelHydrateFunction,\n} from './DashboardPlugin';\n\nexport type DashboardLayoutConfig = ItemConfigType[];\n\nconst log = Log.module('DashboardLayout');\n\nconst EMPTY_OBJECT = Object.freeze({});\n\nconst DEFAULT_LAYOUT_CONFIG: DashboardLayoutConfig = [];\n\nconst DEFAULT_CALLBACK = () => undefined;\n\n// If a component isn't registered, just pass through the props so they are saved if a plugin is loaded later\nconst FALLBACK_CALLBACK = (props: unknown) => props;\n\ntype DashboardData = {\n closed?: ClosedPanels;\n};\n\ninterface DashboardLayoutProps {\n id: string;\n\n // Default hydrate/dehydration functions\n hydrate?: PanelHydrateFunction;\n dehydrate?: PanelDehydrateFunction;\n layout: GoldenLayout;\n layoutConfig?: DashboardLayoutConfig;\n onLayoutChange?: (dehydratedLayout: DashboardLayoutConfig) => void;\n onLayoutInitialized?: () => void;\n data?: DashboardData;\n children?: React.ReactNode | React.ReactNode[];\n emptyDashboard?: React.ReactNode;\n}\n\n/**\n * DashboardLayout component. Handles hydrating, dehydrating components, listening for dragging panels.\n */\nexport const DashboardLayout = ({\n id,\n children,\n emptyDashboard = <div>Dashboard is empty.</div>,\n layout,\n layoutConfig = DEFAULT_LAYOUT_CONFIG,\n onLayoutChange = DEFAULT_CALLBACK,\n onLayoutInitialized = DEFAULT_CALLBACK,\n hydrate = hydrateDefault,\n dehydrate = dehydrateDefault,\n}: DashboardLayoutProps): JSX.Element => {\n const dispatch = useDispatch();\n const data =\n useSelector<RootState>(state => getDashboardData(state, id)) ??\n EMPTY_OBJECT;\n\n const [isDashboardEmpty, setIsDashboardEmpty] = useState(false);\n const [isItemDragging, setIsItemDragging] = useState(false);\n const [lastConfig, setLastConfig] = useState<DashboardLayoutConfig>();\n const [initialClosedPanels] = useState<ReactComponentConfig[] | undefined>(\n (data as DashboardData)?.closed ?? []\n );\n const [isDashboardInitialized, setIsDashboardInitialized] = useState(false);\n\n const hydrateMap = useMemo(() => new Map(), []);\n const dehydrateMap = useMemo(() => new Map(), []);\n const store = useStore();\n const registerComponent = useCallback(\n (\n name: string,\n componentType: PanelComponentType,\n componentHydrate = hydrate,\n componentDehydrate = dehydrate\n ) => {\n log.debug2(\n 'registerComponent',\n name,\n componentType,\n componentHydrate,\n componentDehydrate\n );\n\n function renderComponent(\n props: { glContainer: Container; glEventHub: EventEmitter },\n ref: unknown\n ) {\n // Cast it to an `any` type so we can pass the ref in correctly.\n // ComponentType doesn't seem to work right, ReactNode is also incorrect\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const CType = componentType as any;\n\n // Props supplied by GoldenLayout\n // eslint-disable-next-line react/prop-types\n const { glContainer, glEventHub } = props;\n return (\n <Provider store={store}>\n <PanelErrorBoundary\n glContainer={glContainer}\n glEventHub={glEventHub}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <CType {...props} ref={ref} />\n </PanelErrorBoundary>\n </Provider>\n );\n }\n\n const wrappedComponent = React.forwardRef(renderComponent);\n const cleanup = layout.registerComponent(name, wrappedComponent);\n hydrateMap.set(name, componentHydrate);\n dehydrateMap.set(name, componentDehydrate);\n return cleanup;\n },\n [hydrate, dehydrate, hydrateMap, dehydrateMap, layout, store]\n );\n const hydrateComponent = useCallback(\n (name, props) => (hydrateMap.get(name) ?? FALLBACK_CALLBACK)(props, id),\n [hydrateMap, id]\n );\n const dehydrateComponent = useCallback(\n (name, config) => (dehydrateMap.get(name) ?? FALLBACK_CALLBACK)(config, id),\n [dehydrateMap, id]\n );\n const panelManager = useMemo(\n () =>\n new PanelManager(\n layout,\n hydrateComponent,\n dehydrateComponent,\n new Map(),\n initialClosedPanels,\n ({ closed, openedMap }) => {\n dispatch(updateDashboardData(id, { closed, openedMap }));\n }\n ),\n [\n dehydrateComponent,\n dispatch,\n hydrateComponent,\n id,\n initialClosedPanels,\n layout,\n ]\n );\n\n const handleLayoutStateChanged = useCallback(() => {\n // we don't want to emit stateChanges that happen during item drags or else\n // we risk the last saved state being one without that panel in the layout entirely\n if (isItemDragging) return;\n\n if (!isDashboardInitialized) {\n onLayoutInitialized();\n setIsDashboardInitialized(true);\n }\n\n const glConfig = layout.toConfig();\n const contentConfig = glConfig.content;\n const dehydratedLayoutConfig = LayoutUtils.dehydrateLayoutConfig(\n contentConfig,\n dehydrateComponent\n );\n const hasChanged =\n lastConfig == null ||\n !LayoutUtils.isEqual(lastConfig, dehydratedLayoutConfig);\n\n log.debug(\n 'handleLayoutStateChanged',\n hasChanged,\n contentConfig,\n dehydratedLayoutConfig\n );\n\n if (hasChanged) {\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n\n setLastConfig(dehydratedLayoutConfig);\n\n onLayoutChange(dehydratedLayoutConfig);\n }\n }, [\n dehydrateComponent,\n isDashboardInitialized,\n isItemDragging,\n lastConfig,\n layout,\n onLayoutChange,\n onLayoutInitialized,\n ]);\n\n const handleLayoutItemPickedUp = useCallback(() => {\n setIsItemDragging(true);\n }, []);\n\n const handleLayoutItemDropped = useCallback(() => {\n setIsItemDragging(false);\n }, []);\n\n const handleComponentCreated = useCallback(item => {\n log.debug2('handleComponentCreated', item);\n\n if (!item || !item.config || !item.config.component || !item.element) {\n return;\n }\n\n const cssComponent = item.config.component\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .toLowerCase();\n const cssClass = `${cssComponent}-component`;\n item.element.addClass(cssClass);\n }, []);\n\n useListener(layout, 'stateChanged', handleLayoutStateChanged);\n useListener(layout, 'itemPickedUp', handleLayoutItemPickedUp);\n useListener(layout, 'itemDropped', handleLayoutItemDropped);\n useListener(layout, 'componentCreated', handleComponentCreated);\n useListener(\n layout.eventHub,\n PanelEvent.TITLE_CHANGED,\n handleLayoutStateChanged\n );\n\n const previousLayoutConfig = usePrevious(layoutConfig);\n useEffect(\n function loadNewConfig() {\n if (\n previousLayoutConfig !== layoutConfig &&\n layoutConfig !== lastConfig\n ) {\n log.debug('Setting new layout content...');\n const content = LayoutUtils.hydrateLayoutConfig(\n layoutConfig,\n hydrateComponent\n );\n // Remove the old layout before add the new one\n while (layout.root.contentItems.length > 0) {\n layout.root.contentItems[0].remove();\n }\n\n // Add the new content. It is usally just one item from the root\n for (let i = 0; i < content.length; i += 1) {\n layout.root.addChild(content[i]);\n }\n\n setIsDashboardEmpty(layout.root.contentItems.length === 0);\n }\n },\n [\n hydrateComponent,\n layout,\n layoutConfig,\n lastConfig,\n panelManager,\n previousLayoutConfig,\n ]\n );\n\n return (\n <>\n {isDashboardEmpty && emptyDashboard}\n {React.Children.map(children, child =>\n child\n ? React.cloneElement(child as ReactElement, {\n id,\n layout,\n panelManager,\n registerComponent,\n })\n : null\n )}\n </>\n );\n};\n\nDashboardLayout.propTypes = {\n id: PropTypes.string.isRequired,\n children: PropTypes.node,\n data: PropTypes.shape({}),\n emptyDashboard: PropTypes.node,\n layout: GLPropTypes.Layout.isRequired,\n layoutConfig: PropTypes.arrayOf(PropTypes.shape({})),\n onLayoutChange: PropTypes.func,\n onLayoutIn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B,EAAEpC,SAAS,CAACsH;AARL,CAA5B;AAWA,eAAezF,eAAf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, ReactNode } from 'react';
|
|
2
|
-
import { Container, EventEmitter } from '@deephaven/golden-layout';
|
|
2
|
+
import type { Container, EventEmitter } from '@deephaven/golden-layout';
|
|
3
3
|
import './PanelErrorBoundary.scss';
|
|
4
4
|
interface PanelErrorBoundaryProps {
|
|
5
5
|
children: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelErrorBoundary.d.ts","sourceRoot":"","sources":["../src/PanelErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"PanelErrorBoundary.d.ts","sourceRoot":"","sources":["../src/PanelErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxE,OAAO,2BAA2B,CAAC;AAInC,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,EAAE,SAAS,CAAC;IACvB,UAAU,EAAE,YAAY,CAAC;CAC1B;AAED,UAAU,uBAAuB;IAC/B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AACD;;;;;GAKG;AACH,cAAM,kBAAmB,SAAQ,SAAS,CACxC,uBAAuB,EACvB,uBAAuB,CACxB;gBACa,KAAK,EAAE,uBAAuB;IAK1C,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIrC,oBAAoB,IAAI,IAAI;IAO5B,MAAM,IAAI,SAAS;CAgBpB;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelErrorBoundary.js","names":["React","Component","LoadingOverlay","Log","PanelEvent","LayoutUtils","log","module","PanelErrorBoundary","constructor","props","state","error","componentDidCatch","setState","componentWillUnmount","glContainer","glEventHub","panelId","getIdFromContainer","debug","emit","CLOSED","render","children"],"sources":["../src/PanelErrorBoundary.tsx"],"sourcesContent":["import React, { Component, ReactNode } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { Container, EventEmitter } from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils from './layout/LayoutUtils';\nimport './PanelErrorBoundary.scss';\n\nconst log = Log.module('PanelErrorBoundary');\n\ninterface PanelErrorBoundaryProps {\n children: ReactNode;\n glContainer: Container;\n glEventHub: EventEmitter;\n}\n\ninterface PanelErrorBoundaryState {\n error: Error | null;\n}\n/**\n * Panel wrapper implementing Error Boundary and emitting Closed event.\n * Closed event has to be emitted from the wrapper instead of the panel itself\n * because the panel can get unmounted on errors\n * and we want to differentiate between unmount on error vs panel being intentionally closed.\n */\nclass PanelErrorBoundary extends Component<\n PanelErrorBoundaryProps,\n PanelErrorBoundaryState\n> {\n constructor(props: PanelErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n componentDidCatch(error: Error): void {\n this.setState({ error });\n }\n\n componentWillUnmount(): void {\n const { glContainer, glEventHub } = this.props;\n const panelId = LayoutUtils.getIdFromContainer(glContainer);\n log.debug('componentWillUnmount', panelId);\n glEventHub.emit(PanelEvent.CLOSED, panelId, glContainer);\n }\n\n render(): ReactNode {\n const { children } = this.props;\n const { error } = this.state;\n if (error != null) {\n return (\n <div className=\"panel-error-boundary\">\n <LoadingOverlay\n errorMessage={`${error}`}\n isLoading={false}\n isLoaded={false}\n />\n </div>\n );\n }\n return children;\n }\n}\n\nexport default PanelErrorBoundary;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAA4C,OAA5C;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,U;OACAC,W;;AAGP,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAJ,CAAW,oBAAX,CAAZ;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAN,SAAiCP,SAAjC,CAGE;EACAQ,WAAW,CAACC,KAAD,EAAiC;IAC1C,MAAMA,KAAN;IACA,KAAKC,KAAL,GAAa;MAAEC,KAAK,EAAE;IAAT,CAAb;EACD;;EAEDC,iBAAiB,CAACD,KAAD,EAAqB;IACpC,KAAKE,QAAL,CAAc;MAAEF;IAAF,CAAd;EACD;;EAEDG,oBAAoB,GAAS;IAC3B,IAAM;MAAEC,WAAF;MAAeC;IAAf,IAA8B,KAAKP,KAAzC;IACA,IAAMQ,OAAO,GAAGb,WAAW,CAACc,kBAAZ,CAA+BH,WAA/B,CAAhB;IACAV,GAAG,CAACc,KAAJ,CAAU,sBAAV,EAAkCF,OAAlC;IACAD,UAAU,CAACI,IAAX,CAAgBjB,UAAU,CAACkB,MAA3B,EAAmCJ,OAAnC,EAA4CF,WAA5C;EACD;;EAEDO,MAAM,GAAc;IAClB,IAAM;MAAEC;IAAF,IAAe,KAAKd,KAA1B;IACA,IAAM;MAAEE;IAAF,IAAY,KAAKD,KAAvB;;IACA,IAAIC,KAAK,IAAI,IAAb,EAAmB;MACjB,oBACE;QAAK,SAAS,EAAC;MAAf,gBACE,oBAAC,cAAD;QACE,YAAY,YAAKA,KAAL,CADd;QAEE,SAAS,EAAE,KAFb;QAGE,QAAQ,EAAE;MAHZ,EADF,CADF;IASD;;IACD,OAAOY,QAAP;EACD;;AAhCD;;AAmCF,eAAehB,kBAAf"}
|
|
1
|
+
{"version":3,"file":"PanelErrorBoundary.js","names":["React","Component","LoadingOverlay","Log","PanelEvent","LayoutUtils","log","module","PanelErrorBoundary","constructor","props","state","error","componentDidCatch","setState","componentWillUnmount","glContainer","glEventHub","panelId","getIdFromContainer","debug","emit","CLOSED","render","children"],"sources":["../src/PanelErrorBoundary.tsx"],"sourcesContent":["import React, { Component, ReactNode } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport type { Container, EventEmitter } from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils from './layout/LayoutUtils';\nimport './PanelErrorBoundary.scss';\n\nconst log = Log.module('PanelErrorBoundary');\n\ninterface PanelErrorBoundaryProps {\n children: ReactNode;\n glContainer: Container;\n glEventHub: EventEmitter;\n}\n\ninterface PanelErrorBoundaryState {\n error: Error | null;\n}\n/**\n * Panel wrapper implementing Error Boundary and emitting Closed event.\n * Closed event has to be emitted from the wrapper instead of the panel itself\n * because the panel can get unmounted on errors\n * and we want to differentiate between unmount on error vs panel being intentionally closed.\n */\nclass PanelErrorBoundary extends Component<\n PanelErrorBoundaryProps,\n PanelErrorBoundaryState\n> {\n constructor(props: PanelErrorBoundaryProps) {\n super(props);\n this.state = { error: null };\n }\n\n componentDidCatch(error: Error): void {\n this.setState({ error });\n }\n\n componentWillUnmount(): void {\n const { glContainer, glEventHub } = this.props;\n const panelId = LayoutUtils.getIdFromContainer(glContainer);\n log.debug('componentWillUnmount', panelId);\n glEventHub.emit(PanelEvent.CLOSED, panelId, glContainer);\n }\n\n render(): ReactNode {\n const { children } = this.props;\n const { error } = this.state;\n if (error != null) {\n return (\n <div className=\"panel-error-boundary\">\n <LoadingOverlay\n errorMessage={`${error}`}\n isLoading={false}\n isLoaded={false}\n />\n </div>\n );\n }\n return children;\n }\n}\n\nexport default PanelErrorBoundary;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAA4C,OAA5C;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,OAAOC,GAAP,MAAgB,gBAAhB;OACOC,U;OACAC,W;;AAGP,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAJ,CAAW,oBAAX,CAAZ;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAN,SAAiCP,SAAjC,CAGE;EACAQ,WAAW,CAACC,KAAD,EAAiC;IAC1C,MAAMA,KAAN;IACA,KAAKC,KAAL,GAAa;MAAEC,KAAK,EAAE;IAAT,CAAb;EACD;;EAEDC,iBAAiB,CAACD,KAAD,EAAqB;IACpC,KAAKE,QAAL,CAAc;MAAEF;IAAF,CAAd;EACD;;EAEDG,oBAAoB,GAAS;IAC3B,IAAM;MAAEC,WAAF;MAAeC;IAAf,IAA8B,KAAKP,KAAzC;IACA,IAAMQ,OAAO,GAAGb,WAAW,CAACc,kBAAZ,CAA+BH,WAA/B,CAAhB;IACAV,GAAG,CAACc,KAAJ,CAAU,sBAAV,EAAkCF,OAAlC;IACAD,UAAU,CAACI,IAAX,CAAgBjB,UAAU,CAACkB,MAA3B,EAAmCJ,OAAnC,EAA4CF,WAA5C;EACD;;EAEDO,MAAM,GAAc;IAClB,IAAM;MAAEC;IAAF,IAAe,KAAKd,KAA1B;IACA,IAAM;MAAEE;IAAF,IAAY,KAAKD,KAAvB;;IACA,IAAIC,KAAK,IAAI,IAAb,EAAmB;MACjB,oBACE;QAAK,SAAS,EAAC;MAAf,gBACE,oBAAC,cAAD;QACE,YAAY,YAAKA,KAAL,CADd;QAEE,SAAS,EAAE,KAFb;QAGE,QAAQ,EAAE;MAHZ,EADF,CADF;IASD;;IACD,OAAOY,QAAP;EACD;;AAhCD;;AAmCF,eAAehB,kBAAf"}
|
package/dist/PanelManager.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
import GoldenLayout
|
|
2
|
+
import GoldenLayout from '@deephaven/golden-layout';
|
|
3
|
+
import type { ContentItem, ItemConfigType, ReactComponentConfig } from '@deephaven/golden-layout';
|
|
3
4
|
import { PanelComponent, PanelComponentType, PanelProps } from './DashboardPlugin';
|
|
4
5
|
export declare type PanelHydraterFunction = (name: string, props: PanelProps) => PanelProps;
|
|
5
6
|
export declare type PanelDehydraterFunction = (name: string, config: ReactComponentConfig) => ReactComponentConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelManager.d.ts","sourceRoot":"","sources":["../src/PanelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,YAAY,
|
|
1
|
+
{"version":3,"file":"PanelManager.d.ts","sourceRoot":"","sources":["../src/PanelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAEL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,oBAAY,qBAAqB,GAAG,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,UAAU,KACd,UAAU,CAAC;AAEhB,oBAAY,uBAAuB,GAAG,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,oBAAoB,KACzB,oBAAoB,CAAC;AAE1B,oBAAY,WAAW,GAAG,oBAAoB,CAAC;AAE/C,oBAAY,YAAY,GAAG,WAAW,EAAE,CAAC;AAEzC,oBAAY,cAAc,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;AAEpE,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,oBAAY,oBAAoB,GAAG,CAAC,eAAe,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAE/E;;GAEG;AACH,cAAM,YAAY;IAChB,MAAM,CAAC,sBAAsB,SAAO;IAEpC,MAAM,EAAE,YAAY,CAAC;IAErB,gBAAgB,EAAE,qBAAqB,CAAC;IAEx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CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS;IAYnE,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAcxC,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAuBxC,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAavD,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAKxC,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAMxC,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAM1C;;;;OAIG;IACH,YAAY,CACV,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACtC,IAAI;IAoBP,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAQ7C,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,SAAS,GAAG,IAAI;IAQxE,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMpC,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,SAAS,GAAG,IAAI;IAazD,UAAU,IAAI,IAAI;CAOnB;AAED,eAAe,YAAY,CAAC"}
|
package/dist/PanelManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelManager.js","names":["Log","PanelEvent","LayoutUtils","isReactComponentConfig","isWrappedComponent","log","module","PanelManager","constructor","layout","hydrateComponent","name","props","dehydrateComponent","config","openedMap","Map","closed","onPanelsUpdated","undefined","handleFocus","bind","handleMount","handleUnmount","handleReopen","handleDeleted","handleClosed","handleControlClose","startListening","eventHub","on","FOCUS","MOUNT","UNMOUNT","REOPEN","DELETE","CLOSED","CLOSE","stopListening","off","getClosedPanelConfigsOfType","typeString","filter","panel","component","getOpenedPanels","Array","from","values","getOpenedPanelConfigs","map","glContainer","getComponentConfigFromContainer","getOpenedPanelConfigsOfType","getOpenedPanelById","panelId","get","getContainerByPanelId","stack","getStackForConfig","root","id","getContentItemInStack","getLastUsedPanel","matcher","opened","i","length","getLastUsedPanelOfType","type","getLastUsedPanelOfTypes","types","some","WrappedComponent","updatePanel","getIdFromPanel","error","debug2","delete","set","removePanel","has","debug","removeClosedPanelConfig","panelConfig","index","findIndex","closedConfig","splice","sendUpdate","replaceConfig","openComponent","addClosedPanel","closeComponent","dehydratedConfig","push"],"sources":["../src/PanelManager.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport GoldenLayout, {\n ContentItem,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils, { isReactComponentConfig } from './layout/LayoutUtils';\nimport {\n isWrappedComponent,\n PanelComponent,\n PanelComponentType,\n PanelProps,\n} from './DashboardPlugin';\n\nconst log = Log.module('PanelManager');\n\nexport type PanelHydraterFunction = (\n name: string,\n props: PanelProps\n) => PanelProps;\n\nexport type PanelDehydraterFunction = (\n name: string,\n config: ReactComponentConfig\n) => ReactComponentConfig;\n\nexport type ClosedPanel = ReactComponentConfig;\n\nexport type ClosedPanels = ClosedPanel[];\n\nexport type OpenedPanelMap = Map<string | string[], PanelComponent>;\n\nexport type PanelsUpdateData = {\n closed: ClosedPanels;\n openedMap: OpenedPanelMap;\n};\n\nexport type PanelsUpdateCallback = (panelUpdateData: PanelsUpdateData) => void;\n\n/**\n * Class to keep track of which panels are open, have been closed, and also events to close panels.\n */\nclass PanelManager {\n static MAX_CLOSED_PANEL_COUNT = 100;\n\n layout: GoldenLayout;\n\n hydrateComponent: PanelHydraterFunction;\n\n dehydrateComponent: PanelDehydraterFunction;\n\n onPanelsUpdated: PanelsUpdateCallback;\n\n closed: ClosedPanels;\n\n openedMap: OpenedPanelMap;\n\n /**\n * @param layout The GoldenLayout object to attach to\n * @param hydrateComponent Function to hydrate a panel from a dehydrated state\n * @param dehydrateComponent Function to dehydrate a panel\n * @param openedMap Map of opened panels\n * @param closed Array of closed panels in a dehydrated state\n * @param onPanelsUpdated Triggered when the panels are updated\n */\n constructor(\n layout: GoldenLayout,\n hydrateComponent: PanelHydraterFunction = (name, props) => props,\n dehydrateComponent: PanelDehydraterFunction = (name, config) => config,\n openedMap: OpenedPanelMap = new Map(),\n closed: ClosedPanel[] = [],\n onPanelsUpdated: PanelsUpdateCallback = () => undefined\n ) {\n this.handleFocus = this.handleFocus.bind(this);\n this.handleMount = this.handleMount.bind(this);\n // Panel can be unmounted on error but still keep the tab until it's closed\n // Use PanelEvent.MOUNT/UNMOUNT to track open (active) panels\n // and PanelEvent.CLOSED for cleanup (delete links, add panel to closed panels list, etc)\n this.handleUnmount = this.handleUnmount.bind(this);\n this.handleReopen = this.handleReopen.bind(this);\n this.handleDeleted = this.handleDeleted.bind(this);\n this.handleClosed = this.handleClosed.bind(this);\n this.handleControlClose = this.handleControlClose.bind(this);\n\n this.layout = layout;\n this.hydrateComponent = hydrateComponent;\n this.dehydrateComponent = dehydrateComponent;\n this.onPanelsUpdated = onPanelsUpdated;\n\n // Store the opened and closed panels\n this.openedMap = new Map(openedMap);\n\n // Closed panels are stored in their dehydrated state\n this.closed = [...closed];\n\n this.startListening();\n }\n\n startListening(): void {\n const { eventHub } = this.layout;\n eventHub.on(PanelEvent.FOCUS, this.handleFocus);\n eventHub.on(PanelEvent.MOUNT, this.handleMount);\n eventHub.on(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.on(PanelEvent.REOPEN, this.handleReopen);\n eventHub.on(PanelEvent.DELETE, this.handleDeleted);\n eventHub.on(PanelEvent.CLOSED, this.handleClosed);\n eventHub.on(PanelEvent.CLOSE, this.handleControlClose);\n // PanelEvent.OPEN should be listened to by plugins to open a panel\n }\n\n stopListening(): void {\n const { eventHub } = this.layout;\n eventHub.off(PanelEvent.FOCUS, this.handleFocus);\n eventHub.off(PanelEvent.MOUNT, this.handleMount);\n eventHub.off(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.off(PanelEvent.REOPEN, this.handleReopen);\n eventHub.off(PanelEvent.DELETE, this.handleDeleted);\n eventHub.off(PanelEvent.CLOSED, this.handleClosed);\n eventHub.off(PanelEvent.CLOSE, this.handleControlClose);\n }\n\n getClosedPanelConfigsOfType(typeString: string): ClosedPanels {\n return this.closed.filter(panel => panel.component === typeString);\n }\n\n getOpenedPanels(): PanelComponent[] {\n return Array.from(this.openedMap.values());\n }\n\n getOpenedPanelConfigs(): (ItemConfigType | null)[] {\n return this.getOpenedPanels().map(panel => {\n const { glContainer } = panel.props;\n return LayoutUtils.getComponentConfigFromContainer(glContainer);\n });\n }\n\n getOpenedPanelConfigsOfType(typeString: string): ReactComponentConfig[] {\n return this.getOpenedPanelConfigs().filter(\n config =>\n config != null &&\n isReactComponentConfig(config) &&\n config.component === typeString\n ) as ReactComponentConfig[];\n }\n\n getOpenedPanelById(panelId: string | string[]): PanelComponent | undefined {\n return this.openedMap.get(panelId);\n }\n\n getContainerByPanelId(panelId: string | string[]): ContentItem | null {\n const stack = LayoutUtils.getStackForConfig(this.layout.root, {\n id: panelId,\n });\n return (\n (stack && LayoutUtils.getContentItemInStack(stack, { id: panelId })) ??\n null\n );\n }\n\n getLastUsedPanel<T extends PanelComponent = PanelComponent>(\n matcher: (panel: PanelComponent) => boolean\n ): T | undefined {\n const opened = this.getOpenedPanels();\n for (let i = opened.length - 1; i >= 0; i -= 1) {\n const panel = opened[i];\n if (matcher == null || matcher(panel)) {\n return panel as T;\n }\n }\n\n return undefined;\n }\n\n getLastUsedPanelOfType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n >(type: PanelComponentType<P, C>): PanelComponent<P> | undefined {\n return this.getLastUsedPanelOfTypes([type]);\n }\n\n getLastUsedPanelOfTypes<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n >(types: PanelComponentType<P, C>[]): PanelComponent<P> | undefined {\n return this.getLastUsedPanel(panel =>\n types.some(\n type =>\n panel instanceof type ||\n (isWrappedComponent(type) &&\n type.WrappedComponent &&\n panel instanceof type.WrappedComponent)\n )\n );\n }\n\n updatePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (!panelId) {\n log.error('updatePanel Panel did not have an ID', panel);\n return;\n }\n log.debug2(`Updating panel ID ${panelId} in open panels map`);\n // Delete the entry before it's set to maintain correct ordering in the open panels map.\n // The last updated (focused) panel should be the last inserted.\n // Deleting the entry from the map directly instead of calling this.removePanel to skip the checks.\n this.openedMap.delete(panelId);\n this.openedMap.set(panelId, panel);\n }\n\n removePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (!panelId) {\n log.error('removePanel Panel did not have an ID', panel);\n return;\n }\n if (!this.openedMap.has(panelId)) {\n log.error(`Missing panel ID ${panelId} in open panels map`);\n return;\n }\n if (this.openedMap.get(panelId) !== panel) {\n // We mount a new panel before un-mounting the existing one\n // when replacing existing panels in openComponent/openComponentInStack.\n // Skip map delete if the panelId entry already refers to the new panel.\n log.debug(\n `Panel argument doesn't match the open panels map entry for ${panelId}, removePanel ignored`\n );\n return;\n }\n log.debug2(`Removing panel ID ${panelId} from open panels map`);\n this.openedMap.delete(panelId);\n }\n\n removeClosedPanelConfig(panelConfig: ClosedPanel): void {\n const index = this.closed.findIndex(\n closedConfig =>\n closedConfig === panelConfig ||\n (closedConfig.id &&\n panelConfig.id &&\n closedConfig.id === panelConfig.id)\n );\n if (index >= 0) {\n this.closed.splice(index, 1);\n }\n }\n\n handleFocus(panel: PanelComponent): void {\n log.debug2('Focus: ', panel);\n this.updatePanel(panel);\n }\n\n handleMount(panel: PanelComponent): void {\n log.debug2('Mount: ', panel);\n this.updatePanel(panel);\n this.sendUpdate();\n }\n\n handleUnmount(panel: PanelComponent): void {\n log.debug2('Unmount: ', panel);\n this.removePanel(panel);\n this.sendUpdate();\n }\n\n /**\n *\n * @param panelConfig The config to hydrate and load\n * @param replaceConfig The config to place\n */\n handleReopen(\n panelConfig: ClosedPanel,\n replaceConfig?: Partial<ItemConfigType>\n ): void {\n log.debug2('Reopen:', panelConfig, replaceConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n // Don't need to send an update yet, it will get sent when component is mounted\n\n // Rehydrate the panel before adding it back\n const { component } = panelConfig;\n let { props } = panelConfig;\n props = this.hydrateComponent(component, props);\n\n const config = {\n ...panelConfig,\n props,\n };\n\n const { root } = this.layout;\n LayoutUtils.openComponent({ root, config, replaceConfig });\n }\n\n handleDeleted(panelConfig: ClosedPanel): void {\n log.debug2('Deleted:', panelConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n\n this.sendUpdate();\n }\n\n handleClosed(panelId: string, glContainer: GoldenLayout.Container): void {\n // Panel component should be already unmounted at this point\n // so the emitted event sends the container object instead of the panel.\n log.debug2('Closed: ', panelId);\n this.addClosedPanel(glContainer);\n this.sendUpdate();\n }\n\n handleControlClose(id: string): void {\n const config = { id };\n const { root } = this.layout;\n LayoutUtils.closeComponent(root, config);\n }\n\n addClosedPanel(glContainer: GoldenLayout.Container): void {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n const dehydratedConfig = this.dehydrateComponent(\n config.component,\n config\n );\n if (dehydratedConfig) {\n this.closed.push(dehydratedConfig);\n }\n }\n }\n\n sendUpdate(): void {\n const { closed, openedMap } = this;\n this.onPanelsUpdated({\n closed: [...closed],\n openedMap: new Map(openedMap),\n });\n }\n}\n\nexport default PanelManager;\n"],"mappings":";;;;;;AAMA,OAAOA,GAAP,MAAgB,gBAAhB;OACOC,U;OACAC,W,IAAeC,sB;SAEpBC,kB;AAMF,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAJ,CAAW,cAAX,CAAZ;;AAyBA;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAejB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,CACTC,MADS,EAOT;IAAA,IALAC,gBAKA,uEAL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AAZ,CAAiBD,gBAAjB;MACD;IACF;EACF;;EAEDL,UAAU,GAAS;IACjB,IAAM;MAAExE,MAAF;MAAUF;IAAV,IAAwB,IAA9B;IACA,KAAKG,eAAL,CAAqB;MACnBD,MAAM,EAAE,CAAC,GAAGA,MAAJ,CADW;MAEnBF,SAAS,EAAE,IAAIC,GAAJ,CAAQD,SAAR;IAFQ,CAArB;EAID;;AAjSgB;;gBAAbR,Y,4BAC4B,G;;AAmSlC,eAAeA,YAAf"}
|
|
1
|
+
{"version":3,"file":"PanelManager.js","names":["Log","PanelEvent","LayoutUtils","isReactComponentConfig","isWrappedComponent","log","module","PanelManager","constructor","layout","hydrateComponent","name","props","dehydrateComponent","config","openedMap","Map","closed","onPanelsUpdated","undefined","handleFocus","bind","handleMount","handleUnmount","handleReopen","handleDeleted","handleClosed","handleControlClose","startListening","eventHub","on","FOCUS","MOUNT","UNMOUNT","REOPEN","DELETE","CLOSED","CLOSE","stopListening","off","getClosedPanelConfigsOfType","typeString","filter","panel","component","getOpenedPanels","Array","from","values","getOpenedPanelConfigs","map","glContainer","getComponentConfigFromContainer","getOpenedPanelConfigsOfType","getOpenedPanelById","panelId","get","getContainerByPanelId","stack","getStackForConfig","root","id","getContentItemInStack","getLastUsedPanel","matcher","opened","i","length","getLastUsedPanelOfType","type","getLastUsedPanelOfTypes","types","some","WrappedComponent","updatePanel","getIdFromPanel","error","debug2","delete","set","removePanel","has","debug","removeClosedPanelConfig","panelConfig","index","findIndex","closedConfig","splice","sendUpdate","replaceConfig","openComponent","addClosedPanel","closeComponent","dehydratedConfig","push"],"sources":["../src/PanelManager.ts"],"sourcesContent":["import { ComponentType } from 'react';\nimport GoldenLayout from '@deephaven/golden-layout';\nimport type {\n ContentItem,\n ItemConfigType,\n ReactComponentConfig,\n} from '@deephaven/golden-layout';\nimport Log from '@deephaven/log';\nimport PanelEvent from './PanelEvent';\nimport LayoutUtils, { isReactComponentConfig } from './layout/LayoutUtils';\nimport {\n isWrappedComponent,\n PanelComponent,\n PanelComponentType,\n PanelProps,\n} from './DashboardPlugin';\n\nconst log = Log.module('PanelManager');\n\nexport type PanelHydraterFunction = (\n name: string,\n props: PanelProps\n) => PanelProps;\n\nexport type PanelDehydraterFunction = (\n name: string,\n config: ReactComponentConfig\n) => ReactComponentConfig;\n\nexport type ClosedPanel = ReactComponentConfig;\n\nexport type ClosedPanels = ClosedPanel[];\n\nexport type OpenedPanelMap = Map<string | string[], PanelComponent>;\n\nexport type PanelsUpdateData = {\n closed: ClosedPanels;\n openedMap: OpenedPanelMap;\n};\n\nexport type PanelsUpdateCallback = (panelUpdateData: PanelsUpdateData) => void;\n\n/**\n * Class to keep track of which panels are open, have been closed, and also events to close panels.\n */\nclass PanelManager {\n static MAX_CLOSED_PANEL_COUNT = 100;\n\n layout: GoldenLayout;\n\n hydrateComponent: PanelHydraterFunction;\n\n dehydrateComponent: PanelDehydraterFunction;\n\n onPanelsUpdated: PanelsUpdateCallback;\n\n closed: ClosedPanels;\n\n openedMap: OpenedPanelMap;\n\n /**\n * @param layout The GoldenLayout object to attach to\n * @param hydrateComponent Function to hydrate a panel from a dehydrated state\n * @param dehydrateComponent Function to dehydrate a panel\n * @param openedMap Map of opened panels\n * @param closed Array of closed panels in a dehydrated state\n * @param onPanelsUpdated Triggered when the panels are updated\n */\n constructor(\n layout: GoldenLayout,\n hydrateComponent: PanelHydraterFunction = (name, props) => props,\n dehydrateComponent: PanelDehydraterFunction = (name, config) => config,\n openedMap: OpenedPanelMap = new Map(),\n closed: ClosedPanel[] = [],\n onPanelsUpdated: PanelsUpdateCallback = () => undefined\n ) {\n this.handleFocus = this.handleFocus.bind(this);\n this.handleMount = this.handleMount.bind(this);\n // Panel can be unmounted on error but still keep the tab until it's closed\n // Use PanelEvent.MOUNT/UNMOUNT to track open (active) panels\n // and PanelEvent.CLOSED for cleanup (delete links, add panel to closed panels list, etc)\n this.handleUnmount = this.handleUnmount.bind(this);\n this.handleReopen = this.handleReopen.bind(this);\n this.handleDeleted = this.handleDeleted.bind(this);\n this.handleClosed = this.handleClosed.bind(this);\n this.handleControlClose = this.handleControlClose.bind(this);\n\n this.layout = layout;\n this.hydrateComponent = hydrateComponent;\n this.dehydrateComponent = dehydrateComponent;\n this.onPanelsUpdated = onPanelsUpdated;\n\n // Store the opened and closed panels\n this.openedMap = new Map(openedMap);\n\n // Closed panels are stored in their dehydrated state\n this.closed = [...closed];\n\n this.startListening();\n }\n\n startListening(): void {\n const { eventHub } = this.layout;\n eventHub.on(PanelEvent.FOCUS, this.handleFocus);\n eventHub.on(PanelEvent.MOUNT, this.handleMount);\n eventHub.on(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.on(PanelEvent.REOPEN, this.handleReopen);\n eventHub.on(PanelEvent.DELETE, this.handleDeleted);\n eventHub.on(PanelEvent.CLOSED, this.handleClosed);\n eventHub.on(PanelEvent.CLOSE, this.handleControlClose);\n // PanelEvent.OPEN should be listened to by plugins to open a panel\n }\n\n stopListening(): void {\n const { eventHub } = this.layout;\n eventHub.off(PanelEvent.FOCUS, this.handleFocus);\n eventHub.off(PanelEvent.MOUNT, this.handleMount);\n eventHub.off(PanelEvent.UNMOUNT, this.handleUnmount);\n eventHub.off(PanelEvent.REOPEN, this.handleReopen);\n eventHub.off(PanelEvent.DELETE, this.handleDeleted);\n eventHub.off(PanelEvent.CLOSED, this.handleClosed);\n eventHub.off(PanelEvent.CLOSE, this.handleControlClose);\n }\n\n getClosedPanelConfigsOfType(typeString: string): ClosedPanels {\n return this.closed.filter(panel => panel.component === typeString);\n }\n\n getOpenedPanels(): PanelComponent[] {\n return Array.from(this.openedMap.values());\n }\n\n getOpenedPanelConfigs(): (ItemConfigType | null)[] {\n return this.getOpenedPanels().map(panel => {\n const { glContainer } = panel.props;\n return LayoutUtils.getComponentConfigFromContainer(glContainer);\n });\n }\n\n getOpenedPanelConfigsOfType(typeString: string): ReactComponentConfig[] {\n return this.getOpenedPanelConfigs().filter(\n config =>\n config != null &&\n isReactComponentConfig(config) &&\n config.component === typeString\n ) as ReactComponentConfig[];\n }\n\n getOpenedPanelById(panelId: string | string[]): PanelComponent | undefined {\n return this.openedMap.get(panelId);\n }\n\n getContainerByPanelId(panelId: string | string[]): ContentItem | null {\n const stack = LayoutUtils.getStackForConfig(this.layout.root, {\n id: panelId,\n });\n return (\n (stack && LayoutUtils.getContentItemInStack(stack, { id: panelId })) ??\n null\n );\n }\n\n getLastUsedPanel<T extends PanelComponent = PanelComponent>(\n matcher: (panel: PanelComponent) => boolean\n ): T | undefined {\n const opened = this.getOpenedPanels();\n for (let i = opened.length - 1; i >= 0; i -= 1) {\n const panel = opened[i];\n if (matcher == null || matcher(panel)) {\n return panel as T;\n }\n }\n\n return undefined;\n }\n\n getLastUsedPanelOfType<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n >(type: PanelComponentType<P, C>): PanelComponent<P> | undefined {\n return this.getLastUsedPanelOfTypes([type]);\n }\n\n getLastUsedPanelOfTypes<\n P extends PanelProps = PanelProps,\n C extends ComponentType<P> = ComponentType<P>\n >(types: PanelComponentType<P, C>[]): PanelComponent<P> | undefined {\n return this.getLastUsedPanel(panel =>\n types.some(\n type =>\n panel instanceof type ||\n (isWrappedComponent(type) &&\n type.WrappedComponent &&\n panel instanceof type.WrappedComponent)\n )\n );\n }\n\n updatePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (!panelId) {\n log.error('updatePanel Panel did not have an ID', panel);\n return;\n }\n log.debug2(`Updating panel ID ${panelId} in open panels map`);\n // Delete the entry before it's set to maintain correct ordering in the open panels map.\n // The last updated (focused) panel should be the last inserted.\n // Deleting the entry from the map directly instead of calling this.removePanel to skip the checks.\n this.openedMap.delete(panelId);\n this.openedMap.set(panelId, panel);\n }\n\n removePanel(panel: PanelComponent): void {\n const panelId = LayoutUtils.getIdFromPanel(panel);\n if (!panelId) {\n log.error('removePanel Panel did not have an ID', panel);\n return;\n }\n if (!this.openedMap.has(panelId)) {\n log.error(`Missing panel ID ${panelId} in open panels map`);\n return;\n }\n if (this.openedMap.get(panelId) !== panel) {\n // We mount a new panel before un-mounting the existing one\n // when replacing existing panels in openComponent/openComponentInStack.\n // Skip map delete if the panelId entry already refers to the new panel.\n log.debug(\n `Panel argument doesn't match the open panels map entry for ${panelId}, removePanel ignored`\n );\n return;\n }\n log.debug2(`Removing panel ID ${panelId} from open panels map`);\n this.openedMap.delete(panelId);\n }\n\n removeClosedPanelConfig(panelConfig: ClosedPanel): void {\n const index = this.closed.findIndex(\n closedConfig =>\n closedConfig === panelConfig ||\n (closedConfig.id &&\n panelConfig.id &&\n closedConfig.id === panelConfig.id)\n );\n if (index >= 0) {\n this.closed.splice(index, 1);\n }\n }\n\n handleFocus(panel: PanelComponent): void {\n log.debug2('Focus: ', panel);\n this.updatePanel(panel);\n }\n\n handleMount(panel: PanelComponent): void {\n log.debug2('Mount: ', panel);\n this.updatePanel(panel);\n this.sendUpdate();\n }\n\n handleUnmount(panel: PanelComponent): void {\n log.debug2('Unmount: ', panel);\n this.removePanel(panel);\n this.sendUpdate();\n }\n\n /**\n *\n * @param panelConfig The config to hydrate and load\n * @param replaceConfig The config to place\n */\n handleReopen(\n panelConfig: ClosedPanel,\n replaceConfig?: Partial<ItemConfigType>\n ): void {\n log.debug2('Reopen:', panelConfig, replaceConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n // Don't need to send an update yet, it will get sent when component is mounted\n\n // Rehydrate the panel before adding it back\n const { component } = panelConfig;\n let { props } = panelConfig;\n props = this.hydrateComponent(component, props);\n\n const config = {\n ...panelConfig,\n props,\n };\n\n const { root } = this.layout;\n LayoutUtils.openComponent({ root, config, replaceConfig });\n }\n\n handleDeleted(panelConfig: ClosedPanel): void {\n log.debug2('Deleted:', panelConfig);\n\n this.removeClosedPanelConfig(panelConfig);\n\n this.sendUpdate();\n }\n\n handleClosed(panelId: string, glContainer: GoldenLayout.Container): void {\n // Panel component should be already unmounted at this point\n // so the emitted event sends the container object instead of the panel.\n log.debug2('Closed: ', panelId);\n this.addClosedPanel(glContainer);\n this.sendUpdate();\n }\n\n handleControlClose(id: string): void {\n const config = { id };\n const { root } = this.layout;\n LayoutUtils.closeComponent(root, config);\n }\n\n addClosedPanel(glContainer: GoldenLayout.Container): void {\n const config = LayoutUtils.getComponentConfigFromContainer(glContainer);\n if (config && isReactComponentConfig(config)) {\n const dehydratedConfig = this.dehydrateComponent(\n config.component,\n config\n );\n if (dehydratedConfig) {\n this.closed.push(dehydratedConfig);\n }\n }\n }\n\n sendUpdate(): void {\n const { closed, openedMap } = this;\n this.onPanelsUpdated({\n closed: [...closed],\n openedMap: new Map(openedMap),\n });\n }\n}\n\nexport default PanelManager;\n"],"mappings":";;;;;;AAOA,OAAOA,GAAP,MAAgB,gBAAhB;OACOC,U;OACAC,W,IAAeC,sB;SAEpBC,kB;AAMF,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAJ,CAAW,cAAX,CAAZ;;AAyBA;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAejB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,CACTC,MADS,EAOT;IAAA,IALAC,gBAKA,uEAL0C,CAACC,IAAD,EAAOC,KAAP,KAAiBA,KAK3D;IAAA,IAJAC,kBAIA,uEAJ8C,CAACF,IAAD,EAAOG,MAAP,KAAkBA,MAIhE;IAAA,IAHAC,SAGA,uEAH4B,IAAIC,GAAJ,EAG5B;IAAA,IAFAC,MAEA,uEAFwB,EAExB;IAAA,IADAC,eACA,uEADwC,MAAMC,SAC9C;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;;IACA,KAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBD,IAAjB,CAAsB,IAAtB,CAAnB,CAFA,CAGA;IACA;IACA;;IACA,KAAKE,aAAL,GAAqB,KAAKA,aAAL,CAAmBF,IAAnB,CA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