-
Notifications
You must be signed in to change notification settings - Fork 392
Show a specific error when agent creation hits the application limit #10538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@wso2is/admin.agents.v1": patch | ||
| "@wso2is/i18n": patch | ||
|
pavinduLakshan marked this conversation as resolved.
|
||
| "@wso2is/console": patch | ||
| --- | ||
|
|
||
| Show a specific error message when agent creation fails because the organization's application limit has been reached, instead of the generic "Something went wrong" alert. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { AppState } from "@wso2is/admin.core.v1/store"; | |||||
| import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models"; | ||||||
| import { addAlert } from "@wso2is/core/store"; | ||||||
| import { URLUtils } from "@wso2is/core/utils"; | ||||||
| import { AxiosError } from "axios"; | ||||||
| import { | ||||||
| CheckboxFieldAdapter, | ||||||
| CheckboxGroupFieldAdapter, | ||||||
|
|
@@ -44,6 +45,7 @@ import { useDispatch, useSelector } from "react-redux"; | |||||
| import { Dispatch } from "redux"; | ||||||
| import { Divider, Grid, Icon, Message } from "semantic-ui-react"; | ||||||
| import { addAgent, updateAgentApplicationConfiguration } from "../../api/agents"; | ||||||
| import { AGENT_APP_LIMIT_REACHED_SCIM_TYPE } from "../../constants/agents"; | ||||||
| import { AgentScimSchema, AgentType } from "../../models/agents"; | ||||||
| import "./add-agent-wizard.scss"; | ||||||
|
|
||||||
|
|
@@ -168,18 +170,33 @@ const AddAgentWizard: FunctionComponent<AddAgentWizardPropsInterface> = ( | |||||
| setCreationResult(result); | ||||||
| setIsShowingSuccessScreen(true); | ||||||
| setIsSubmitting(false); | ||||||
| } catch (_err: unknown) { | ||||||
| } catch (error: unknown) { | ||||||
| // On error, stay on form with the user's values. | ||||||
| setIsShowingSuccessScreen(false); | ||||||
| setCreationResult(null); | ||||||
| setSubmittedValues(null); | ||||||
| dispatch( | ||||||
| addAlert({ | ||||||
| description: t("agents:wizard.alerts.error.description"), | ||||||
| level: AlertLevels.ERROR, | ||||||
| message: t("agents:wizard.alerts.error.message") | ||||||
| }) | ||||||
| ); | ||||||
|
|
||||||
| const errorResponse: AxiosError<{ scimType?: string }>["response"] = | ||||||
| (error as AxiosError<{ scimType?: string }>)?.response; | ||||||
|
|
||||||
| if (errorResponse?.status === 403 | ||||||
| && errorResponse?.data?.scimType === AGENT_APP_LIMIT_REACHED_SCIM_TYPE) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason why we can't check for the error code instead of checking the scimType, as we have done in other places? checking the scimType for this kind of error looks odd, IMO. identity-apps/features/admin.roles.v2/pages/create-role-wizard.tsx Lines 156 to 157 in 8387948
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agent creation goes through the SCIM2 API ( The role wizard example calls the Roles REST API, which does return a |
||||||
| dispatch( | ||||||
| addAlert({ | ||||||
| description: t("agents:wizard.alerts.limitReached.description"), | ||||||
| level: AlertLevels.ERROR, | ||||||
| message: t("agents:wizard.alerts.limitReached.message") | ||||||
| }) | ||||||
| ); | ||||||
| } else { | ||||||
| dispatch( | ||||||
| addAlert({ | ||||||
| description: t("agents:wizard.alerts.error.description"), | ||||||
| level: AlertLevels.ERROR, | ||||||
| message: t("agents:wizard.alerts.error.message") | ||||||
| }) | ||||||
| ); | ||||||
| } | ||||||
| setIsSubmitting(false); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.