Skip to content

Commit cfe9e2e

Browse files
committed
dataExport: show 'Data export requires Business Plan' on 404 for SaaS; add test; keep generic/self-hosted fallback
1 parent 74cdf17 commit cfe9e2e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

static/app/components/dataExport.spec.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,22 @@ describe('DataExport', function () {
160160
expect(addErrorMessage).toHaveBeenCalledWith('uh oh');
161161
});
162162
});
163+
164+
it('shows upgrade message on 404', async function () {
165+
MockApiClient.addMockResponse({
166+
url: `/organizations/${mockAuthorizedOrg.slug}/data-export/`,
167+
method: 'POST',
168+
statusCode: 404,
169+
});
170+
171+
render(<DataExport payload={mockPayload} />, {
172+
...mockContext(mockAuthorizedOrg),
173+
});
174+
175+
await userEvent.click(screen.getByRole('button'));
176+
177+
await waitFor(() => {
178+
expect(addErrorMessage).toHaveBeenCalledWith('Data export requires Business Plan');
179+
});
180+
});
163181
});

static/app/components/dataExport.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicato
55
import Feature from 'sentry/components/acl/feature';
66
import {Button} from 'sentry/components/core/button';
77
import {t} from 'sentry/locale';
8+
import ConfigStore from 'sentry/stores/configStore';
89
import useApi from 'sentry/utils/useApi';
910
import useOrganization from 'sentry/utils/useOrganization';
1011

@@ -70,11 +71,14 @@ export function useDataExport({
7071
if (unmountedRef?.current) {
7172
return;
7273
}
74+
const isSelfHosted = ConfigStore.get('isSelfHosted');
7375
const message =
74-
err?.responseJSON?.detail ??
75-
t(
76-
"We tried our hardest, but we couldn't export your data. Give it another go."
77-
);
76+
err?.status === 404 && !isSelfHosted
77+
? t('Data export requires Business Plan')
78+
: (err?.responseJSON?.detail ??
79+
t(
80+
"We tried our hardest, but we couldn't export your data. Give it another go."
81+
));
7882

7983
addErrorMessage(message);
8084
inProgressCallback?.(false);

0 commit comments

Comments
 (0)