Skip to content

Commit

Permalink
Merge pull request wso2#5422 from JKAUSHALYA/GIT-19277
Browse files Browse the repository at this point in the history
Add custom templating to custom SMS provider.
  • Loading branch information
JKAUSHALYA authored Feb 8, 2024
2 parents f502de4 + 76d400c commit 60a2c3a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2194,17 +2194,17 @@ 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",
placeholder: "authorisation: Bearer {{token}}",
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ export const extensions: Extensions = {
contentType: {
label: "අන්තර්ගතයේ වර්ගය",
placeholder: "JSON",
hint: "SMS යැවීම සඳහා භාවිතා කරන API ඉල්ලීමේ අන්තර්ගත වර්ගය."
hint: "API ඉල්ලීමේ අන්තර්ගත වර්ගය. පිළිගත් අගයන් 'FORM' හෝ 'JSON' වේ"
},
headers: {
label: "ශීර්ෂ",
Expand All @@ -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 සපයන්නාගේ සත්‍යාපන යතුර",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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: {
Expand Down
124 changes: 16 additions & 108 deletions apps/console/src/features/sms-providers/pages/custom-sms-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,84 +118,22 @@ const CustomSMSProvider: FunctionComponent<CustomSMSProviderPageInterface> = (
<Grid.Row columns={ 2 }>
<Grid.Column>
<FinalFormField
key="key"
width={ 16 }
FormControlProps={ {
margin: "dense"
} }
ariaLabel="key"
required={ false }
readOnly={ isReadOnly }
data-componentid={ `${componentId}-key` }
name="key"
type="text"
label={ t("extensions:develop.smsProviders.form.custom.key.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.key.placeholder") }
helperText={ (
<Hint compact>
{ t("extensions:develop.smsProviders.form.custom.key.hint") }
</Hint>
) }
component={ TextFieldAdapter }
maxLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH
}
minLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH
}
autoComplete="new-password"
/>
</Grid.Column>
<Grid.Column>
<FinalFormField
key="secret"
fullWidth
FormControlProps={ {
margin: "dense"
} }
ariaLabel="secret"
readOnly={ isReadOnly }
required={ false }
data-componentid={ `${componentId}-secret` }
name="secret"
type="password"
label={ t("extensions:develop.smsProviders.form.custom.secret.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.secret.placeholder") }
helperText={ (
<Hint compact>
{ t("extensions:develop.smsProviders.form.custom.secret.hint") }
</Hint>
) }
component={ TextFieldAdapter }
maxLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH
}
minLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH
}
autoComplete="new-password"
/>
</Grid.Column>
</Grid.Row>
<Grid.Row columns={ 2 }>
<Grid.Column>
<FinalFormField
key="sender"
key="contentType"
fullWidth
FormControlProps={ {
margin: "dense"
} }
ariaLabel="sender"
ariaLabel="contentType"
readOnly={ isReadOnly }
required={ false }
data-componentid={ `${componentId}-sender` }
name="sender"
data-componentid={ `${componentId}-contentType` }
name="contentType"
type="text"
label={ t("extensions:develop.smsProviders.form.custom.sender.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.sender.placeholder") }
label={ t("extensions:develop.smsProviders.form.custom.contentType.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.contentType.placeholder") }
helperText={ (
<Hint compact>
{ t("extensions:develop.smsProviders.form.custom.sender.hint") }
{ t("extensions:develop.smsProviders.form.custom.contentType.hint") }
</Hint>
) }
component={ TextFieldAdapter }
Expand All @@ -210,22 +148,22 @@ const CustomSMSProvider: FunctionComponent<CustomSMSProviderPageInterface> = (
</Grid.Column>
<Grid.Column>
<FinalFormField
key="contentType"
key="httpMethod"
fullWidth
FormControlProps={ {
margin: "dense"
} }
ariaLabel="contentType"
ariaLabel="httpMethod"
readOnly={ isReadOnly }
required={ true }
data-componentid={ `${componentId}-contentType` }
name="contentType"
required={ false }
data-componentid={ `${componentId}-httpMethod` }
name="httpMethod"
type="text"
label={ t("extensions:develop.smsProviders.form.custom.contentType.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.contentType.placeholder") }
label={ t("extensions:develop.smsProviders.form.custom.httpMethod.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.httpMethod.placeholder") }
helperText={ (
<Hint compact>
{ t("extensions:develop.smsProviders.form.custom.contentType.hint") }
{ t("extensions:develop.smsProviders.form.custom.httpMethod.hint") }
</Hint>
) }
component={ TextFieldAdapter }
Expand Down Expand Up @@ -270,36 +208,6 @@ const CustomSMSProvider: FunctionComponent<CustomSMSProviderPageInterface> = (
autoComplete="new-password"
/>
</Grid.Column>
<Grid.Column>
<FinalFormField
key="httpMethod"
fullWidth
FormControlProps={ {
margin: "dense"
} }
ariaLabel="httpMethod"
readOnly={ isReadOnly }
required={ false }
data-componentid={ `${componentId}-httpMethod` }
name="httpMethod"
type="text"
label={ t("extensions:develop.smsProviders.form.custom.httpMethod.label") }
placeholder={ t("extensions:develop.smsProviders.form.custom.httpMethod.placeholder") }
helperText={ (
<Hint compact>
{ t("extensions:develop.smsProviders.form.custom.httpMethod.hint") }
</Hint>
) }
component={ TextFieldAdapter }
maxLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MAX_LENGTH
}
minLength={
SMSProviderConstants.SMS_PROVIDER_CONFIG_FIELD_MIN_LENGTH
}
autoComplete="new-password"
/>
</Grid.Column>
</Grid.Row>
<Grid.Row columns={ 1 }>
<Grid.Column>
Expand All @@ -324,7 +232,7 @@ const CustomSMSProvider: FunctionComponent<CustomSMSProviderPageInterface> = (
) }
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
Expand Down

0 comments on commit 60a2c3a

Please sign in to comment.