Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 20 additions & 4 deletions static/app/views/issueDetails/groupTags/groupTagsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Group} from 'sentry/types/group';
import {trackAnalytics} from 'sentry/utils/analytics';
import {useDetailedProject} from 'sentry/utils/useDetailedProject';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {useParams} from 'sentry/utils/useParams';
Expand Down Expand Up @@ -67,6 +68,15 @@ export function GroupTagsDrawer({group}: {group: Group}) {
environment: environments,
});

const {data: detailedProject, isPending: isHighlightsPending} = useDetailedProject({
orgSlug: organization.slug,
projectSlug: project.slug,
});

const highlightTagKeys = useMemo(() => {
return detailedProject?.highlightTags ?? project?.highlightTags ?? [];
}, [detailedProject, project]);

const tagValues = useMemo(
() =>
data.reduce((valueMap, tag) => {
Expand All @@ -78,18 +88,24 @@ export function GroupTagsDrawer({group}: {group: Group}) {
);

const displayTags = useMemo(() => {
const sortedTags = data.sort((a, b) => a.key.localeCompare(b.key));
const searchedTags = sortedTags.filter(
const highlightTags = data.filter(tag => highlightTagKeys.includes(tag.key));
const orderedHighlightTags = highlightTags.sort(
(a, b) => highlightTagKeys.indexOf(a.key) - highlightTagKeys.indexOf(b.key)
);
const remainingTags = data.filter(tag => !highlightTagKeys.includes(tag.key));
const sortedTags = remainingTags.sort((a, b) => a.key.localeCompare(b.key));
const orderedTags = [...orderedHighlightTags, ...sortedTags];
const searchedTags = orderedTags.filter(
tag =>
tag.key.includes(search) ||
tag.name.includes(search) ||
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
tagValues[tag.key].includes(search)
);
return searchedTags;
}, [data, search, tagValues]);
}, [data, search, tagValues, highlightTagKeys]);

if (isPending) {
if (isPending || isHighlightsPending) {
return <LoadingIndicator />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ describe('EventDetailsHeader', () => {
new Set(['environments'])
);
ProjectsStore.loadInitialData([project]);
MockApiClient.addMockResponse({
url: '/projects/org-slug/project-slug/',
body: [project],
});
MockApiClient.addMockResponse({
url: `/organizations/${organization.slug}/events-stats/`,
body: {'count()': EventsStatsFixture(), 'count_unique(user)': EventsStatsFixture()},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('EventGraph', () => {
url: `/organizations/${organization.slug}/releases/stats/`,
body: [],
});
MockApiClient.addMockResponse({
url: '/projects/org-slug/project-slug/',
body: [project],
});
PageFiltersStore.init();
PageFiltersStore.onInitializeUrlState(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ describe('GroupDetailsLayout', () => {
githubWriteIntegration: {ok: true},
},
});
MockApiClient.addMockResponse({
url: '/projects/org-slug/project-slug/',
body: [project],
});
});

it('renders children, can collapse sidebar', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import {GroupFixture} from 'sentry-fixture/group';
import {ProjectFixture} from 'sentry-fixture/project';
import {TagsFixture} from 'sentry-fixture/tags';

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

import IssueTagsPreview from './issueTagsPreview';

describe('IssueTagsPreview', () => {
beforeEach(() => {
MockApiClient.addMockResponse({
url: '/projects/org-slug/project-slug/',
body: [ProjectFixture()],
});
});
it('renders preview tags', async () => {
const group = GroupFixture();
MockApiClient.addMockResponse({
Expand Down
28 changes: 24 additions & 4 deletions static/app/views/issueDetails/streamline/issueTagsPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {space} from 'sentry/styles/space';
import type {Project} from 'sentry/types/project';
import {percent} from 'sentry/utils';
import {isMobilePlatform} from 'sentry/utils/platform';
import {useDetailedProject} from 'sentry/utils/useDetailedProject';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {formatVersion} from 'sentry/utils/versions/formatVersion';
import type {GroupTag} from 'sentry/views/issueDetails/groupTags/useGroupTags';
import {useGroupTagsReadable} from 'sentry/views/issueDetails/groupTags/useGroupTags';
Expand Down Expand Up @@ -199,6 +201,19 @@ export default function IssueTagsPreview({
project: Project;
}) {
const searchQuery = useEventQuery({groupId});
const organization = useOrganization();

const {data: detailedProject, isPending: isHighlightPending} = useDetailedProject({
orgSlug: organization.slug,
projectSlug: project.slug,
});

const highlightTagKeys = useMemo(() => {
const tagKeys = detailedProject?.highlightTags ?? project?.highlightTags ?? [];
const highlightDefaults =
detailedProject?.highlightPreset?.tags ?? project?.highlightPreset?.tags ?? [];
return tagKeys.filter(tag => !highlightDefaults.includes(tag));
}, [detailedProject, project]);

const {
isError,
Expand All @@ -213,6 +228,10 @@ export default function IssueTagsPreview({
return [];
}

const highlightTags = tags
.filter(tag => highlightTagKeys.includes(tag.key))
.sort((a, b) => highlightTagKeys.indexOf(a.key) - highlightTagKeys.indexOf(b.key));

const priorityTags = isMobilePlatform(project?.platform)
? MOBILE_TAGS
: frontend.some(val => val === project?.platform)
Expand All @@ -226,11 +245,12 @@ export default function IssueTagsPreview({
.sort((a, b) => priorityTags.indexOf(a.key) - priorityTags.indexOf(b.key));

const remainingTagKeys = tags.filter(tag => !priorityTags.includes(tag.key)).sort();
const orderedTags = [...sortedTags, ...remainingTagKeys];
return orderedTags.slice(0, 4);
}, [tags, project?.platform]);
const orderedTags = [...highlightTags, ...sortedTags, ...remainingTagKeys];
Copy link
Member

Choose a reason for hiding this comment

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

i'm not totally in love with this but we can try it

const uniqueTags = [...new Set(orderedTags)];
Copy link
Member

Choose a reason for hiding this comment

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

i forgot that sets were insertion ordered so thanks for that

return uniqueTags.slice(0, 4);
}, [tags, project?.platform, highlightTagKeys]);

if (isPending) {
if (isPending || isHighlightPending) {
return (
<IssueTagPreviewSection>
<Placeholder width="240px" height="100px" />
Expand Down
Loading