Skip to content

Commit

Permalink
Merge branch 'master' into rjo100/migrate-invalid-slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjo100 committed Jul 7, 2023
2 parents 22a5241 + ac2803b commit 509fe02
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
13 changes: 10 additions & 3 deletions static/app/views/issueList/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {normalizeUrl} from 'sentry/utils/withDomainRequired';
import IssueListSetAsDefault from 'sentry/views/issueList/issueListSetAsDefault';

import {
CUSTOM_TAB_VALUE,
FOR_REVIEW_QUERIES,
getTabs,
IssueSortOptions,
Expand Down Expand Up @@ -91,6 +92,7 @@ function IssueListHeader({
const visibleTabs = displayReprocessingTab
? tabs
: tabs.filter(([tab]) => tab !== Query.REPROCESSING);
const tabValues = new Set(visibleTabs.map(([val]) => val));
// Remove cursor and page when switching tabs
const {cursor: _, page: __, ...queryParms} = router?.location?.query ?? {};
const sortParam =
Expand Down Expand Up @@ -130,11 +132,11 @@ function IssueListHeader({
</ButtonBar>
</Layout.HeaderActions>
<StyledGlobalEventProcessingAlert projects={selectedProjects} />
<StyledTabs selectedKey={query} onSelectionChange={() => {}}>
<StyledTabs value={tabValues.has(query) ? query : CUSTOM_TAB_VALUE}>
<TabList hideBorder>
{[
...visibleTabs.map(
([tabQuery, {name: queryName, tooltipTitle, tooltipHoverable}]) => {
([tabQuery, {name: queryName, tooltipTitle, tooltipHoverable, hidden}]) => {
const to = normalizeUrl({
query: {
...queryParms,
Expand All @@ -147,7 +149,12 @@ function IssueListHeader({
});

return (
<TabList.Item key={tabQuery} to={to} textValue={queryName}>
<TabList.Item
key={tabQuery}
to={to}
textValue={queryName}
hidden={hidden}
>
<GuideAnchor
disabled={tabQuery !== Query.ARCHIVED}
target="issue_stream_archive_tab"
Expand Down
13 changes: 11 additions & 2 deletions static/app/views/issueList/utils.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ describe('getTabs', () => {
getTabs(TestStubs.Organization({features: ['escalating-issues']})).map(
tab => tab[1].name
)
).toEqual(['Unresolved', 'For Review', 'Regressed', 'Escalating', 'Archived']);
).toEqual([
'Unresolved',
'For Review',
'Regressed',
'Escalating',
'Archived',
'Custom',
]);

expect(
getTabs(TestStubs.Organization({features: []})).map(tab => tab[1].name)
).toEqual(['All Unresolved', 'For Review', 'Ignored']);
).toEqual(['All Unresolved', 'For Review', 'Ignored', 'Custom']);
});

it('should enable/disable my_teams filter in For Review tab', () => {
Expand All @@ -20,12 +27,14 @@ describe('getTabs', () => {
'is:unresolved',
'is:unresolved is:for_review assigned_or_suggested:[me, my_teams, none]',
'is:ignored',
'__custom__',
]);

expect(getTabs(TestStubs.Organization({features: []})).map(tab => tab[0])).toEqual([
'is:unresolved',
'is:unresolved is:for_review assigned_or_suggested:[me, none]',
'is:ignored',
'__custom__',
]);
});
});
16 changes: 16 additions & 0 deletions static/app/views/issueList/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export enum Query {
REPROCESSING = 'is:reprocessing',
}

export const CUSTOM_TAB_VALUE = '__custom__';

type OverviewTab = {
/**
* Emitted analytics event tab name
Expand All @@ -29,6 +31,7 @@ type OverviewTab = {
*/
enabled: boolean;
name: string;
hidden?: boolean;
/**
* Tooltip text to be hoverable when text has links
*/
Expand Down Expand Up @@ -128,6 +131,19 @@ export function getTabs(organization: Organization) {
tooltipHoverable: true,
},
],
[
// Hidden tab to account for custom queries that don't match any of the queries
// above. It's necessary because if Tabs's value doesn't match that of any tab item
// then Tabs will fall back to a default value, causing unexpected behaviors.
CUSTOM_TAB_VALUE,
{
name: t('Custom'),
analyticsName: 'custom',
hidden: true,
count: false,
enabled: true,
},
],
];

return tabs.filter(([_query, tab]) => tab.enabled);
Expand Down

0 comments on commit 509fe02

Please sign in to comment.