Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DisableFnAndHtml feature flag #2026

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,11 @@ export class Processor {
entryId: config.entryId || configId,
});

if (!isChartWithJSAndHtmlAllowed({createdAt: config.createdAt})) {
const disableFnAndHtml = isEnabledServerFeature(ctx, Feature.DisableFnAndHtml);
if (
disableFnAndHtml ||
!isChartWithJSAndHtmlAllowed({createdAt: config.createdAt})
) {
resultConfig.enableJsAndHtml = false;
}
const enableJsAndHtml = get(resultConfig, 'enableJsAndHtml', false);
Expand Down
10 changes: 10 additions & 0 deletions src/server/components/features/features-list/DisableFnAndHtml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Feature} from '../../../../shared';
import {createFeatureConfig} from '../utils';

export default createFeatureConfig({
name: Feature.DisableFnAndHtml,
state: {
development: false,
production: false,
},
});
2 changes: 1 addition & 1 deletion src/shared/constants/qa/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export const enum EditorTemplatesQA {
Markdown = 'editor-templates-markdown-item',
Timeseries = 'editor-templates-timeseries-item',
Markup = 'editor-templates-markup-item',
D3 = 'editor-templates-d3-item',
GravityCharts = 'editor-templates-gravity-charts-item',
BlankChart = 'editor-templates-blank-chart-item',
}
2 changes: 2 additions & 0 deletions src/shared/types/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export enum Feature {
ChartActions = 'ChartActions',
/** Escaping string in wizard chart config to remove potential html injection */
EscapeStringInWizard = 'EscapeStringInWizard',
/** Disable the use of html and function in chart configs */
DisableFnAndHtml = 'DisableFnAndHtml',
}

export type FeatureConfig = Record<string, boolean>;
1 change: 1 addition & 0 deletions src/shared/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum EditorType {
ControlNode = 'control_node',
MarkdownNode = 'markdown_node',
MarkupNode = 'markup_node',
GravityChartsNode = 'd3_node',
}

export enum WidgetKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class UiSandboxRuntime {
}

callFunction(props: UiSandboxRuntimeProps) {
const {fn, fnContext, fnArgs, globalApi, libs, name} = props;
const {fn, fnContext = {}, fnArgs, globalApi, libs, name} = props;

this.vm.evalCode(libs);

Expand Down
1 change: 1 addition & 0 deletions src/ui/units/dash/containers/Dialogs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function isEntryTypeWithFiltering(
const widgetTypesWithFilteringAvailable: WidgetType[] = [
EditorType.TableNode,
EditorType.GraphNode,
EditorType.GravityChartsNode,
];

const wizardEntryTypes = [
Expand Down
1 change: 1 addition & 0 deletions src/ui/units/editor/components/NodeTemplates/List/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function Item({item, onClick}) {
return (
<div className={b('item')} onClick={() => onClick(item)} data-qa={item.qa}>
{i18n('editor.templates.view', `label_${name}`)}
{item.version ? <span className={b('item-version')}>{item.version}</span> : null}
</div>
);
}
Expand Down
7 changes: 7 additions & 0 deletions src/ui/units/editor/components/NodeTemplates/List/List.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@
font-size: 16px;
font-weight: bold;
}

&__item-version {
color: var(--g-color-base-brand);
font-weight: bold;
margin-bottom: 8px;
margin-left: 4px;
}
}
2 changes: 1 addition & 1 deletion src/ui/units/editor/constants/templates/d3-chart.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {EDITOR_TYPE, EditorTemplatesQA} from '../../../../../shared/constants';

export default {
qa: EditorTemplatesQA.D3,
qa: EditorTemplatesQA.GravityCharts,
name: 'd3',
type: EDITOR_TYPE.D3_NODE,
data: {
Expand Down
Loading