fix: feature flags typing (#15254)

* fix: feature flags typing

* fix tests

* add note in UPDATING.md

* fix frontend

* also move SCHEDULED_QUERIES to top level

* fix test

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
This commit is contained in:
Daniel Vaz Gaspar
2021-11-19 15:56:16 +00:00
committed by GitHub
parent 02a9b84b14
commit 69f9ee8f5e
10 changed files with 45 additions and 32 deletions

View File

@@ -26,6 +26,12 @@ import { Form, FormItem } from 'src/components/Form';
import './ScheduleQueryButton.less';
import Button from 'src/components/Button';
const appContainer = document.getElementById('app');
const bootstrapData = JSON.parse(
appContainer?.getAttribute('data-bootstrap') || '{}',
);
const scheduledQueriesConf = bootstrapData?.common?.conf?.SCHEDULED_QUERIES;
const validators = {
greater: (a: number, b: number) => a > b,
greater_equal: (a: number, b: number) => a >= b,
@@ -34,7 +40,7 @@ const validators = {
};
const getJSONSchema = () => {
const jsonSchema = window.featureFlags.SCHEDULED_QUERIES?.JSONSCHEMA;
const jsonSchema = scheduledQueriesConf?.JSONSCHEMA;
// parse date-time into usable value (eg, 'today' => `new Date()`)
if (jsonSchema) {
Object.entries(jsonSchema.properties).forEach(
@@ -52,10 +58,9 @@ const getJSONSchema = () => {
return {};
};
const getUISchema = () => window.featureFlags.SCHEDULED_QUERIES?.UISCHEMA;
const getUISchema = () => scheduledQueriesConf?.UISCHEMA;
const getValidationRules = () =>
window.featureFlags.SCHEDULED_QUERIES?.VALIDATION || [];
const getValidationRules = () => scheduledQueriesConf?.VALIDATION || [];
const getValidator = () => {
const rules: any = getValidationRules();