fix(data-vi): "Current popup record" variable issue (#5984)

This commit is contained in:
YANG QIA 2025-01-02 23:36:55 +08:00 committed by GitHub
parent b1b1dc6f13
commit 72255250fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,17 +9,28 @@
import React from 'react';
import { BlockRefreshButton } from '../initializers/BlockRefreshAction';
import { SchemaComponentOptions } from '@nocobase/client';
import { SchemaComponentOptions, useCurrentPopupContext, useLocalVariables } from '@nocobase/client';
import { GlobalAutoRefreshProvider } from './GlobalAutoRefreshProvider';
import _ from 'lodash';
export const ChartBlockProvider: React.FC = (props) => {
const currentPopupContext = useCurrentPopupContext();
const localVariables = useLocalVariables();
const popUpCtxReady =
_.isEmpty(currentPopupContext) ||
localVariables?.some((variable) => variable.name === '$nPopupRecord' && variable.ctx);
if (!popUpCtxReady) {
return null;
}
return (
<SchemaComponentOptions
components={{
BlockRefreshButton,
}}
>
<GlobalAutoRefreshProvider> {props.children}</GlobalAutoRefreshProvider>
<GlobalAutoRefreshProvider>{props.children}</GlobalAutoRefreshProvider>
</SchemaComponentOptions>
);
};