From 720a4a85c6bc673221ae65ee30a6a215a92e300c Mon Sep 17 00:00:00 2001 From: JKAUSHALYA Date: Tue, 6 Feb 2024 11:59:59 +0530 Subject: [PATCH 1/2] Add custom templating to custom SMS provider. Fix: https://github.com/wso2/product-is/issues/19277 --- .../i18n/resources/en-US/extensions.ts | 8 +- .../constants/sms-provider-constants.ts | 3 +- .../pages/custom-sms-provider.tsx | 124 +++--------------- 3 files changed, 22 insertions(+), 113 deletions(-) diff --git a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts index ba1828dca20..68fc79273e6 100755 --- a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts @@ -2194,7 +2194,7 @@ export const extensions: Extensions = { contentType: { label: "Content Type", placeholder: "JSON", - hint: "The content type of the API request. Accepted value is JSON. (Default is JSON)" + hint: "The content type of the API request. Accepted values are 'FORM' or 'JSON'" }, headers: { label: "Headers", @@ -2202,9 +2202,9 @@ export const extensions: Extensions = { hint: "Comma seperated list of HTTP headers to be included in the SMS API request." }, payload: { - label: "Payload", - placeholder: "Enter the payload", - hint: "Static payload that will be appended after the generated payload of the SMS." + label: "Payload Template", + placeholder: "{\"content\": {{body}}, \"to\": {{mobile}} }", + hint: "The payload template of the API request. Use {{body}} to represent the generated SMS body. Use {{mobile}} to represent the mobile number." }, key: { label: "SMS Provider Auth Key", diff --git a/apps/console/src/features/sms-providers/constants/sms-provider-constants.ts b/apps/console/src/features/sms-providers/constants/sms-provider-constants.ts index 3ced7d2b8bf..307565cef23 100644 --- a/apps/console/src/features/sms-providers/constants/sms-provider-constants.ts +++ b/apps/console/src/features/sms-providers/constants/sms-provider-constants.ts @@ -21,7 +21,7 @@ import { IdentityAppsError } from "@wso2is/core/errors"; export class SMSProviderConstants { private constructor() { } - + public static readonly SMS_PROVIDER_CONFIG_NAME: string = "SMSPublisher"; public static readonly TWILIO_SMS_PROVIDER: string = "TwilioSMSProvider"; public static readonly TWILIO: string = "Twilio"; @@ -39,6 +39,7 @@ export class SMSProviderConstants { public static readonly SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH: number = 0; public static readonly SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH: number = 100; + public static readonly SMS_PROVIDER_CONFIG_TEMPLATE_FIELD_MAX_LENGTH: number = 1020; public static readonly SMS_REGEX: RegExp = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; public static ErrorMessages: { diff --git a/apps/console/src/features/sms-providers/pages/custom-sms-provider.tsx b/apps/console/src/features/sms-providers/pages/custom-sms-provider.tsx index 596af1f8dde..e0793868a22 100644 --- a/apps/console/src/features/sms-providers/pages/custom-sms-provider.tsx +++ b/apps/console/src/features/sms-providers/pages/custom-sms-provider.tsx @@ -118,84 +118,22 @@ const CustomSMSProvider: FunctionComponent = ( - { t("extensions:develop.smsProviders.form.custom.key.hint") } - - ) } - component={ TextFieldAdapter } - maxLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH - } - minLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH - } - autoComplete="new-password" - /> - - - - { t("extensions:develop.smsProviders.form.custom.secret.hint") } - - ) } - component={ TextFieldAdapter } - maxLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH - } - minLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH - } - autoComplete="new-password" - /> - - - - - - { t("extensions:develop.smsProviders.form.custom.sender.hint") } + { t("extensions:develop.smsProviders.form.custom.contentType.hint") } ) } component={ TextFieldAdapter } @@ -210,22 +148,22 @@ const CustomSMSProvider: FunctionComponent = ( - { t("extensions:develop.smsProviders.form.custom.contentType.hint") } + { t("extensions:develop.smsProviders.form.custom.httpMethod.hint") } ) } component={ TextFieldAdapter } @@ -270,36 +208,6 @@ const CustomSMSProvider: FunctionComponent = ( autoComplete="new-password" /> - - - { t("extensions:develop.smsProviders.form.custom.httpMethod.hint") } - - ) } - component={ TextFieldAdapter } - maxLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH - } - minLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH - } - autoComplete="new-password" - /> - @@ -324,7 +232,7 @@ const CustomSMSProvider: FunctionComponent = ( ) } component={ TextFieldAdapter } maxLength={ - SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH + SMSProviderConstants.SMS_PROVIDER_CONFIG_TEMPLATE_FIELD_MAX_LENGTH } minLength={ SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH From 76d400c41a47efa509228c229fb57a835ac672f6 Mon Sep 17 00:00:00 2001 From: JKAUSHALYA Date: Wed, 7 Feb 2024 15:51:27 +0530 Subject: [PATCH 2/2] Add French and Sinhala translations. --- .../src/extensions/i18n/resources/fr-FR/extensions.ts | 6 +++--- .../src/extensions/i18n/resources/si-LK/extensions.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/console/src/extensions/i18n/resources/fr-FR/extensions.ts b/apps/console/src/extensions/i18n/resources/fr-FR/extensions.ts index d3960f86c59..31fa6e4478a 100755 --- a/apps/console/src/extensions/i18n/resources/fr-FR/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/fr-FR/extensions.ts @@ -2226,7 +2226,7 @@ export const extensions: Extensions = { contentType: { label: "Type de contenu", placeholder: "JSON", - hint: "Le type de contenu de la requête API utilisée pour l'envoi du SMS." + hint: "Le type de contenu de la requête API. Les valeurs acceptées sont 'FORM' ou 'JSON'" }, headers: { label: "En-têtes", @@ -2235,8 +2235,8 @@ export const extensions: Extensions = { }, payload: { label: "Charge utile", - placeholder: "Entrez la charge utile", - hint: "Charge utile de la requête API SMS." + placeholder: "{\"content\": {{body}}, \"to\": {{mobile}} }", + hint: "Le modèle de charge utile de la requête API. Utilisez {{body}} pour représenter le corps du SMS généré. Utilisez {{mobile}} pour représenter le numéro de mobile." }, key: { label: "Clé d'authentification du fournisseur SMS", diff --git a/apps/console/src/extensions/i18n/resources/si-LK/extensions.ts b/apps/console/src/extensions/i18n/resources/si-LK/extensions.ts index 8e2577d3e85..8d261e94f2d 100755 --- a/apps/console/src/extensions/i18n/resources/si-LK/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/si-LK/extensions.ts @@ -2164,7 +2164,7 @@ export const extensions: Extensions = { contentType: { label: "අන්තර්ගතයේ වර්ගය", placeholder: "JSON", - hint: "SMS යැවීම සඳහා භාවිතා කරන API ඉල්ලීමේ අන්තර්ගත වර්ගය." + hint: "API ඉල්ලීමේ අන්තර්ගත වර්ගය. පිළිගත් අගයන් 'FORM' හෝ 'JSON' වේ" }, headers: { label: "ශීර්ෂ", @@ -2173,8 +2173,8 @@ export const extensions: Extensions = { }, payload: { label: "ගෙවීම", - placeholder: "ගෙවීම ඇතුළත් කරන්න", - hint: "SMS API ඉල්ලීමේ ගෙවීම." + placeholder: "{\"content\": {{body}}, \"to\": {{mobile}} }", + hint: "API ඉල්ලීමේ ගෙවීමේ අච්චුව. උත්පාදනය කරන ලද SMS අන්තර්ගතය නියෝජනය කිරීමට {{body}} භාවිතා කරන්න. ජංගම දුරකථන අංකය නියෝජනය කිරීමට {{mobile}} භාවිතා කරන්න." }, key: { label: "SMS සපයන්නාගේ සත්‍යාපන යතුර",