Skip to content

Commit

Permalink
fix(applications): simplify conditional auth looping constructs error…
Browse files Browse the repository at this point in the history
… message (#2554)

* fix(i18n): add translations
* fix(applications): simplify looping constructs error message
  • Loading branch information
yasinmiran authored Oct 5, 2021
1 parent 1e95671 commit 4cad7dd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import { AlertLevels, SBACInterface, TestableComponentInterface } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import { Field, Forms } from "@wso2is/forms";
import { Heading, Hint, LinkButton, PrimaryButton } from "@wso2is/react-components";
import { Code, Heading, Hint, LinkButton, PrimaryButton } from "@wso2is/react-components";
import kebabCase from "lodash-es/kebabCase";
import React, { FunctionComponent, ReactElement, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Trans, useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { Divider, Grid, Icon } from "semantic-ui-react";
import { ScriptBasedFlow } from "./script-based-flow";
Expand Down Expand Up @@ -250,6 +250,30 @@ export const SignInMethodCustomization: FunctionComponent<SignInMethodCustomizat
onUpdate(appId);
})
.catch((error) => {

const DISALLOWED_PROGRAMMING_CONSTRUCTS = "APP-60001";
if (error.response && error.response.data?.code === DISALLOWED_PROGRAMMING_CONSTRUCTS) {
dispatch(addAlert({
description: (
<p>
<Trans
i18nKey={
"console:develop.features.applications.notifications" +
".conditionalScriptLoopingError.description"
}>
Looping constructs such as <Code>for</Code>, <Code>while</Code> and,
<Code>forEach</Code> are not allowed in the conditional authentication
script.
</Trans>
</p>
),
level: AlertLevels.ERROR,
message: t("console:develop.features.applications.notifications" +
".conditionalScriptLoopingError.message")
}));
return;
}

if (error.response && error.response.data && error.response.data.description) {
dispatch(addAlert({
description: error.response.data.description,
Expand Down
1 change: 1 addition & 0 deletions modules/i18n/src/models/namespaces/console-ns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ export interface ConsoleNS {
updateProtocol: Notification;
fetchOIDCServiceEndpoints: Notification;
secondFactorAuthenticatorToFirstStep: Notification;
conditionalScriptLoopingError: NotificationItem;
};
popups: {
appStatus: {
Expand Down
6 changes: 6 additions & 0 deletions modules/i18n/src/translations/en-US/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,12 @@ export const console: ConsoleNS = {
description: "Successfully added new protocol configurations.",
message: "Update successful"
}
},
conditionalScriptLoopingError: {
description: "Looping constructs such as <1>for</1>, <3>while</3>, and" +
" <5>forEach</5> are not allowed in the conditional authentication" +
" script.",
message: "Failed to update the script"
}
},
placeholders: {
Expand Down
5 changes: 5 additions & 0 deletions modules/i18n/src/translations/fr-FR/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2620,6 +2620,11 @@ export const console: ConsoleNS = {
description: "Ajout réussi de nouvelles configurations de protocole.",
message: "Mise à jour réussie"
}
},
conditionalScriptLoopingError: {
description: "Les constructions en boucle telles que <1>for</1>, <3>while</3> et " +
"<5>forEach</5> ne sont pas autorisées dans le script d'authentification conditionnelle.",
message: "Échec de la mise à jour du script"
}
},
placeholders: {
Expand Down
5 changes: 5 additions & 0 deletions modules/i18n/src/translations/si-LK/portals/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,11 @@ export const console: ConsoleNS = {
description: "නව ප්‍රොටොකෝල් වින්‍යාසයන් සාර්ථකව එක් කරන ලදි.",
message: "යාවත්කාලීන කිරීම සාර්ථකයි"
}
},
conditionalScriptLoopingError: {
description: "කොන්දේසි සහිත සත්‍යාපන පිටපත තුළ <1>for</1>, <3>while</3>, සහ <5>forEach</5>" +
" වැනි ලූප් ඉදි කිරීම් වලට ඉඩ නොදේ.",
message: "පිටපත යාවත්කාලීන කිරීමට අසමත් විය"
}
},
placeholders: {
Expand Down

0 comments on commit 4cad7dd

Please sign in to comment.