From dce52f848cb719d2ec32f446b6c7198950a12c86 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Wed, 19 May 2021 09:32:29 +0530 Subject: [PATCH] Fixes for selfserve (#796) * fixes * more edits * fixed test errors --- src/SelfServe/SelfServeUtils.test.tsx | 8 +++++--- src/SelfServe/SelfServeUtils.tsx | 10 +++++----- src/i18n.ts | 3 +-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/SelfServe/SelfServeUtils.test.tsx b/src/SelfServe/SelfServeUtils.test.tsx index 324d18f77..05016747c 100644 --- a/src/SelfServe/SelfServeUtils.test.tsx +++ b/src/SelfServe/SelfServeUtils.test.tsx @@ -190,7 +190,8 @@ describe("SelfServeUtils", () => { max: 5, step: 1, 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[], }, @@ -225,7 +226,8 @@ describe("SelfServeUtils", () => { type: "boolean", labelTKey: "Invalid Enable Logging", 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[], }, @@ -252,7 +254,7 @@ describe("SelfServeUtils", () => { type: "object", labelTKey: "Invalid Regions", 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[], }, diff --git a/src/SelfServe/SelfServeUtils.tsx b/src/SelfServe/SelfServeUtils.tsx index 3c34bc982..735cf5228 100644 --- a/src/SelfServe/SelfServeUtils.tsx +++ b/src/SelfServe/SelfServeUtils.tsx @@ -206,8 +206,8 @@ const addToDescriptor = ( const getInput = (value: DecoratorProperties): AnyDisplay => { switch (value.type) { case "number": - if (!value.labelTKey || !value.step || !value.uiType || !value.min || !value.max) { - value.errorMessage = `label, step, min, max and uiType are required for number input '${value.id}'.`; + if (!value.labelTKey || !value.uiType || !value.step || !value.max || value.min === undefined) { + value.errorMessage = `labelTkey, step, min, max and uiType are required for number input '${value.id}'.`; } return value as NumberInput; case "string": @@ -218,17 +218,17 @@ const getInput = (value: DecoratorProperties): AnyDisplay => { return value as DescriptionDisplay; } 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; case "boolean": 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; default: 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; } diff --git a/src/i18n.ts b/src/i18n.ts index 98c122828..533baca85 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -8,8 +8,7 @@ i18n .init({ fallbackLng: "en", detection: { order: ["navigator", "cookie", "localStorage", "sessionStorage", "querystring", "htmlTag"] }, - // temporarily setting debug to true to investigate loading issues in prod - debug: true, + debug: process.env.NODE_ENV === "development", keySeparator: ".", interpolation: { formatSeparator: ",",