Skip to content

Commit a247a21

Browse files
authored
chore(issue-details): Update streamline util to better support enforcing new experience (#87336)
we previously defaulted to "false" in the backend, but that doesn't allow us to properly show the experience to users with the "enforced" flag. now, we will be able to see if a user has the option defined or not, and show them the correct experience based off that.
1 parent 45522de commit a247a21

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

static/app/types/user.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface User extends Omit<AvatarUser, 'options'> {
5353
clock24Hours: boolean;
5454
defaultIssueEvent: 'recommended' | 'latest' | 'oldest';
5555
language: string;
56-
prefersIssueDetailsStreamlinedUI: boolean;
56+
prefersIssueDetailsStreamlinedUI: boolean | null;
5757
prefersSpecializedProjectOverview: {[projectId: string]: boolean};
5858
prefersStackedNavigation: boolean;
5959
quickStartDisplay: QuickStartDisplay;

static/app/views/issueDetails/groupEventAttachments/groupEventAttachments.spec.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ import {EventAttachmentFixture} from 'sentry-fixture/eventAttachment';
33
import {GroupFixture} from 'sentry-fixture/group';
44
import {ProjectFixture} from 'sentry-fixture/project';
55
import {TagsFixture} from 'sentry-fixture/tags';
6+
import {UserFixture} from 'sentry-fixture/user';
67

78
import {initializeOrg} from 'sentry-test/initializeOrg';
89
import {
10+
act,
911
render,
1012
renderGlobalModal,
1113
screen,
1214
userEvent,
1315
within,
1416
} from 'sentry-test/reactTestingLibrary';
1517

18+
import ConfigStore from 'sentry/stores/configStore';
1619
import GroupStore from 'sentry/stores/groupStore';
1720
import ModalStore from 'sentry/stores/modalStore';
1821
import ProjectsStore from 'sentry/stores/projectsStore';
@@ -150,6 +153,11 @@ describe('GroupEventAttachments', function () {
150153
});
151154

152155
it('filters by date/query when using Streamlined UI', function () {
156+
ConfigStore.init();
157+
const user = UserFixture();
158+
user.options.prefersIssueDetailsStreamlinedUI = true;
159+
act(() => ConfigStore.set('user', user));
160+
153161
render(<GroupEventAttachments project={project} group={group} />, {
154162
disableRouterMocks: true,
155163
initialRouterConfig: {

static/app/views/issueDetails/utils.spec.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,38 @@ describe('useHasStreamlinedUI', () => {
6767
expect(prefersStreamlineButQueryParamDisabled.current).toBe(false);
6868
});
6969

70-
it('ignores preferences if enforce flag is set', () => {
70+
it('ignores preferences if enforce flag is set and user has not opted out', () => {
7171
const enforceOrg = OrganizationFixture({
7272
features: ['issue-details-streamline-enforce'],
7373
});
7474
jest.mocked(useOrganization).mockReturnValue(enforceOrg);
7575

7676
ConfigStore.init();
7777
const user = UserFixture();
78-
user.options.prefersIssueDetailsStreamlinedUI = false;
78+
user.options.prefersIssueDetailsStreamlinedUI = null;
7979
act(() => ConfigStore.set('user', user));
8080

8181
jest.mocked(useLocation).mockReturnValue(LocationFixture());
8282
const {result} = renderHook(useHasStreamlinedUI);
8383
expect(result.current).toBe(true);
8484
});
8585

86+
it('respects preferences if enforce flag is set and user has opted out', () => {
87+
const enforceOrg = OrganizationFixture({
88+
features: ['issue-details-streamline-enforce'],
89+
});
90+
jest.mocked(useOrganization).mockReturnValue(enforceOrg);
91+
92+
ConfigStore.init();
93+
const user = UserFixture();
94+
user.options.prefersIssueDetailsStreamlinedUI = false;
95+
act(() => ConfigStore.set('user', user));
96+
97+
jest.mocked(useLocation).mockReturnValue(LocationFixture());
98+
const {result} = renderHook(useHasStreamlinedUI);
99+
expect(result.current).toBe(false);
100+
});
101+
86102
it('ignores preferences if organization option is set to true', () => {
87103
jest.mocked(useLocation).mockReturnValue(LocationFixture());
88104

static/app/views/issueDetails/utils.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export function useHasStreamlinedUI() {
274274
const location = useLocation();
275275
const user = useUser();
276276
const organization = useOrganization();
277+
const userStreamlinedUIOption = user?.options?.prefersIssueDetailsStreamlinedUI;
277278

278279
// Allow query param to override all other settings to set the UI.
279280
if (defined(location.query.streamline)) {
@@ -286,12 +287,15 @@ export function useHasStreamlinedUI() {
286287
}
287288

288289
// If the enforce flag is set for the organization, ignore user preferences and enable the UI
289-
if (organization.features.includes('issue-details-streamline-enforce')) {
290+
if (
291+
userStreamlinedUIOption !== false &&
292+
organization.features.includes('issue-details-streamline-enforce')
293+
) {
290294
return true;
291295
}
292296

293297
// Apply the UI based on user preferences
294-
return !!user?.options?.prefersIssueDetailsStreamlinedUI;
298+
return userStreamlinedUIOption ?? false;
295299
}
296300

297301
export function useIsSampleEvent(): boolean {

0 commit comments

Comments
 (0)