-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathcontinuousProfileHeader.tsx
More file actions
105 lines (93 loc) · 3.44 KB
/
continuousProfileHeader.tsx
File metadata and controls
105 lines (93 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import {Fragment, useCallback, useMemo} from 'react';
import styled from '@emotion/styled';
import {LinkButton} from '@sentry/scraps/button';
import {FeedbackButton} from 'sentry/components/feedbackButton/feedbackButton';
import * as Layout from 'sentry/components/layouts/thirds';
import type {ProfilingBreadcrumbsProps} from 'sentry/components/profiling/profilingBreadcrumbs';
import {ProfilingBreadcrumbs} from 'sentry/components/profiling/profilingBreadcrumbs';
import {t} from 'sentry/locale';
import type {Event} from 'sentry/types/event';
import {trackAnalytics} from 'sentry/utils/analytics';
import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
import {useLocation} from 'sentry/utils/useLocation';
import {useOrganization} from 'sentry/utils/useOrganization';
import {TopBar} from 'sentry/views/navigation/topBar';
import {useHasPageFrameFeature} from 'sentry/views/navigation/useHasPageFrameFeature';
interface ContinuousProfileHeader {
transaction: Event | null;
}
export function ContinuousProfileHeader({transaction}: ContinuousProfileHeader) {
const location = useLocation();
const organization = useOrganization();
const hasPageFrameFeature = useHasPageFrameFeature();
// @TODO add breadcrumbs when other views are implemented
const breadCrumbs = useMemo((): ProfilingBreadcrumbsProps['trails'] => {
return [{type: 'landing', payload: {query: {}}}];
}, []);
const transactionTarget = transaction?.id
? generateLinkToEventInTraceView({
timestamp: transaction.endTimestamp ?? '',
eventId: transaction.id,
traceSlug: transaction.contexts?.trace?.trace_id ?? '',
location,
organization,
})
: null;
const handleGoToTransaction = useCallback(() => {
trackAnalytics('profiling_views.go_to_transaction', {
organization,
});
}, [organization]);
return (
<SmallerLayoutHeader>
<SmallerHeaderContent>
<SmallerProfilingBreadcrumbsWrapper>
<ProfilingBreadcrumbs organization={organization} trails={breadCrumbs} />
</SmallerProfilingBreadcrumbsWrapper>
</SmallerHeaderContent>
{hasPageFrameFeature ? (
<Fragment>
{transactionTarget && (
<TopBar.Slot name="actions">
<LinkButton
size="sm"
onClick={handleGoToTransaction}
to={transactionTarget}
>
{t('Go to Trace')}
</LinkButton>
</TopBar.Slot>
)}
<TopBar.Slot name="feedback">
<FeedbackButton>{null}</FeedbackButton>
</TopBar.Slot>
</Fragment>
) : (
<StyledHeaderActions>
<FeedbackButton />
{transactionTarget && (
<LinkButton size="sm" onClick={handleGoToTransaction} to={transactionTarget}>
{t('Go to Trace')}
</LinkButton>
)}
</StyledHeaderActions>
)}
</SmallerLayoutHeader>
);
}
const StyledHeaderActions = styled(Layout.HeaderActions)`
display: flex;
flex-direction: row;
gap: ${p => p.theme.space.md};
`;
const SmallerHeaderContent = styled(Layout.HeaderContent)`
margin-bottom: ${p => p.theme.space.lg};
`;
const SmallerProfilingBreadcrumbsWrapper = styled('div')`
nav {
padding-bottom: ${p => p.theme.space.md};
}
`;
const SmallerLayoutHeader = styled(Layout.Header)`
padding: ${p => p.theme.space.md} ${p => p.theme.space.xl} 0 ${p => p.theme.space.xl} !important;
`;