Skip to content

fix(export): show 'Data export requires Business Plan' on 404 for SaaS #97546

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {GroupFixture} from 'sentry-fixture/group';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {ProjectFixture} from 'sentry-fixture/project';

import {render, screen} from 'sentry-test/reactTestingLibrary';

import TagExportDropdown from 'sentry/views/issueDetails/groupDistributions/tagExportDropdown';

describe('TagExportDropdown', function () {
const group = GroupFixture();
const project = ProjectFixture();
const orgWithFeature = OrganizationFixture({features: ['discover-query']});
const orgWithoutFeature = OrganizationFixture({features: []});

it('does not render when org lacks discover-query feature', function () {
render(
<TagExportDropdown
organization={orgWithoutFeature}
project={project}
group={group}
tagKey="user"
/>
);

expect(screen.queryByLabelText('Export options')).not.toBeInTheDocument();
});

it('renders when org has discover-query feature', function () {
render(
<TagExportDropdown
organization={orgWithFeature}
project={project}
group={group}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Feature Flag Mismatch in TagExportDropdown Test

The TagExportDropdown test sets the discover-query feature flag on the organization, but the component checks for organizations:discover-query. This mismatch prevents the component from correctly detecting the feature, causing the test that expects the dropdown to render to fail.

Fix in Cursor Fix in Web

tagKey="user"
/>
);

expect(screen.getByLabelText('Export options')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useState} from 'react';

import Feature from 'sentry/components/acl/feature';
import {Button} from 'sentry/components/core/button';
import {ExportQueryType, useDataExport} from 'sentry/components/dataExport';
import {DropdownMenu} from 'sentry/components/dropdownMenu';
Expand Down Expand Up @@ -30,39 +31,41 @@ export default function TagExportDropdown({tagKey, group, organization, project}
});

return (
<DropdownMenu
size="xs"
trigger={triggerProps => (
<Button
{...triggerProps}
borderless
size="xs"
aria-label={t('Export options')}
icon={<IconDownload />}
/>
)}
items={[
{
key: 'export-page',
label: t('Export Page to CSV'),
// TODO(issues): Dropdown menu doesn't support hrefs yet
onAction: () => {
window.open(
`/${organization.slug}/${project.slug}/issues/${group.id}/tags/${tagKey}/export/`,
'_blank'
);
<Feature features="organizations:discover-query" organization={organization}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature is already wrapped with withOrganization so we shouldn't have to pass organization in here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay i believe i updated it. but this will just hide the button right. do we have an example of showing an "upgrade to business" hook?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we have a unified upgrade to business hook since each place that I know of that has this upsell, does it slightly differently

<DropdownMenu
size="xs"
trigger={triggerProps => (
<Button
{...triggerProps}
borderless
size="xs"
aria-label={t('Export options')}
icon={<IconDownload />}
/>
)}
items={[
{
key: 'export-page',
label: t('Export Page to CSV'),
// TODO(issues): Dropdown menu doesn't support hrefs yet
onAction: () => {
window.open(
`/${organization.slug}/${project.slug}/issues/${group.id}/tags/${tagKey}/export/`,
'_blank'
);
},
},
},
{
key: 'export-all',
label: isExportDisabled ? t('Export in progress...') : t('Export All to CSV'),
onAction: () => {
handleDataExport();
setIsExportDisabled(true);
{
key: 'export-all',
label: isExportDisabled ? t('Export in progress...') : t('Export All to CSV'),
onAction: () => {
handleDataExport();
setIsExportDisabled(true);
},
disabled: isExportDisabled,
},
disabled: isExportDisabled,
},
]}
/>
]}
/>
</Feature>
);
}
Loading