Fixes for selfserve (#796)

* fixes

* more edits

* fixed test errors
This commit is contained in:
Srinath Narayanan 2021-05-19 09:32:29 +05:30 committed by GitHub
parent 6e9144b068
commit dce52f848c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -190,7 +190,8 @@ describe("SelfServeUtils", () => {
max: 5, max: 5,
step: 1, step: 1,
uiType: "Spinner", uiType: "Spinner",
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidThroughput'.", errorMessage:
"labelTkey, trueLabelTKey and falseLabelTKey are required for boolean input 'invalidThroughput'.",
}, },
children: [] as Node[], children: [] as Node[],
}, },
@ -225,7 +226,8 @@ describe("SelfServeUtils", () => {
type: "boolean", type: "boolean",
labelTKey: "Invalid Enable Logging", labelTKey: "Invalid Enable Logging",
placeholderTKey: "placeholder text", placeholderTKey: "placeholder text",
errorMessage: "label, truelabel and falselabel are required for boolean input 'invalidEnableLogging'.", errorMessage:
"labelTkey, trueLabelTKey and falseLabelTKey are required for boolean input 'invalidEnableLogging'.",
}, },
children: [] as Node[], children: [] as Node[],
}, },
@ -252,7 +254,7 @@ describe("SelfServeUtils", () => {
type: "object", type: "object",
labelTKey: "Invalid Regions", labelTKey: "Invalid Regions",
placeholderTKey: "placeholder text", placeholderTKey: "placeholder text",
errorMessage: "label and choices are required for Choice input 'invalidRegions'.", errorMessage: "labelTKey and choices are required for Choice input 'invalidRegions'.",
}, },
children: [] as Node[], children: [] as Node[],
}, },

View File

@ -206,8 +206,8 @@ const addToDescriptor = (
const getInput = (value: DecoratorProperties): AnyDisplay => { const getInput = (value: DecoratorProperties): AnyDisplay => {
switch (value.type) { switch (value.type) {
case "number": case "number":
if (!value.labelTKey || !value.step || !value.uiType || !value.min || !value.max) { if (!value.labelTKey || !value.uiType || !value.step || !value.max || value.min === undefined) {
value.errorMessage = `label, step, min, max and uiType are required for number input '${value.id}'.`; value.errorMessage = `labelTkey, step, min, max and uiType are required for number input '${value.id}'.`;
} }
return value as NumberInput; return value as NumberInput;
case "string": case "string":
@ -218,17 +218,17 @@ const getInput = (value: DecoratorProperties): AnyDisplay => {
return value as DescriptionDisplay; return value as DescriptionDisplay;
} }
if (!value.labelTKey) { if (!value.labelTKey) {
value.errorMessage = `label is required for string input '${value.id}'.`; value.errorMessage = `labelTKey is required for string input '${value.id}'.`;
} }
return value as StringInput; return value as StringInput;
case "boolean": case "boolean":
if (!value.labelTKey || !value.trueLabelTKey || !value.falseLabelTKey) { if (!value.labelTKey || !value.trueLabelTKey || !value.falseLabelTKey) {
value.errorMessage = `label, truelabel and falselabel are required for boolean input '${value.id}'.`; value.errorMessage = `labelTkey, trueLabelTKey and falseLabelTKey are required for boolean input '${value.id}'.`;
} }
return value as BooleanInput; return value as BooleanInput;
default: default:
if (!value.labelTKey || !value.choices) { if (!value.labelTKey || !value.choices) {
value.errorMessage = `label and choices are required for Choice input '${value.id}'.`; value.errorMessage = `labelTKey and choices are required for Choice input '${value.id}'.`;
} }
return value as ChoiceInput; return value as ChoiceInput;
} }

View File

@ -8,8 +8,7 @@ i18n
.init({ .init({
fallbackLng: "en", fallbackLng: "en",
detection: { order: ["navigator", "cookie", "localStorage", "sessionStorage", "querystring", "htmlTag"] }, detection: { order: ["navigator", "cookie", "localStorage", "sessionStorage", "querystring", "htmlTag"] },
// temporarily setting debug to true to investigate loading issues in prod debug: process.env.NODE_ENV === "development",
debug: true,
keySeparator: ".", keySeparator: ".",
interpolation: { interpolation: {
formatSeparator: ",", formatSeparator: ",",