-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapAnalysis.tsx
executable file
·879 lines (830 loc) · 28.8 KB
/
MapAnalysis.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
import { useCallback, useMemo, useState } from 'react';
import {
AnalysisState,
DEFAULT_ANALYSIS_NAME,
EntityDiagram,
PromiseResult,
useAnalysisClient,
useDataClient,
useDownloadClient,
useFindEntityAndVariable,
useGetDefaultVariableDescriptor,
usePromise,
useStudyEntities,
useStudyMetadata,
useStudyRecord,
useSubsettingClient,
} from '../../core';
import MapVEuMap from '@veupathdb/components/lib/map/MapVEuMap';
import { useGeoConfig } from '../../core/hooks/geoConfig';
import { DocumentationContainer } from '../../core/components/docs/DocumentationContainer';
import {
CheckIcon,
Download,
Plus,
FilledButton,
Filter as FilterIcon,
FloatingButton,
H5,
Table,
} from '@veupathdb/coreui';
import { useEntityCounts } from '../../core/hooks/entityCounts';
import ShowHideVariableContextProvider from '../../core/utils/show-hide-variable-context';
import { AppState, MarkerConfiguration, useAppState } from './appState';
import Subsetting from '../../workspace/Subsetting';
import { MapHeader } from './MapHeader';
import FilterChipList from '../../core/components/FilterChipList';
import { VariableLinkConfig } from '../../core/components/VariableLink';
import { MapSidePanel } from './MapSidePanel';
import { EditLocation, InfoOutlined, Notes, Share } from '@material-ui/icons';
import { ComputationAppOverview } from '../../core/types/visualization';
import { useWdkService } from '@veupathdb/wdk-client/lib/Hooks/WdkServiceHook';
import Login from '../../workspace/sharing/#';
import { useLoginCallbacks } from '../../workspace/sharing/hooks';
import NameAnalysis from '../../workspace/sharing/NameAnalysis';
import NotesTab from '../../workspace/NotesTab';
import ConfirmShareAnalysis from '../../workspace/sharing/ConfirmShareAnalysis';
import { useHistory, useLocation, useRouteMatch } from 'react-router';
import { uniq } from 'lodash';
import Path from 'path';
import DownloadTab from '../../workspace/DownloadTab';
import { RecordController } from '@veupathdb/wdk-client/lib/Controllers';
import {
BarPlotMarkerIcon,
DonutMarkerIcon,
BubbleMarkerIcon,
} from './MarkerConfiguration/icons';
import { AllAnalyses } from '../../workspace/AllAnalyses';
import { getStudyId } from '@veupathdb/study-data-access/lib/shared/studies';
import { isSavedAnalysis } from '../../core/utils/analysis';
import { GeoConfig } from '../../core/types/geoConfig';
import {
SidePanelItem,
SidePanelMenuEntry,
SiteInformationProps,
} from './Types';
import { SideNavigationItems } from './MapSideNavigation';
import {
barMarkerPlugin,
bubbleMarkerPlugin,
donutMarkerPlugin,
} from './mapTypes';
import { MapTypeMapLayerProps } from './mapTypes/types';
import { defaultViewport } from '@veupathdb/components/lib/map/config/map';
import AnalysisNameDialog from '../../workspace/AnalysisNameDialog';
import { Page } from '@veupathdb/wdk-client/lib/Components';
import { AnalysisError } from '../../core/components/AnalysisError';
import useSnackbar from '@veupathdb/coreui/lib/components/notifications/useSnackbar';
import SettingsButton from '@veupathdb/coreui/lib/components/containers/DraggablePanel/SettingsButton';
enum MapSideNavItemLabels {
Download = 'Download',
Filter = 'Filter',
Notes = 'Notes',
Plot = 'Plot',
Share = 'Share',
StudyDetails = 'View Study Details',
MyAnalyses = 'My Analyses',
ConfigureMap = 'Configure Map',
SingleVariableMaps = 'Single Variable Maps',
GroupedVariableMaps = 'Grouped Variable Maps',
}
const mapStyle: React.CSSProperties = {
zIndex: 1,
pointerEvents: 'auto',
};
interface Props {
analysisId?: string;
sharingUrl: string;
singleAppMode?: string;
studyId: string;
siteInformationProps: SiteInformationProps;
showLinkToEda?: boolean;
}
export function MapAnalysis(props: Props) {
const appStateAndSetters = useAppState(
'@@mapApp@@',
props.analysisId,
props.singleAppMode
);
const geoConfigs = useGeoConfig(useStudyEntities());
const location = useLocation();
if (geoConfigs == null || geoConfigs.length === 0)
return (
<Page requireLogin={false}>
<h1>Incompatible Study</h1>
<div css={{ fontSize: '1.2em' }}>
<p>This study does not contain map-specific variables.</p>
</div>
</Page>
);
if (appStateAndSetters.analysisState.error) {
return (
<Page requireLogin={false}>
<AnalysisError
error={appStateAndSetters.analysisState.error}
baseAnalysisPath={location.pathname}
/>
</Page>
);
}
if (appStateAndSetters.appState == null) return null;
return (
<MapAnalysisImpl
{...props}
{...(appStateAndSetters as CompleteAppState)}
geoConfigs={geoConfigs}
/>
);
}
type CompleteAppState = ReturnType<typeof useAppState> & {
appState: AppState;
analysisState: AnalysisState;
};
interface ImplProps extends Props, CompleteAppState {
geoConfigs: GeoConfig[];
}
function MapAnalysisImpl(props: ImplProps) {
const {
appState,
analysisState,
analysisId,
setViewport,
setBoundsZoomLevel,
setSubsetVariableAndEntity,
// sharingUrl,
setIsSidePanelExpanded,
setMarkerConfigurations,
setActiveMarkerConfigurationType,
setStudyDetailsPanelConfig,
geoConfigs,
setTimeSliderConfig,
showLinkToEda = false,
} = props;
const { activeMarkerConfigurationType, markerConfigurations } = appState;
const filters = analysisState.analysis?.descriptor.subset.descriptor;
const studyRecord = useStudyRecord();
const studyMetadata = useStudyMetadata();
const studyId = studyMetadata.id;
const studyEntities = useStudyEntities(filters);
const analysisClient = useAnalysisClient();
const dataClient = useDataClient();
const downloadClient = useDownloadClient();
const subsettingClient = useSubsettingClient();
const geoConfig = geoConfigs[0];
const history = useHistory();
const [hideVizInputsAndControls, setHideVizInputsAndControls] =
useState(false);
// FIXME use the sharingUrl prop to construct this
const sharingUrl = new URL(`../${analysisId}/import`, window.location.href)
.href;
const getDefaultVariableDescriptor = useGetDefaultVariableDescriptor();
const findEntityAndVariable = useFindEntityAndVariable();
const activeMarkerConfiguration = markerConfigurations.find(
(markerConfig) => markerConfig.type === activeMarkerConfigurationType
);
const updateMarkerConfigurations = useCallback(
(updatedConfiguration: MarkerConfiguration) => {
const nextMarkerConfigurations = markerConfigurations.map(
(configuration) => {
if (configuration.type === updatedConfiguration.type) {
return updatedConfiguration;
}
return configuration;
}
);
setMarkerConfigurations(nextMarkerConfigurations);
},
[markerConfigurations, setMarkerConfigurations]
);
const userLoggedIn = useWdkService(async (wdkService) => {
const user = await wdkService.getCurrentUser();
return !user.isGuest;
});
function showLoginForm() {
const currentUrl = window.location.href;
const loginUrl = `${props.siteInformationProps.loginUrl}?destination=${currentUrl}`;
history.push(loginUrl);
}
function toggleVisible() {
setActiveSideMenuId(undefined);
}
const loginCallbacks = useLoginCallbacks({ showLoginForm, toggleVisible });
const appsPromiseState = usePromise(
useCallback(async () => {
const { apps } = await dataClient.getApps();
return apps; // return all apps; new viz picker will only show those with client plugins defined
}, [dataClient])
);
const totalCounts = useEntityCounts();
const filteredCounts = useEntityCounts(
analysisState.analysis?.descriptor.subset.descriptor
);
const subsetVariableAndEntity = useMemo(() => {
return appState.subsetVariableAndEntity ?? getDefaultVariableDescriptor();
}, [appState.subsetVariableAndEntity, getDefaultVariableDescriptor]);
function openSubsetPanelFromControlOutsideOfNavigation() {
setActiveSideMenuId('filter');
setIsSidePanelExpanded(true);
}
const FilterChipListForHeader = () => {
if (!studyEntities || !filters) return <></>;
const filterChipConfig: VariableLinkConfig = {
type: 'button',
onClick(value) {
setSubsetVariableAndEntity(value);
openSubsetPanelFromControlOutsideOfNavigation();
},
};
return (
<div
style={{
// These styles format the "Show X Filters" and filter chips
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: 30,
}}
className="FilterChips"
>
<FilledButton
disabled={
// You don't need this button if whenever the filter
// section is active and expanded.
appState.isSidePanelExpanded && activeSideMenuId === 'filter'
}
themeRole="primary"
text="Add filters"
onPress={openSubsetPanelFromControlOutsideOfNavigation}
size="small"
textTransform="unset"
styleOverrides={{
container: {
width: 'max-content',
marginBottom: '5px',
},
}}
/>
<div style={{ margin: '0 10px' }}>
<FilterChipList
filters={filters}
removeFilter={(filter) =>
analysisState.analysis &&
analysisState.setFilters(
analysisState.analysis.descriptor.subset.descriptor.filter(
(f) => f !== filter
)
)
}
variableLinkConfig={filterChipConfig}
entities={studyEntities}
selectedEntityId={subsetVariableAndEntity.entityId}
selectedVariableId={subsetVariableAndEntity.variableId}
/>
</div>
</div>
);
};
const filteredEntities = uniq(filters?.map((f) => f.entityId));
const [isAnalysisNameDialogOpen, setIsAnalysisNameDialogOpen] =
useState(false);
const { url: urlRouteMatch } = useRouteMatch();
const redirectURL = studyId
? urlRouteMatch.endsWith(studyId)
? `/workspace/${urlRouteMatch}/new`
: Path.resolve(urlRouteMatch, '../new')
: null;
const redirectToNewAnalysis = useCallback(() => {
if (redirectURL) history.push(redirectURL);
}, [history, redirectURL]);
const sidePanelMenuEntries: SidePanelMenuEntry[] = [
{
type: 'heading',
labelText: MapSideNavItemLabels.ConfigureMap,
leftIcon: <EditLocation />,
children: [
{
type: 'subheading',
labelText: MapSideNavItemLabels.SingleVariableMaps,
children: [
{
type: 'item',
id: 'single-variable-pie',
labelText: donutMarkerPlugin.displayName,
rightIcon: <DonutMarkerIcon style={{ height: '1.25em' }} />,
leftIcon:
activeMarkerConfigurationType === 'pie' ? <CheckIcon /> : null,
onActive: () => {
setActiveMarkerConfigurationType('pie');
},
renderSidePanelDrawer(apps) {
return (
<donutMarkerPlugin.ConfigPanelComponent
apps={apps}
analysisState={analysisState}
appState={appState}
studyId={studyId}
filters={filters}
studyEntities={studyEntities}
geoConfigs={geoConfigs}
configuration={activeMarkerConfiguration}
updateConfiguration={updateMarkerConfigurations as any}
hideVizInputsAndControls={hideVizInputsAndControls}
setHideVizInputsAndControls={setHideVizInputsAndControls}
/>
);
},
},
{
type: 'item',
id: 'single-variable-bar',
labelText: barMarkerPlugin.displayName,
leftIcon:
activeMarkerConfigurationType === 'barplot' ? (
<CheckIcon />
) : null,
rightIcon: <BarPlotMarkerIcon style={{ height: '1.25em' }} />,
onActive: () => {
setActiveMarkerConfigurationType('barplot');
},
renderSidePanelDrawer(apps) {
return (
<barMarkerPlugin.ConfigPanelComponent
apps={apps}
analysisState={analysisState}
appState={appState}
studyId={studyId}
filters={filters}
studyEntities={studyEntities}
geoConfigs={geoConfigs}
configuration={activeMarkerConfiguration}
updateConfiguration={updateMarkerConfigurations as any}
hideVizInputsAndControls={hideVizInputsAndControls}
setHideVizInputsAndControls={setHideVizInputsAndControls}
/>
);
},
},
{
type: 'item',
id: 'single-variable-bubble',
labelText: bubbleMarkerPlugin.displayName,
rightIcon: <BubbleMarkerIcon style={{ height: '1.25em' }} />,
leftIcon:
activeMarkerConfigurationType === 'bubble' ? (
<CheckIcon />
) : null,
onActive: () => setActiveMarkerConfigurationType('bubble'),
renderSidePanelDrawer(apps) {
return (
<bubbleMarkerPlugin.ConfigPanelComponent
apps={apps}
analysisState={analysisState}
appState={appState}
studyId={studyId}
filters={filters}
studyEntities={studyEntities}
geoConfigs={geoConfigs}
configuration={activeMarkerConfiguration}
updateConfiguration={updateMarkerConfigurations as any}
hideVizInputsAndControls={hideVizInputsAndControls}
setHideVizInputsAndControls={setHideVizInputsAndControls}
/>
);
},
},
],
},
],
},
{
type: 'item',
id: 'filter',
labelText: MapSideNavItemLabels.Filter,
leftIcon: <FilterIcon />,
renderSidePanelDrawer: () => {
return (
<div
style={{
width: '70vw',
maxWidth: 1500,
maxHeight: 650,
padding: '0 25px',
}}
>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<EntityDiagram
expanded
orientation="horizontal"
selectedEntity={subsetVariableAndEntity.entityId}
selectedVariable={subsetVariableAndEntity.variableId}
entityCounts={totalCounts.value}
filteredEntityCounts={filteredCounts.value}
filteredEntities={filteredEntities}
variableLinkConfig={{
type: 'button',
onClick: (variableValue) => {
setSubsetVariableAndEntity({
entityId: variableValue?.entityId,
variableId: variableValue?.variableId
? variableValue.variableId
: getDefaultVariableDescriptor(variableValue?.entityId)
.variableId,
});
},
}}
/>
</div>
<Subsetting
variableLinkConfig={{
type: 'button',
onClick: setSubsetVariableAndEntity,
}}
entityId={subsetVariableAndEntity?.entityId ?? ''}
variableId={subsetVariableAndEntity.variableId ?? ''}
analysisState={analysisState}
totalCounts={totalCounts.value}
filteredCounts={filteredCounts.value}
// gets passed to variable tree in order to disable scrollIntoView
scope="map"
/>
</div>
);
},
},
{
type: 'item',
id: 'download',
labelText: MapSideNavItemLabels.Download,
leftIcon: <Download />,
renderSidePanelDrawer: () => {
return (
<div
style={{
padding: '1em',
width: '70vw',
maxWidth: '1500px',
}}
>
<DownloadTab
downloadClient={downloadClient}
analysisState={analysisState}
totalCounts={totalCounts.value}
filteredCounts={filteredCounts.value}
/>
</div>
);
},
},
{
type: 'item',
id: 'share',
labelText: MapSideNavItemLabels.Share,
leftIcon: <Share />,
renderSidePanelDrawer: () => {
if (!analysisState.analysis) return null;
function getShareMenuContent() {
if (!userLoggedIn) {
return <Login {...loginCallbacks} showCloseButton={false} />;
}
if (analysisState?.analysis?.displayName === DEFAULT_ANALYSIS_NAME) {
return (
<NameAnalysis
currentName={analysisState.analysis.displayName}
updateName={analysisState.setName}
/>
);
}
return <ConfirmShareAnalysis sharingUrl={sharingUrl} />;
}
return (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: '0 15px',
}}
>
{getShareMenuContent()}
</div>
);
},
},
{
type: 'item',
id: 'notes',
labelText: MapSideNavItemLabels.Notes,
leftIcon: <Notes />,
renderSidePanelDrawer: () => {
return (
<div
style={{
padding: '1em',
width: '70vw',
maxWidth: '1500px',
}}
>
<NotesTab analysisState={analysisState} />
</div>
);
},
},
{
type: 'item',
id: 'my-analyses',
labelText: MapSideNavItemLabels.MyAnalyses,
leftIcon: <Table />,
renderSidePanelDrawer: () => {
return (
<div
css={{
h1: {
fontSize: '1.75em',
margin: '25px 0 0 0',
padding: '0 0 1em 0',
},
'.MesaComponent .DataTable': {
fontSize: 'inherit',
},
}}
style={{
padding: '1em',
width: '70vw',
maxWidth: '1500px',
}}
>
{analysisId && redirectToNewAnalysis ? (
<div style={{ float: 'right' }}>
<FloatingButton
text="Create new analysis"
icon={Plus}
onPress={
analysisState.analysis?.displayName ===
DEFAULT_ANALYSIS_NAME
? () => setIsAnalysisNameDialogOpen(true)
: redirectToNewAnalysis
}
textTransform="none"
/>
</div>
) : (
<></>
)}
{analysisState.analysis && (
<AnalysisNameDialog
isOpen={isAnalysisNameDialogOpen}
setIsOpen={setIsAnalysisNameDialogOpen}
initialAnalysisName={analysisState.analysis.displayName}
setAnalysisName={analysisState.setName}
redirectToNewAnalysis={redirectToNewAnalysis}
/>
)}
<AllAnalyses
analysisClient={analysisClient}
activeAnalysisId={
isSavedAnalysis(analysisState.analysis)
? analysisState.analysis.analysisId
: undefined
}
subsettingClient={subsettingClient}
studyId={getStudyId(studyRecord)}
showLoginForm={showLoginForm}
/>
</div>
);
},
},
{
type: 'item',
id: 'study-details',
labelText: MapSideNavItemLabels.StudyDetails,
leftIcon: <InfoOutlined />,
renderSidePanelDrawer: () => {
return (
<div
style={{
padding: '1em',
width: '70vw',
maxWidth: '1500px',
fontSize: '.95em',
}}
>
<H5 additionalStyles={{ margin: '25px 0 0 0' }}>Study Details</H5>
<RecordController
recordClass="dataset"
primaryKey={studyRecord.id.map((p) => p.value).join('/')}
/>
</div>
);
},
},
];
function findActiveSidePanelItem(
entries: SidePanelMenuEntry[] = sidePanelMenuEntries
): SidePanelItem | undefined {
for (const entry of entries) {
switch (entry.type) {
case 'heading':
case 'subheading':
const activeChild = findActiveSidePanelItem(entry.children);
if (activeChild) return activeChild;
break;
case 'item':
if (entry.id === activeSideMenuId) {
return entry;
}
break;
}
}
}
// activeSideMenuId is derived from the label text since labels must be unique in a navigation menu
const [activeSideMenuId, setActiveSideMenuId] = useState<string | undefined>(
'single-variable-' + appState.activeMarkerConfigurationType
);
// snackbar
const { enqueueSnackbar } = useSnackbar();
// behaviors of the Legend's setup/gear icon
const openPanel = useCallback(() => {
const nextSideMenuId =
'single-variable-' +
(appState.activeMarkerConfigurationType === 'barplot'
? 'bar'
: appState.activeMarkerConfigurationType);
if (appState.isSidePanelExpanded && activeSideMenuId === nextSideMenuId)
enqueueSnackbar('Marker configuration panel is already open', {
variant: 'info',
anchorOrigin: { vertical: 'top', horizontal: 'center' },
});
if (!appState.isSidePanelExpanded) setIsSidePanelExpanded(true);
if (activeSideMenuId !== nextSideMenuId)
setActiveSideMenuId(nextSideMenuId);
}, [
appState.isSidePanelExpanded,
enqueueSnackbar,
activeSideMenuId,
setActiveSideMenuId,
setIsSidePanelExpanded,
appState.activeMarkerConfigurationType,
]);
const { variable: overlayVariable } =
findEntityAndVariable(activeMarkerConfiguration?.selectedVariable) ?? {};
// component for a gear icon at Legend
const HeaderButtons: React.FC = () => (
<div style={{ marginLeft: 'auto' }}>
<SettingsButton
buttonText={`Settings ${overlayVariable?.displayName}`}
tooltipText={'Open marker configuration panel'}
size={20}
onClick={openPanel}
/>
</div>
);
// close left-side panel when map events happen
const closePanel = useCallback(
() => setIsSidePanelExpanded(false),
[setIsSidePanelExpanded]
);
const activeMapTypePlugin =
activeMarkerConfiguration?.type === 'barplot'
? barMarkerPlugin
: activeMarkerConfiguration?.type === 'bubble'
? bubbleMarkerPlugin
: activeMarkerConfiguration?.type === 'pie'
? donutMarkerPlugin
: undefined;
return (
<PromiseResult state={appsPromiseState}>
{(apps: ComputationAppOverview[]) => {
const activePanelItem = findActiveSidePanelItem();
const activeSideNavigationItemMenu =
activePanelItem?.renderSidePanelDrawer(apps) ?? null;
const mapTypeMapLayerProps: MapTypeMapLayerProps = {
apps,
analysisState,
appState,
studyId,
filters,
studyEntities,
geoConfigs,
configuration: activeMarkerConfiguration,
updateConfiguration: updateMarkerConfigurations as any,
totalCounts,
filteredCounts,
hideVizInputsAndControls,
setHideVizInputsAndControls,
setStudyDetailsPanelConfig,
headerButtons: HeaderButtons,
};
return (
<ShowHideVariableContextProvider>
<DocumentationContainer>
<div
style={{
height: '100%',
width: '100%',
position: 'relative',
display: 'flex',
flexDirection: 'column',
}}
>
<MapHeader
analysisName={analysisState.analysis?.displayName}
filterList={<FilterChipListForHeader />}
siteInformation={props.siteInformationProps}
onAnalysisNameEdit={analysisState.setName}
studyName={studyRecord.displayName}
mapTypeDetails={
activeMapTypePlugin?.MapTypeHeaderDetails && (
<activeMapTypePlugin.MapTypeHeaderDetails
{...mapTypeMapLayerProps}
/>
)
}
showLinkToEda={showLinkToEda}
>
{/* child elements will be distributed across, 'hanging' below the header */}
{/* Time slider component won't render if there's no suitable variable to use */}
{activeMapTypePlugin?.TimeSliderComponent && (
<activeMapTypePlugin.TimeSliderComponent
{...mapTypeMapLayerProps}
setTimeSliderConfig={setTimeSliderConfig}
siteInformationProps={props.siteInformationProps}
/>
)}
</MapHeader>
<div
style={{
// Make a div that completely fills its parent.
height: '100%',
width: '100%',
// Attach this div container to its parent.
position: 'relative',
// Remember that just about everything in the DOM is box.
// This div is sitting on top of the map. By disabling
// pointer events we are saying: hey, div, become porous.
// If a user clicks you, don't capture it, but let it go
// to the map you're covering.
pointerEvents: 'none',
}}
>
<MapSidePanel
isExpanded={appState.isSidePanelExpanded}
isUserLoggedIn={userLoggedIn}
onToggleIsExpanded={() =>
setIsSidePanelExpanded(!appState.isSidePanelExpanded)
}
siteInformationProps={props.siteInformationProps}
sidePanelDrawerContents={activeSideNavigationItemMenu}
>
<SideNavigationItems
activeSideMenuId={activeSideMenuId}
menuEntries={sidePanelMenuEntries}
setActiveSideMenuId={setActiveSideMenuId}
/>
</MapSidePanel>
<MapVEuMap
height="100%"
width="100%"
style={mapStyle}
showLayerSelector={false}
showSpinner={false}
viewport={appState.viewport}
onBoundsChanged={setBoundsZoomLevel}
onViewportChanged={setViewport}
showGrid={geoConfig?.zoomLevelToAggregationLevel !== null}
zoomLevelToGeohashLevel={
geoConfig?.zoomLevelToAggregationLevel
}
// pass defaultViewport & isStandAloneMap props for custom zoom control
defaultViewport={defaultViewport}
// close left-side panel when map events happen
onMapClick={closePanel}
onMapDrag={closePanel}
onMapZoom={closePanel}
>
{activeMapTypePlugin?.MapLayerComponent && (
<activeMapTypePlugin.MapLayerComponent
{...mapTypeMapLayerProps}
/>
)}
</MapVEuMap>
</div>
{activeMapTypePlugin?.MapOverlayComponent && (
<activeMapTypePlugin.MapOverlayComponent
{...mapTypeMapLayerProps}
/>
)}
</div>
</DocumentationContainer>
</ShowHideVariableContextProvider>
);
}}
</PromiseResult>
);
}