-
Notifications
You must be signed in to change notification settings - Fork 663
Expand file tree
/
Copy pathPanelExtensionAdapter.tsx
More file actions
756 lines (656 loc) · 24.4 KB
/
PanelExtensionAdapter.tsx
File metadata and controls
756 lines (656 loc) · 24.4 KB
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
// SPDX-FileCopyrightText: Copyright (C) 2023-2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)<lichtblick@bmwgroup.com>
// SPDX-License-Identifier: MPL-2.0
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { useTheme } from "@mui/material";
import { produce } from "immer";
import { CSSProperties, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useLatest } from "react-use";
import { v4 as uuid } from "uuid";
import { useSynchronousMountedState, useValueChangedDebugLog } from "@lichtblick/hooks";
import Logger from "@lichtblick/log";
import { fromSec, toSec } from "@lichtblick/rostime";
import {
AppSettingValue,
ExtensionPanelRegistration,
PanelExtensionContext,
ParameterValue,
RenderState,
SettingsTree,
SettingsTreeAction,
Subscription,
Time,
VariableValue,
} from "@lichtblick/suite";
import {
MessagePipelineContext,
useMessagePipeline,
useMessagePipelineGetter,
} from "@lichtblick/suite-base/components/MessagePipeline";
import { getTopicToSchemaNameMap } from "@lichtblick/suite-base/components/MessagePipeline/selectors";
import { usePanelContext } from "@lichtblick/suite-base/components/PanelContext";
import PanelToolbar from "@lichtblick/suite-base/components/PanelToolbar";
import { useAlertsActions } from "@lichtblick/suite-base/context/AlertsContext";
import { useAppConfiguration } from "@lichtblick/suite-base/context/AppConfigurationContext";
import {
ExtensionCatalog,
getExtensionPanelSettings,
useExtensionCatalog,
} from "@lichtblick/suite-base/context/ExtensionCatalogContext";
import {
useClearHoverValue,
useHoverValue,
useSetHoverValue,
} from "@lichtblick/suite-base/context/TimelineInteractionStateContext";
import useGlobalVariables from "@lichtblick/suite-base/hooks/useGlobalVariables";
import { PLAYER_CAPABILITIES } from "@lichtblick/suite-base/players/constants";
import {
AdvertiseOptions,
PlayerPresence,
SubscribePayload,
} from "@lichtblick/suite-base/players/types";
import {
useDefaultPanelTitle,
usePanelSettingsTreeUpdate,
} from "@lichtblick/suite-base/providers/PanelStateContextProvider";
import { PanelConfig, SaveConfig } from "@lichtblick/suite-base/types/panels";
import { assertNever } from "@lichtblick/suite-base/util/assertNever";
import { maybeCast } from "@lichtblick/suite-base/util/maybeCast";
import { PanelConfigVersionError } from "./PanelConfigVersionError";
import { RenderStateConfig, initRenderStateBuilder } from "./renderState";
import { BuiltinPanelExtensionContext, MessageConverterAlertHandler } from "./types";
import { useSharedPanelState } from "./useSharedPanelState";
import { useSubscribeMessageRange } from "./useSubscribeMessageRange";
const log = Logger.getLogger(__filename);
type VersionedPanelConfig = Record<string, unknown> & { [VERSION_CONFIG_KEY]: number };
export const VERSION_CONFIG_KEY = "foxgloveConfigVersion";
function isVersionedPanelConfig(config: unknown): config is VersionedPanelConfig {
return (
config != undefined &&
typeof config === "object" &&
VERSION_CONFIG_KEY in config &&
typeof config[VERSION_CONFIG_KEY] === "number"
);
}
type PanelExtensionAdapterProps = {
/** function that initializes the panel extension */
initPanel:
| ExtensionPanelRegistration["initPanel"]
| ((context: BuiltinPanelExtensionContext) => void);
/**
* If defined, the highest supported version of config the panel supports.
* Used to prevent older implementations of a panel from trying to access
* newer, incompatible versions of the panel's config. Panels should include a
* numbered foxgloveConfigVersion property in their config to control this.
*/
highestSupportedConfigVersion?: number;
config: unknown;
saveConfig: SaveConfig<unknown>;
};
function selectContext(ctx: MessagePipelineContext) {
return ctx;
}
function selectInstalledMessageConverters(state: ExtensionCatalog) {
return state.installedMessageConverters;
}
type RenderFn = NonNullable<PanelExtensionContext["onRender"]>;
/**
* PanelExtensionAdapter renders a panel extension via initPanel
*
* The adapter creates a PanelExtensionContext and invokes initPanel using the context.
*/
function PanelExtensionAdapter(
props: React.PropsWithChildren<PanelExtensionAdapterProps>,
): React.JSX.Element {
const { initPanel, config, saveConfig, highestSupportedConfigVersion } = props;
// Unlike the react data flow, the config is only provided to the panel once on setup.
// The panel is meant to manage the config and call saveConfig on its own.
//
// We store the config in a ref to avoid re-initializing the panel when the react config
// changes.
const initialState = useLatest(maybeCast<RenderStateConfig>(config));
const messagePipelineContext = useMessagePipeline(selectContext);
const {
playerState,
pauseFrame,
setSubscriptions,
seekPlayback,
getMetadata,
sortedTopics,
sortedServices,
} = messagePipelineContext;
const { capabilities, profile: dataSourceProfile, presence: playerPresence } = playerState;
const { openSiblingPanel, setMessagePathDropConfig, type: panelName } = usePanelContext();
const [panelId] = useState(() => uuid());
const isMounted = useSynchronousMountedState();
const [error, setError] = useState<Error | undefined>();
const [forceConversion, setForceConversion] = useState(new Set<string>());
const [watchedFields, setWatchedFields] = useState(new Set<keyof RenderState>());
const messageConverters = useExtensionCatalog(selectInstalledMessageConverters);
const [localSubscriptions, setLocalSubscriptions] = useState<Subscription[]>([]);
const [appSettings, setAppSettings] = useState(new Map<string, AppSettingValue>());
const [subscribedAppSettings, setSubscribedAppSettings] = useState<string[]>([]);
const [renderFn, setRenderFn] = useState<RenderFn | undefined>();
const isPanelInitializedRef = useRef(false);
const [slowRender, setSlowRender] = useState(false);
const [, setDefaultPanelTitle] = useDefaultPanelTitle();
const { setAlert } = useAlertsActions();
const { globalVariables, setGlobalVariables } = useGlobalVariables();
const hoverValue = useHoverValue({
componentId: `PanelExtensionAdapter:${panelId}`,
isPlaybackSeconds: true,
});
const setHoverValue = useSetHoverValue();
const clearHoverValue = useClearHoverValue();
// track the advertisements requested by the panel context
// topic -> advertisement
const advertisementsRef = useRef(new Map<string, AdvertiseOptions>());
const {
palette: { mode: colorScheme },
} = useTheme();
const appConfiguration = useAppConfiguration();
// The panel extension context exposes methods on the message pipeline. We don't want
// the extension context to be re-created when the message pipeline changes since it only
// needs to act on the latest version of the message pipeline.
//
// This getter allows the extension context to remain stable through pipeline changes
const getMessagePipelineContext = useMessagePipelineGetter();
// initRenderStateBuilder render produces a function which computes the latest render state from a set of inputs
// Spiritually its like a reducer
const [buildRenderState, setBuildRenderState] = useState(() => initRenderStateBuilder());
const [sharedPanelState, setSharedPanelState] = useSharedPanelState();
const emitMessageConverterAlert = useMemo<MessageConverterAlertHandler>(
() => (converter, alert, alertId) => {
const converterTag = `message-converter:${converter.extensionId ?? "unknown"}:${
converter.fromSchemaName
}->${converter.toSchemaName}`;
const tag = alertId ? `${converterTag}:${alertId}` : converterTag;
setAlert(tag, alert);
},
[setAlert],
);
const subscribeMessageRange = useSubscribeMessageRange(emitMessageConverterAlert);
// Register handlers to update the app settings we subscribe to
useEffect(() => {
const handlers = new Map<string, (newValue: AppSettingValue) => void>();
for (const key of subscribedAppSettings) {
const handler = (newValue: AppSettingValue) => {
setAppSettings((old) => {
old.set(key, newValue);
return new Map(old);
});
};
handlers.set(key, handler);
appConfiguration.addChangeListener(key, handler);
}
const newAppSettings = new Map<string, AppSettingValue>();
for (const key of subscribedAppSettings) {
newAppSettings.set(key, appConfiguration.get(key));
}
setAppSettings(newAppSettings);
return () => {
for (const [key, handler] of handlers.entries()) {
appConfiguration.removeChangeListener(key, handler);
}
};
}, [appConfiguration, subscribedAppSettings]);
const messageEvents = useMemo(
() => messagePipelineContext.messageEventsBySubscriberId.get(panelId),
[messagePipelineContext.messageEventsBySubscriberId, panelId],
);
// The rendering ref is set when we've begin rendering the frame (calling the panel's render
// function)
//
// If another update arrives before the panel finishes rendering, we will update the
// slowRenderState to indicate that the panel could not keep up with rendering relative to
// updates.
const renderingRef = useRef<boolean>(false);
useLayoutEffect(() => {
/**
* We need to check that the panel has been initialized because the renderFn function is being
* called between the initPanel's useLayoutEffect cleanup and initPanel being called
* again even if setRenderFn(undefined) is called in the cleanup function. This causes
* the old renderFn to be called in this effect and pauseFrame to happen, but it is never
* resumed, thus causing a 5 second delay in all panels in the layout to be loaded.
*/
if (!renderFn || !isPanelInitializedRef.current) {
return;
}
const renderState = buildRenderState({
appSettings,
colorScheme,
currentFrame: messageEvents,
emitAlert: emitMessageConverterAlert,
globalVariables,
hoverValue,
messageConverters,
playerState,
sharedPanelState,
sortedTopics,
sortedServices,
subscriptions: localSubscriptions,
watchedFields,
forceConversion,
config: initialState.current,
});
if (!renderState) {
return;
}
if (renderingRef.current) {
setSlowRender(true);
return;
}
// Clear any conversions that were forced.
forceConversion.clear();
setSlowRender(false);
const resumeFrame = pauseFrame(panelId);
// tell the panel to render and lockout future renders until rendering is complete
renderingRef.current = true;
try {
setError(undefined);
let doneCalled = false;
renderFn(renderState, () => {
// ignore any additional done calls from the panel
if (doneCalled) {
log.warn(`${panelId} called render done function twice`);
return;
}
doneCalled = true;
resumeFrame();
renderingRef.current = false;
});
} catch (e: unknown) {
const err = e as Error;
setError(err);
}
}, [
appSettings,
buildRenderState,
colorScheme,
emitMessageConverterAlert,
globalVariables,
hoverValue,
localSubscriptions,
messageConverters,
messageEvents,
panelId,
pauseFrame,
playerState,
renderFn,
sharedPanelState,
sortedTopics,
sortedServices,
watchedFields,
initialState,
forceConversion,
]);
const updatePanelSettingsTree = usePanelSettingsTreeUpdate();
const extensionsSettings = useExtensionCatalog(getExtensionPanelSettings);
type PartialPanelExtensionContext = Omit<BuiltinPanelExtensionContext, "panelElement">;
const messagePipelineState = useMessagePipelineGetter();
const partialExtensionContext = useMemo<PartialPanelExtensionContext>(() => {
const layout: PanelExtensionContext["layout"] = {
addPanel: ({ position, type, updateIfExists, getState }) => {
if (!isMounted()) {
return;
}
// Check if it is not sibling. Currently it is impossible, but in the future it might be possible.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (position !== "sibling") {
assertNever(position, `Unsupported position for addPanel: ${position}`);
}
openSiblingPanel({
panelType: type,
updateIfExists,
siblingConfigCreator: (existingConfig) => getState(existingConfig) as PanelConfig,
});
},
};
const extensionSettingsActionHandler = (action: SettingsTreeAction) => {
if (action.action === "reorder-node") {
return; // Extensions don't support reordering
}
const {
payload: { path },
} = action;
saveConfig(
produce<{ topics: Record<string, unknown> }>((draft) => {
const [category, topicName] = path;
if (category === "topics" && topicName != undefined) {
const topicToSchemaNameMap = getTopicToSchemaNameMap(messagePipelineState());
const schemaName = topicToSchemaNameMap[topicName];
if (schemaName == undefined) {
return;
}
extensionsSettings[panelName]?.[schemaName]?.handler(action, draft.topics[topicName]);
setForceConversion((_old) => {
return new Set([topicName]);
});
}
}),
);
};
return {
initialState: initialState.current,
saveState: (state) => {
if (!isMounted()) {
return;
}
saveConfig(state);
},
layout,
metadata: getMetadata(),
seekPlayback: seekPlayback
? (stamp: number | Time) => {
if (!isMounted()) {
return;
}
const seekTarget = typeof stamp === "object" ? stamp : fromSec(stamp);
seekPlayback(seekTarget);
}
: undefined,
dataSourceProfile,
setParameter: (name: string, value: ParameterValue) => {
if (!isMounted()) {
return;
}
getMessagePipelineContext().setParameter(name, value);
},
setVariable: (name: string, value: VariableValue) => {
if (!isMounted()) {
return;
}
setGlobalVariables({ [name]: value });
},
setPreviewTime: (stamp: number | undefined) => {
if (!isMounted()) {
return;
}
if (stamp == undefined) {
clearHoverValue("PanelExtensionAdatper");
} else {
const ctx = getMessagePipelineContext();
const startTime = ctx.playerState.activeData?.startTime;
// if we don't have a start time we cannot correctly set the playback seconds hover value
// this hover value needs seconds from start
if (!startTime) {
return;
}
const secondsFromStart = stamp - toSec(startTime);
setHoverValue({
type: "PLAYBACK_SECONDS",
componentId: "PanelExtensionAdatper",
value: secondsFromStart,
});
}
},
setSharedPanelState,
watch: (field: keyof RenderState) => {
if (!isMounted()) {
return;
}
setWatchedFields((old) => {
if (old.has(field)) {
// In React 18 we noticed that this setter function would be called in an infinite loop
// even though watch() was not called repeatedly. Adding this early return of the old
// value fixed the issue.
return old;
}
const newWatchedFields = new Set(old);
newWatchedFields.add(field);
return newWatchedFields;
});
},
subscribe: (topics: ReadonlyArray<string | Subscription>) => {
if (!isMounted()) {
return;
}
const subscribePayloads = topics.map((item): SubscribePayload => {
if (typeof item === "string") {
// For backwards compatability with the topic-string-array api `subscribe(["/topic"])`
// results in a topic subscription with full preloading
return { topic: item, preloadType: "full" };
}
return {
topic: item.topic,
preloadType: item.preload === true ? "full" : "partial",
};
});
// ExtensionPanel-Facing subscription type
const localSubs = topics.map((item): Subscription => {
if (typeof item === "string") {
return { topic: item, preload: true };
}
return item;
});
setLocalSubscriptions(localSubs);
setSubscriptions(panelId, subscribePayloads);
},
advertise: capabilities.includes(PLAYER_CAPABILITIES.advertise)
? (topic: string, datatype: string, options) => {
if (!isMounted()) {
return;
}
const payload: AdvertiseOptions = {
topic,
schemaName: datatype,
options,
};
advertisementsRef.current.set(topic, payload);
getMessagePipelineContext().setPublishers(
panelId,
Array.from(advertisementsRef.current.values()),
);
}
: undefined,
unadvertise: capabilities.includes(PLAYER_CAPABILITIES.advertise)
? (topic: string) => {
if (!isMounted()) {
return;
}
advertisementsRef.current.delete(topic);
getMessagePipelineContext().setPublishers(
panelId,
Array.from(advertisementsRef.current.values()),
);
}
: undefined,
publish: capabilities.includes(PLAYER_CAPABILITIES.advertise)
? (topic, message) => {
if (!isMounted()) {
return;
}
getMessagePipelineContext().publish({
topic,
msg: message as Record<string, unknown>,
});
}
: undefined,
callService: capabilities.includes(PLAYER_CAPABILITIES.callServices)
? async (service, request): Promise<unknown> => {
if (!isMounted()) {
throw new Error("Service call after panel was unmounted");
}
return await getMessagePipelineContext().callService(service, request);
}
: undefined,
unstable_fetchAsset: async (uri, options) => {
if (!isMounted()) {
throw new Error("Asset fetch after panel was unmounted");
}
return await getMessagePipelineContext().fetchAsset(uri, options);
},
unsubscribeAll: () => {
if (!isMounted()) {
return;
}
setLocalSubscriptions([]);
setSubscriptions(panelId, []);
},
subscribeAppSettings: (settings: string[]) => {
if (!isMounted()) {
return;
}
setSubscribedAppSettings(settings);
},
updatePanelSettingsEditor: (settings: SettingsTree) => {
if (!isMounted()) {
return;
}
const actionHandler: typeof settings.actionHandler = (action) => {
settings.actionHandler(action);
extensionSettingsActionHandler(action);
};
updatePanelSettingsTree({ ...settings, actionHandler });
},
setDefaultPanelTitle: (title: string) => {
if (!isMounted()) {
return;
}
setDefaultPanelTitle(title);
},
/**
* EXPERIMENTAL: Subscribe to message ranges for efficient batch processing.
*
* This API is marked as "unstable" because it's still experimental and not fully functional.
* We're gradually testing and refining this feature to see how it performs in real-world scenarios.
*
* The API may change without notice as we gather feedback and improve the implementation.
* Use with caution in production environments.
*
* Current limitations:
* - Performance characteristics may vary
* - Error handling is still being refined
* - API surface may change based on testing feedback
*/
unstable_subscribeMessageRange(args) {
if (!isMounted()) {
return () => {};
}
return subscribeMessageRange(args);
},
unstable_setMessagePathDropConfig(dropConfig) {
setMessagePathDropConfig(dropConfig);
},
};
// Disable this rule because the metadata function. If used, it will break.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
initialState,
seekPlayback,
dataSourceProfile,
setSharedPanelState,
capabilities,
isMounted,
openSiblingPanel,
saveConfig,
extensionsSettings,
panelName,
getMessagePipelineContext,
setGlobalVariables,
clearHoverValue,
setHoverValue,
setSubscriptions,
panelId,
updatePanelSettingsTree,
setDefaultPanelTitle,
setMessagePathDropConfig,
subscribeMessageRange,
]);
const panelContainerRef = useRef<HTMLDivElement>(ReactNull);
useValueChangedDebugLog(initPanel, "initPanel");
useValueChangedDebugLog(panelId, "panelId");
useValueChangedDebugLog(partialExtensionContext, "partialExtensionContext");
const configTooNew = useMemo(() => {
const latestConfig = initialState.current;
return (
isVersionedPanelConfig(latestConfig) &&
highestSupportedConfigVersion != undefined &&
latestConfig[VERSION_CONFIG_KEY] > highestSupportedConfigVersion
);
}, [initialState, highestSupportedConfigVersion]);
const playerIsInitializing = playerPresence === PlayerPresence.INITIALIZING;
// Manage extension lifecycle by calling initPanel() when the panel context changes.
//
// If we useEffect here instead of useLayoutEffect, the prevRenderState can get polluted with data
// from a previous panel instance.
useLayoutEffect(() => {
if (!panelContainerRef.current) {
throw new Error("Expected panel container to be mounted");
}
// Also don't show panel when the player is initializing. The initializing state is temporary for
// players to go through to load their sources. Once a player has completed initialization `initPanel` is called again (or even a few times),
// because parts of the player context have changed. This cleans up the old panel that was present
// during initialization. So there can be no state held between extension panels between initialization and
// whatever follows it. To prevent this unnecessary render, we do not render the panel during initialization.
if (configTooNew || playerIsInitializing) {
return;
}
// Reset local state when the panel element is mounted or changes
setRenderFn(undefined);
renderingRef.current = false;
setSlowRender(false);
setBuildRenderState(() => initRenderStateBuilder());
const panelElement = document.createElement("div");
panelElement.style.width = "100%";
panelElement.style.height = "100%";
panelElement.style.overflow = "hidden";
panelContainerRef.current.appendChild(panelElement);
log.info(`Init panel ${panelId}`);
const onUnmount = initPanel({
panelElement,
...partialExtensionContext,
// eslint-disable-next-line no-restricted-syntax
set onRender(renderFunction: RenderFn | undefined) {
setRenderFn(() => renderFunction);
},
});
isPanelInitializedRef.current = true;
return () => {
if (onUnmount) {
onUnmount();
}
isPanelInitializedRef.current = false;
panelElement.remove();
getMessagePipelineContext().setSubscriptions(panelId, []);
getMessagePipelineContext().setPublishers(panelId, []);
};
}, [
initPanel,
panelId,
partialExtensionContext,
getMessagePipelineContext,
configTooNew,
playerIsInitializing,
]);
const style: CSSProperties = {};
if (slowRender) {
style.borderColor = "orange";
style.borderWidth = "1px";
style.borderStyle = "solid";
}
if (error) {
throw error;
}
return (
<div
style={{
alignItems: "stretch",
display: "flex",
flexDirection: "column",
height: "100%",
overflow: "hidden",
width: "100%",
zIndex: 0,
...style,
}}
>
<PanelToolbar />
{configTooNew && <PanelConfigVersionError />}
{props.children}
<div style={{ flex: 1, overflow: "hidden" }} ref={panelContainerRef} />
</div>
);
}
export default PanelExtensionAdapter;