@@ -6,6 +6,8 @@ import {Button} from 'sentry/components/core/button';
6
6
import { LinkButton } from 'sentry/components/core/button/linkButton' ;
7
7
import { DateTime } from 'sentry/components/dateTime' ;
8
8
import { KeyValueTable , KeyValueTableRow } from 'sentry/components/keyValueTable' ;
9
+ import LoadingError from 'sentry/components/loadingError' ;
10
+ import LoadingIndicator from 'sentry/components/loadingIndicator' ;
9
11
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle' ;
10
12
import TimeSince from 'sentry/components/timeSince' ;
11
13
import { ActionsProvider } from 'sentry/components/workflowEngine/layout/actions' ;
@@ -16,12 +18,19 @@ import {useWorkflowEngineFeatureGate} from 'sentry/components/workflowEngine/use
16
18
import { IconArrow , IconEdit } from 'sentry/icons' ;
17
19
import { t } from 'sentry/locale' ;
18
20
import { space } from 'sentry/styles/space' ;
21
+ import type { Detector } from 'sentry/types/workflowEngine/detectors' ;
19
22
import getDuration from 'sentry/utils/duration/getDuration' ;
20
23
import useOrganization from 'sentry/utils/useOrganization' ;
24
+ import { useParams } from 'sentry/utils/useParams' ;
25
+ import useProjects from 'sentry/utils/useProjects' ;
21
26
import { ConnectedAutomationsList } from 'sentry/views/detectors/components/connectedAutomationList' ;
22
27
import DetailsPanel from 'sentry/views/detectors/components/detailsPanel' ;
23
28
import IssuesList from 'sentry/views/detectors/components/issuesList' ;
24
- import { makeMonitorBasePathname } from 'sentry/views/detectors/pathnames' ;
29
+ import { useDetector } from 'sentry/views/detectors/hooks' ;
30
+ import {
31
+ makeMonitorBasePathname ,
32
+ makeMonitorDetailsPathname ,
33
+ } from 'sentry/views/detectors/pathnames' ;
25
34
26
35
type Priority = {
27
36
sensitivity : string ;
@@ -33,16 +42,43 @@ const priorities: Priority[] = [
33
42
{ sensitivity : 'high' , threshold : 10 } ,
34
43
] ;
35
44
45
+ function getEnvironmentFromDetector ( detector : Detector ) {
46
+ return detector . dataSources . find ( ds => ds . queryObj . snubaQuery . environment ) ?. queryObj
47
+ . snubaQuery . environment ;
48
+ }
49
+
36
50
export default function DetectorDetail ( ) {
37
51
const organization = useOrganization ( ) ;
38
52
useWorkflowEngineFeatureGate ( { redirect : true } ) ;
53
+ const params = useParams < { detectorId : string } > ( ) ;
54
+ const { projects} = useProjects ( ) ;
55
+
56
+ const {
57
+ data : detector ,
58
+ isPending,
59
+ isError,
60
+ refetch,
61
+ } = useDetector ( {
62
+ // TODO: Remove hardcoded project slug or move to project url
63
+ projectSlug : 'sentry' ,
64
+ detectorId : params . detectorId ,
65
+ } ) ;
66
+ const project = projects . find ( p => p . id === detector ?. projectId ) ;
67
+
68
+ if ( isPending ) {
69
+ return < LoadingIndicator /> ;
70
+ }
71
+
72
+ if ( isError || ! project ) {
73
+ return < LoadingError onRetry = { refetch } /> ;
74
+ }
39
75
40
76
return (
41
- < SentryDocumentTitle title = { '/endpoint' } noSuffix >
77
+ < SentryDocumentTitle title = { detector . name } noSuffix >
42
78
< BreadcrumbsProvider
43
79
crumb = { { label : t ( 'Monitors' ) , to : makeMonitorBasePathname ( organization . slug ) } }
44
80
>
45
- < ActionsProvider actions = { < Actions /> } >
81
+ < ActionsProvider actions = { < Actions detector = { detector } /> } >
46
82
< DetailLayout project = { { slug : 'project-slug' , platform : 'javascript-astro' } } >
47
83
< DetailLayout . Main >
48
84
{ /* TODO: Add chart here */ }
@@ -81,15 +117,17 @@ export default function DetectorDetail() {
81
117
< KeyValueTable >
82
118
< KeyValueTableRow
83
119
keyName = { t ( 'Date created' ) }
84
- value = { < DateTime date = { new Date ( ) } dateOnly year /> }
120
+ value = { < DateTime date = { detector . dateCreated } dateOnly year /> }
85
121
/>
86
- < KeyValueTableRow keyName = { t ( 'Created by' ) } value = "Jane Doe " />
122
+ < KeyValueTableRow keyName = { t ( 'Created by' ) } value = "placeholder " />
87
123
< KeyValueTableRow
88
124
keyName = { t ( 'Last modified' ) }
89
- value = { < TimeSince date = { new Date ( ) } /> }
125
+ value = { < TimeSince date = { detector . dateUpdated } /> }
126
+ />
127
+ < KeyValueTableRow
128
+ keyName = { t ( 'Environment' ) }
129
+ value = { getEnvironmentFromDetector ( detector ) }
90
130
/>
91
- < KeyValueTableRow keyName = { t ( 'Team' ) } value = "Platform" />
92
- < KeyValueTableRow keyName = { t ( 'Environment' ) } value = "prod" />
93
131
</ KeyValueTable >
94
132
</ Section >
95
133
</ DetailLayout . Sidebar >
@@ -100,7 +138,8 @@ export default function DetectorDetail() {
100
138
) ;
101
139
}
102
140
103
- function Actions ( ) {
141
+ function Actions ( { detector} : { detector : Detector } ) {
142
+ const organization = useOrganization ( ) ;
104
143
const disable = ( ) => {
105
144
window . alert ( 'disable' ) ;
106
145
} ;
@@ -109,7 +148,12 @@ function Actions() {
109
148
< Button onClick = { disable } size = "sm" >
110
149
{ t ( 'Disable' ) }
111
150
</ Button >
112
- < LinkButton to = "edit" priority = "primary" icon = { < IconEdit /> } size = "sm" >
151
+ < LinkButton
152
+ to = { `${ makeMonitorDetailsPathname ( organization . slug , detector . id ) } edit/` }
153
+ priority = "primary"
154
+ icon = { < IconEdit /> }
155
+ size = "sm"
156
+ >
113
157
{ t ( 'Edit' ) }
114
158
</ LinkButton >
115
159
</ Fragment >
0 commit comments