Skip to content

Commit 9a6d892

Browse files
use fetchMutation
1 parent 2481d75 commit 9a6d892

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

static/gsAdmin/components/toggleConsolePlatformsModal.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import FieldFromConfig from 'sentry/components/forms/fieldFromConfig';
1313
import Form from 'sentry/components/forms/form';
1414
import {space} from 'sentry/styles/space';
1515
import type {Organization} from 'sentry/types/organization';
16-
import {useMutation} from 'sentry/utils/queryClient';
17-
import useApi from 'sentry/utils/useApi';
16+
import {fetchMutation, useMutation} from 'sentry/utils/queryClient';
1817

1918
interface ToggleConsolePlatformsModalProps extends ModalRenderProps {
19+
onSuccess: () => void;
2020
organization: Organization;
2121
}
2222

@@ -25,14 +25,15 @@ export function ToggleConsolePlatformsModal({
2525
Body,
2626
closeModal,
2727
organization,
28+
onSuccess,
2829
}: ToggleConsolePlatformsModalProps) {
29-
const api = useApi();
3030
const {enabledConsolePlatforms = []} = organization;
3131

3232
const {isPending, mutate: updateConsolePlatforms} = useMutation({
3333
mutationFn: (platforms: Record<string, boolean>) => {
34-
return api.requestPromise(`/organizations/${organization.slug}/`, {
34+
return fetchMutation({
3535
method: 'PUT',
36+
url: `/organizations/${organization.slug}/`,
3637
data: {
3738
enabledConsolePlatforms: Object.keys(platforms).reduce((acc, key) => {
3839
if (platforms[key]) {
@@ -48,6 +49,7 @@ export function ToggleConsolePlatformsModal({
4849
},
4950
onSuccess: () => {
5051
addSuccessMessage(`Console platforms updated for ${organization.slug}`);
52+
onSuccess();
5153
},
5254
onError: () => {
5355
addErrorMessage(`Failed to update console platforms for ${organization.slug}`);
@@ -131,10 +133,16 @@ const StyledFieldFromConfig = styled(FieldFromConfig)`
131133

132134
export function openToggleConsolePlatformsModal({
133135
organization,
136+
onSuccess,
134137
}: {
138+
onSuccess: () => void;
135139
organization: Organization;
136140
}) {
137141
return openModal(deps => (
138-
<ToggleConsolePlatformsModal {...deps} organization={organization} />
142+
<ToggleConsolePlatformsModal
143+
{...deps}
144+
organization={organization}
145+
onSuccess={onSuccess}
146+
/>
139147
));
140148
}

static/gsAdmin/views/customerDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ export default function CustomerDetails() {
810810
help: 'Enable or disable a console platform for this organization.',
811811
skipConfirmModal: true,
812812
onAction: () => {
813-
openToggleConsolePlatformsModal({organization});
813+
openToggleConsolePlatformsModal({organization, onSuccess: reloadData});
814814
},
815815
},
816816
]}

0 commit comments

Comments
 (0)