This commit is contained in:
2025-11-14 02:35:17 +01:00
parent 6f4ff68062
commit a3c5494bf7
53 changed files with 269 additions and 340 deletions
+8 -7
View File
@@ -88,13 +88,14 @@ const DocumentInfoPanel: React.FC<DocumentInfoPanelProps> = ({
const contentConfig = contentConfigProp || null;
const contentEnabled = Boolean(contentConfig && (contentConfig.enabled ?? true));
const loadContent = contentConfig?.loadContent ?? null;
const showContentTab = Boolean(contentConfig && (contentConfig.forceDisplay ?? contentEnabled));
const [contentState, setContentState] = useState<ContentState | null>(() => {
if (!contentConfig) {
return null;
}
if (!contentEnabled || typeof contentConfig.loadContent !== 'function') {
if (!contentEnabled || !loadContent) {
return { status: contentEnabled ? 'idle' : 'unavailable', data: null, error: null };
}
return { status: 'idle', data: null, error: null };
@@ -106,7 +107,7 @@ const DocumentInfoPanel: React.FC<DocumentInfoPanelProps> = ({
return undefined;
}
if (!contentEnabled || typeof contentConfig.loadContent !== 'function') {
if (!contentEnabled || !loadContent) {
setContentState({ status: contentEnabled ? 'idle' : 'unavailable', data: null, error: null });
return undefined;
}
@@ -116,7 +117,7 @@ const DocumentInfoPanel: React.FC<DocumentInfoPanelProps> = ({
setContentState({ status: 'loading', data: null, error: null });
Promise.resolve(contentConfig.loadContent({ signal: controller.signal }))
Promise.resolve(loadContent({ signal: controller.signal }))
.then((result) => {
if (cancelled) {
return;
@@ -143,7 +144,7 @@ const DocumentInfoPanel: React.FC<DocumentInfoPanelProps> = ({
controller.abort();
contentConfig.onCancel?.();
};
}, [contentConfig, contentEnabled, showContentTab, document?.id, resetKey]);
}, [contentConfig, contentEnabled, showContentTab, document?.id, resetKey, loadContent]);
const renderSummarySection = useCallback(() => (
<DocumentSummarySection
@@ -345,10 +346,10 @@ const DocumentInfoPanel: React.FC<DocumentInfoPanelProps> = ({
if (!tab) {
return null;
}
if (typeof tab.render === 'function') {
return tab.render(context);
if (!tab.render) {
return null;
}
return null;
return tab.render(context);
};
const isControlled = controlledActiveTab !== undefined && controlledActiveTab !== null;