SoloPanel: Fixes issue with solo route and scopes variable (#112769)
* SoloPanel: Fixes issue with solo route and scopes variable * fix lint
This commit is contained in:
@@ -77,6 +77,7 @@ export function SoloPanelRenderer({ dashboard, panelId }: { dashboard: Dashboard
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
{renderHiddenVariables(dashboard)}
|
||||
<SoloPanelContextProvider value={soloPanelContext} dashboard={dashboard} singleMatch={true}>
|
||||
<body.Component model={body} />
|
||||
</SoloPanelContextProvider>
|
||||
@@ -84,6 +85,28 @@ export function SoloPanelRenderer({ dashboard, panelId }: { dashboard: Dashboard
|
||||
);
|
||||
}
|
||||
|
||||
// Some variables like ScopesVariable needs
|
||||
// to be rendered for their logic to work even if hidden
|
||||
function renderHiddenVariables(dashboard: DashboardScene) {
|
||||
if (!dashboard.state.$variables) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const variables = dashboard.state.$variables.state.variables;
|
||||
|
||||
return (
|
||||
<>
|
||||
{variables.map((variable) => {
|
||||
if (variable.UNSAFE_renderAsHidden) {
|
||||
return <variable.Component model={variable} key={variable.state.key} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({
|
||||
container: css({
|
||||
position: 'fixed',
|
||||
|
||||
Reference in New Issue
Block a user