fix(plugin-chart-handlebars): improve CSS sanitization tooltip and hide when not needed (#39180)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maxime Beauchemin
2026-04-08 12:25:54 -07:00
committed by GitHub
parent a64609f4f3
commit 36de05fe36

View File

@@ -30,10 +30,12 @@ import { debounceFunc } from '../../consts';
interface StyleCustomControlProps {
value: string;
htmlSanitization: boolean;
}
const StyleControl = (props: CustomControlConfig<StyleCustomControlProps>) => {
const theme = useTheme();
const htmlSanitization = props.htmlSanitization ?? true;
const defaultValue = props?.value
? undefined
@@ -48,10 +50,16 @@ const StyleControl = (props: CustomControlConfig<StyleCustomControlProps>) => {
<ControlHeader>
<div>
{props.label}
<InfoTooltip
iconStyle={{ marginLeft: theme.sizeUnit }}
tooltip={t('You need to configure HTML sanitization to use CSS')}
/>
{htmlSanitization && (
<InfoTooltip
iconStyle={{ marginLeft: theme.sizeUnit }}
tooltip={t(
'CSS styles may be removed by server-side HTML sanitization. ' +
'If styles are not applying, ask your Superset administrator ' +
'to adjust the HTML sanitization configuration.',
)}
/>
)}
</div>
</ControlHeader>
<CodeEditor
@@ -79,8 +87,9 @@ export const styleControlSetItem: ControlSetItem = {
valueKey: null,
validators: [],
mapStateToProps: ({ controls }) => ({
mapStateToProps: ({ controls, common }) => ({
value: controls?.handlebars_template?.value,
htmlSanitization: common?.conf?.HTML_SANITIZATION ?? true,
}),
},
};