Skip to content

Commit 2142f11

Browse files
committed
✨ Add fields to project settings
1 parent 50953a0 commit 2142f11

File tree

4 files changed

+123
-13
lines changed

4 files changed

+123
-13
lines changed

static/app/components/events/eventTags/eventTagsTreeRow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function EventTagsTreeRowDropdown({
205205
);
206206
}
207207

208-
const TreeRow = styled('div')<{hasErrors: boolean}>`
208+
export const TreeRow = styled('div')<{hasErrors: boolean}>`
209209
border-radius: ${space(0.5)};
210210
padding-left: ${space(1)};
211211
position: relative;
@@ -270,7 +270,7 @@ const TreeValueTrunk = styled('div')`
270270
grid-column-gap: ${space(0.5)};
271271
`;
272272

273-
const TreeValue = styled('div')`
273+
export const TreeValue = styled('div')`
274274
padding: ${space(0.25)} 0;
275275
align-self: start;
276276
font-family: ${p => p.theme.text.familyMono};
@@ -279,7 +279,7 @@ const TreeValue = styled('div')`
279279
grid-column: span 1;
280280
`;
281281

282-
const TreeKey = styled(TreeValue)<{hasErrors: boolean}>`
282+
export const TreeKey = styled(TreeValue)<{hasErrors: boolean}>`
283283
color: ${p => (p.hasErrors ? 'inherit' : p.theme.gray300)};
284284
`;
285285

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,104 @@
1-
import ContextSummary from 'sentry/components/events/contextSummary';
1+
import styled from '@emotion/styled';
2+
3+
import {getOrderedContextItems} from 'sentry/components/events/contexts';
4+
import ContextCard from 'sentry/components/events/contexts/contextCard';
5+
import {EventDataSection} from 'sentry/components/events/eventDataSection';
6+
import {
7+
TreeKey,
8+
TreeRow,
9+
TreeValue,
10+
} from 'sentry/components/events/eventTags/eventTagsTreeRow';
211
import {useHasNewTagsUI} from 'sentry/components/events/eventTags/util';
12+
import {t} from 'sentry/locale';
13+
import {space} from 'sentry/styles/space';
314
import type {Event, Group, Project} from 'sentry/types';
15+
import {useDetailedProject} from 'sentry/utils/useDetailedProject';
16+
import useOrganization from 'sentry/utils/useOrganization';
417

518
interface HighlightsSectionProps {
619
event: Event;
720
group: Group;
821
project: Project;
922
}
1023

11-
export default function HighlightsDataSection({event}: HighlightsSectionProps) {
24+
export default function HighlightsDataSection({
25+
event,
26+
group,
27+
project,
28+
}: HighlightsSectionProps) {
1229
const hasNewTagsUI = useHasNewTagsUI();
13-
if (!hasNewTagsUI) {
30+
const organization = useOrganization();
31+
const {isLoading, data} = useDetailedProject({
32+
orgSlug: organization.slug,
33+
projectSlug: project.slug,
34+
});
35+
36+
if (!hasNewTagsUI || isLoading) {
1437
return null;
1538
}
16-
// TODO(Leander): When a design is confirmed, remove this usage of ContextSummary
17-
return <ContextSummary event={event} />;
39+
40+
const contextMap = getOrderedContextItems(event).reduce((acc, [alias, ctx]) => {
41+
acc[ctx.type] = {value: ctx, alias};
42+
return acc;
43+
}, {});
44+
const contextHighlights = data?.highlightContext ?? [];
45+
46+
const tagMap = event.tags.reduce((tm, {key, value}) => {
47+
tm[key] = value;
48+
return tm;
49+
}, {});
50+
const tagHighlights = data?.highlightTags ?? [];
51+
52+
return (
53+
<EventDataSection
54+
title={t('Highlighted Event Data')}
55+
data-test-id="highlighted-event-data"
56+
type="highlighted-event-data"
57+
>
58+
<HighlightWrapper>
59+
<ContextHighlightSection>
60+
{contextHighlights.map((contextType, i) => (
61+
<ContextCard
62+
key={i}
63+
type={contextType}
64+
alias={contextMap[contextType]?.alias ?? contextType}
65+
value={contextMap[contextType]?.value}
66+
group={group}
67+
event={event}
68+
project={project}
69+
/>
70+
))}
71+
</ContextHighlightSection>
72+
<TagHighlightSection>
73+
{tagHighlights.map((tag, i) => (
74+
<TreeRow hasErrors={false} key={i}>
75+
<TreeKey hasErrors={false}>{tag}</TreeKey>
76+
<TreeValue>{tagMap[tag]}</TreeValue>
77+
</TreeRow>
78+
))}
79+
</TagHighlightSection>
80+
</HighlightWrapper>
81+
</EventDataSection>
82+
);
1883
}
84+
85+
const HighlightWrapper = styled('div')`
86+
margin-bottom: ${space(2)};
87+
display: flex;
88+
gap: ${space(1)};
89+
align-items: start;
90+
/* TODO(Leander): Account for screen width */
91+
`;
92+
93+
const ContextHighlightSection = styled('div')`
94+
flex: 1;
95+
`;
96+
97+
const TagHighlightSection = styled('div')`
98+
flex: 1;
99+
display: grid;
100+
grid-template-columns: minmax(auto, 175px) 1fr;
101+
:nth-child(odd) {
102+
background-color: ${p => p.theme.backgroundSecondary};
103+
}
104+
`;

static/app/data/forms/projectGeneralSettings.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,38 @@ export const fields: Record<string, Field> = {
111111
},
112112
highlightContext: {
113113
name: 'highlightContext',
114-
type: 'string',
114+
type: 'textarea',
115115
multiline: true,
116116
autosize: true,
117117
rows: 1,
118118
placeholder: t('browser, runtime, user, my-context'),
119119
label: t('Highlighted Context'),
120120
help: tct(
121-
'[link:Structured context] to promote to the top of each issue page for quick debugging. Separate entries with a newline.',
121+
'Structured context keys to promote for quick debugging. Click [link:here] for documentation',
122122
{
123123
link: <ExternalLink openInNewTab href={CONTEXT_DOCS_LINK} />,
124124
}
125125
),
126-
getValue: val => extractMultilineFields(val),
127-
setValue: val => convertMultilineFieldValue(val),
126+
getValue: (val: string) => (val === '' ? {} : JSON.parse(val)),
127+
setValue: (val: string) => {
128+
const schema = JSON.stringify(val, null, 2);
129+
if (schema === '{}') {
130+
return '';
131+
}
132+
return schema;
133+
},
134+
validate: ({id, form}) => {
135+
if (!form.schema) {
136+
return [];
137+
}
138+
139+
try {
140+
JSON.parse(form.schema);
141+
} catch (e) {
142+
return [[id, 'Invalid JSON']];
143+
}
144+
return [];
145+
},
128146
},
129147

130148
subjectPrefix: {

static/app/views/settings/projectGeneralSettings/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ class ProjectGeneralSettings extends DeprecatedAsyncView<Props, State> {
302302
},
303303
};
304304

305+
const detailsFields = [fields.name, fields.platform];
306+
if (organization.features.includes('event-tags-tree-ui')) {
307+
detailsFields.push(fields.highlightTags);
308+
detailsFields.push(fields.highlightContext);
309+
}
310+
305311
return (
306312
<div>
307313
<SettingsPageHeader title={t('Project Settings')} />
@@ -311,7 +317,7 @@ class ProjectGeneralSettings extends DeprecatedAsyncView<Props, State> {
311317
<JsonForm
312318
{...jsonFormProps}
313319
title={t('Project Details')}
314-
fields={[fields.name, fields.platform]}
320+
fields={detailsFields}
315321
/>
316322

317323
<JsonForm

0 commit comments

Comments
 (0)