Skip to content

Commit

Permalink
Merge pull request #6405 from savindi7/fix-sms-provider-tab-switch
Browse files Browse the repository at this point in the history
Remove duplicate API call and improve tab switching in SMS Providers
  • Loading branch information
savindi7 authored Jun 7, 2024
2 parents 16208c3 + b22b12c commit 38a707f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .changeset/violet-falcons-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.sms-providers.v1": patch
"@wso2is/admin.extensions.v1": patch
---

Remove duplicated API call and improve tab switching in SMS Providers.
6 changes: 6 additions & 0 deletions features/admin.extensions.v1/configs/models/sms-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
* under the License.
*/

import { RequestErrorInterface } from "@wso2is/admin.core.v1/hooks/use-request";
import { SMSProviderAPIResponseInterface } from "@wso2is/admin.sms-providers.v1/models/sms-providers";
import { AxiosError } from "axios";
import { ReactNode } from "react";

interface SmsProviderConfig {
renderAlternativeSmsProviderOptions: (options?: {
existingSMSProviders: string[]
mutateGetSMSProviderConfig: () => void,
originalSMSProviderConfig: SMSProviderAPIResponseInterface[],
smsProviderConfigFetchRequestError: AxiosError<RequestErrorInterface>,
}) => ReactNode
}

Expand Down
1 change: 1 addition & 0 deletions features/admin.extensions.v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@wso2is/admin.provisioning.v1": "^2.20.19",
"@wso2is/admin.roles.v2": "^2.20.19",
"@wso2is/admin.server-configurations.v1": "^2.20.19",
"@wso2is/admin.sms-providers.v1": "^2.20.19",
"@wso2is/admin.tenants.v1": "^2.20.19",
"@wso2is/admin.users.v1": "^2.20.19",
"@wso2is/admin.userstores.v1": "^2.20.19",
Expand Down
16 changes: 8 additions & 8 deletions features/admin.sms-providers.v1/pages/sms-providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import {
FeatureConfigInterface
} from "@wso2is/admin.core.v1";
import { history } from "@wso2is/admin.core.v1/helpers";
import {
useSMSNotificationSenders
}from "@wso2is/admin.extensions.v1/components/identity-providers/api/identity-provider";
import smsProviderConfig from "@wso2is/admin.extensions.v1/configs/sms-provider";
import { IdentityAppsApiException } from "@wso2is/core/exceptions";
import { hasRequiredScopes } from "@wso2is/core/helpers";
Expand Down Expand Up @@ -126,9 +123,6 @@ const SMSProviders: FunctionComponent<SMSProviderPageInterface> = (
mutate: mutateSMSProviderConfig,
error: smsProviderConfigFetchRequestError
} = useSMSProviders();
const {
mutate: mutateNotificationSendersFetchRequest
} = useSMSNotificationSenders();

const [ isLoading, setIsLoading ] = useState(true);
const [ isChoreoSMSOTPProvider, setChoreoSMSOTPProvider ] = useState<boolean>(false);
Expand Down Expand Up @@ -215,6 +209,10 @@ const SMSProviders: FunctionComponent<SMSProviderPageInterface> = (

}, [ originalSMSProviderConfig ]);

const mutateGetSMSProviderConfig = (): void => {
mutateSMSProviderConfig();
};

/**
* Displays the error banner when unable to fetch sms provider configuration.
*/
Expand Down Expand Up @@ -365,7 +363,6 @@ const SMSProviders: FunctionComponent<SMSProviderPageInterface> = (
}).finally(() => {
setIsSubmitting(false);
mutateSMSProviderConfig();
mutateNotificationSendersFetchRequest();
});
};

Expand Down Expand Up @@ -611,7 +608,10 @@ const SMSProviders: FunctionComponent<SMSProviderPageInterface> = (
data-componentid={ "custom-sms-provider" }
/>
{ smsProviderConfig.renderAlternativeSmsProviderOptions({
existingSMSProviders
existingSMSProviders,
mutateGetSMSProviderConfig,
originalSMSProviderConfig,
smsProviderConfigFetchRequestError
}) }
</>
) }
Expand Down
5 changes: 3 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38a707f

Please sign in to comment.