Skip to content

Commit 4489a76

Browse files
martinRenouGauss-Taylor-Euler
authored andcommitted
Draft rework left panel to be a react component
1 parent 283c196 commit 4489a76

File tree

8 files changed

+373
-296
lines changed

8 files changed

+373
-296
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IStateDB } from '@jupyterlab/statedb';
12
import { MapChange } from '@jupyter/ydoc';
23
import {
34
IAnnotation,
@@ -91,6 +92,7 @@ import CollaboratorPointers, { ClientPointer } from './CollaboratorPointers';
9192
import { FollowIndicator } from './FollowIndicator';
9293
import TemporalSlider from './TemporalSlider';
9394
import { MainViewModel } from './mainviewmodel';
95+
import { LeftPanelComponent } from '../panelview';
9496

9597
type OlLayerTypes =
9698
| TileLayer
@@ -103,7 +105,7 @@ type OlLayerTypes =
103105
| ImageLayer<any>;
104106
interface IProps {
105107
viewModel: MainViewModel;
106-
leftPanel?: Widget;
108+
state?: IStateDB;
107109
rightPanel?: Widget;
108110
}
109111

@@ -127,6 +129,8 @@ export class MainView extends React.Component<IProps, IStates> {
127129
constructor(props: IProps) {
128130
super(props);
129131

132+
this._state = props.state;
133+
130134
// Enforce the map to take the full available width in the case of Jupyter Notebook viewer
131135
const el = document.getElementById('main-panel');
132136

@@ -156,7 +160,6 @@ export class MainView extends React.Component<IProps, IStates> {
156160
resizeObserver.observe(el);
157161
}
158162

159-
this._leftPanel = props.leftPanel;
160163
this._rightPanel = props.rightPanel;
161164
this._mainViewModel = this.props.viewModel;
162165
this._mainViewModel.viewSettingChanged.connect(this._onViewChanged, this);
@@ -2202,7 +2205,22 @@ export class MainView extends React.Component<IProps, IStates> {
22022205
scale={this.state.scale}
22032206
/>
22042207
</div>
2205-
{this._leftPanel && (
2208+
{this._state &&
2209+
<Rnd
2210+
default={{
2211+
x: 400,
2212+
y: 0,
2213+
width: 200,
2214+
height: 600,
2215+
}}
2216+
bounds="window"
2217+
minWidth={100}
2218+
minHeight={100}
2219+
>
2220+
<LeftPanelComponent model={this._model} commands={this._commands} state={this._state}></LeftPanelComponent>
2221+
</Rnd>
2222+
}
2223+
{/* {this._leftPanel && (
22062224
<Rnd
22072225
default={{
22082226
x: 0,
@@ -2216,7 +2234,7 @@ export class MainView extends React.Component<IProps, IStates> {
22162234
>
22172235
<Lumino>{this._leftPanel}</Lumino>
22182236
</Rnd>
2219-
)}
2237+
)} */}
22202238

22212239
{this._rightPanel && (
22222240
<Rnd
@@ -2253,6 +2271,6 @@ export class MainView extends React.Component<IProps, IStates> {
22532271
private _originalFeatures: IDict<Feature<Geometry>[]> = {};
22542272
private _highlightLayer: VectorLayer<VectorSource>;
22552273
private _updateCenter: CallableFunction;
2256-
private _leftPanel?: Widget;
2274+
private _state?: IStateDB;
22572275
private _rightPanel?: Widget;
22582276
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IStateDB } from '@jupyterlab/statedb';
12
import { ReactWidget } from '@jupyterlab/apputils';
23
import { Widget } from '@lumino/widgets';
34
import * as React from 'react';
@@ -10,28 +11,27 @@ export class JupyterGISMainViewPanel extends ReactWidget {
1011
* Construct a `JupyterGISPanel`.
1112
*/
1213
constructor(
13-
options: { mainViewModel: MainViewModel },
14-
leftPanel?: Widget,
14+
options: { mainViewModel: MainViewModel, state?: IStateDB },
1515
rightPanel?: Widget,
1616
) {
1717
super();
1818
this._mainViewModel = options.mainViewModel;
19+
this._state = options.state;
1920
this.addClass('jp-jupytergis-panel');
20-
this._leftPanel = leftPanel;
2121
this._rightPanel = rightPanel;
2222
}
2323

2424
render(): JSX.Element {
2525
return (
2626
<MainView
27-
leftPanel={this._leftPanel}
27+
state={this._state}
2828
rightPanel={this._rightPanel}
2929
viewModel={this._mainViewModel}
3030
/>
3131
);
3232
}
3333

34+
private _state?: IStateDB;
3435
private _mainViewModel: MainViewModel;
35-
private _leftPanel?: Widget;
3636
private _rightPanel?: Widget;
3737
}

packages/base/src/panelview/components/identify-panel/IdentifyPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ interface IIdentifyComponentProps {
3838
model: IJupyterGISModel;
3939
}
4040

41-
const IdentifyPanelComponent = ({ model: model }: IIdentifyComponentProps) => {
41+
const IdentifyPanelComponent = (options: IIdentifyComponentProps) => {
4242
const [features, setFeatures] = useState<IDict<any>>();
4343
const [visibleFeatures, setVisibleFeatures] = useState<IDict<any>>({
4444
0: true,
4545
});
4646
const [remoteUser, setRemoteUser] = useState<User.IIdentity | null>(null);
47-
const jgisModel = model;
47+
const jgisModel = options.model;
4848

4949
const featuresRef = useRef(features);
5050

0 commit comments

Comments
 (0)