1
1
import {
2
2
IAnnotationModel ,
3
3
IJGISFormSchemaRegistry ,
4
+ IJupyterGISClientState ,
4
5
IJupyterGISModel ,
5
6
} from '@jupytergis/schema' ;
6
7
import * as React from 'react' ;
@@ -23,15 +24,50 @@ interface IRightPanelProps {
23
24
24
25
export const RightPanel : React . FC < IRightPanelProps > = props => {
25
26
const [ settings , setSettings ] = React . useState ( props . model . jgisSettings ) ;
27
+ const tabInfo = [
28
+ ! settings . objectPropertiesDisabled
29
+ ? { name : 'objectProperties' , title : 'Object Properties' }
30
+ : false ,
31
+ ! settings . annotationsDisabled
32
+ ? { name : 'annotations' , title : 'Annotations' }
33
+ : false ,
34
+ ! settings . identifyDisabled
35
+ ? { name : 'identifyPanel' , title : 'Identified Features' }
36
+ : false ,
37
+ ] . filter ( Boolean ) as { name : string ; title : string } [ ] ;
38
+
39
+ const [ curTab , setCurTab ] = React . useState < string | undefined > (
40
+ tabInfo . length > 0 ? tabInfo [ 0 ] . name : undefined ,
41
+ ) ;
26
42
27
43
React . useEffect ( ( ) => {
28
44
const onSettingsChanged = ( ) => {
29
45
setSettings ( { ...props . model . jgisSettings } ) ;
30
46
} ;
47
+ let currentlyIdentifiedFeatures : any = undefined ;
48
+ const onAwerenessChanged = (
49
+ _ : IJupyterGISModel ,
50
+ clients : Map < number , IJupyterGISClientState > ,
51
+ ) => {
52
+ const clientId = props . model . getClientId ( ) ;
53
+ const localState = clientId ? clients . get ( clientId ) : null ;
54
+
55
+ if (
56
+ localState &&
57
+ localState . identifiedFeatures ?. value &&
58
+ localState . identifiedFeatures . value !== currentlyIdentifiedFeatures
59
+ ) {
60
+ currentlyIdentifiedFeatures = localState . identifiedFeatures . value ;
61
+ setCurTab ( 'identifyPanel' ) ;
62
+ }
63
+ } ;
31
64
32
65
props . model . settingsChanged . connect ( onSettingsChanged ) ;
66
+ props . model . clientStateChanged . connect ( onAwerenessChanged ) ;
67
+
33
68
return ( ) => {
34
69
props . model . settingsChanged . disconnect ( onSettingsChanged ) ;
70
+ props . model . clientStateChanged . disconnect ( onAwerenessChanged ) ;
35
71
} ;
36
72
} , [ props . model ] ) ;
37
73
@@ -43,22 +79,6 @@ export const RightPanel: React.FC<IRightPanelProps> = props => {
43
79
const rightPanelVisible =
44
80
! settings . rightPanelDisabled && ! allRightTabsDisabled ;
45
81
46
- const tabInfo = [
47
- ! settings . objectPropertiesDisabled
48
- ? { name : 'objectProperties' , title : 'Object Properties' }
49
- : false ,
50
- ! settings . annotationsDisabled
51
- ? { name : 'annotations' , title : 'Annotations' }
52
- : false ,
53
- ! settings . identifyDisabled
54
- ? { name : 'identifyPanel' , title : 'Identified Features' }
55
- : false ,
56
- ] . filter ( Boolean ) as { name : string ; title : string } [ ] ;
57
-
58
- const [ curTab , setCurTab ] = React . useState < string | undefined > (
59
- tabInfo . length > 0 ? tabInfo [ 0 ] . name : undefined ,
60
- ) ;
61
-
62
82
const [ selectedObjectProperties , setSelectedObjectProperties ] =
63
83
React . useState ( undefined ) ;
64
84
0 commit comments