1
1
import React , { useState } from "react" ;
2
+ import { Tooltip } from "antd" ;
2
3
import PresidioDetectedEntities from "./PresidioDetectedEntities" ;
3
4
import BedrockGuardrailDetails , {
4
5
BedrockGuardrailResponse ,
5
- } from "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails"
6
+ } from "@/components/view_logs/GuardrailViewer/BedrockGuardrailDetails" ;
6
7
7
8
interface RecognitionMetadata {
8
9
recognizer_name : string ;
@@ -44,9 +45,13 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
44
45
// Default to presidio for backwards compatibility
45
46
const guardrailProvider = data . guardrail_provider ?? "presidio" ;
46
47
47
- if ( ! data ) {
48
- return null ;
49
- }
48
+ if ( ! data ) return null ;
49
+
50
+ const isSuccess =
51
+ typeof data . guardrail_status === "string" &&
52
+ data . guardrail_status . toLowerCase ( ) === "success" ;
53
+
54
+ const tooltipTitle = isSuccess ? null : "Guardrail failed to run." ;
50
55
51
56
// Calculate total masked entities
52
57
const totalMaskedEntities = data . masked_entity_count ?
@@ -73,13 +78,18 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
73
78
< path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M9 5l7 7-7 7" />
74
79
</ svg >
75
80
< h3 className = "text-lg font-medium" > Guardrail Information</ h3 >
76
- < span className = { `ml-3 px-2 py-1 rounded-md text-xs font-medium inline-block ${
77
- data . guardrail_status === "success"
78
- ? 'bg-green-100 text-green-800'
79
- : 'bg-red-100 text-red-800'
80
- } `} >
81
- { data . guardrail_status }
82
- </ span >
81
+
82
+ { /* Header status chip with tooltip */ }
83
+ < Tooltip title = { tooltipTitle } placement = "top" arrow destroyTooltipOnHide >
84
+ < span
85
+ className = { `ml-3 px-2 py-1 rounded-md text-xs font-medium inline-block ${
86
+ isSuccess ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800 cursor-help"
87
+ } `}
88
+ >
89
+ { data . guardrail_status }
90
+ </ span >
91
+ </ Tooltip >
92
+
83
93
{ totalMaskedEntities > 0 && (
84
94
< span className = "ml-3 px-2 py-1 bg-blue-50 text-blue-700 rounded-md text-xs font-medium" >
85
95
{ totalMaskedEntities } masked { totalMaskedEntities === 1 ? 'entity' : 'entities' }
@@ -104,15 +114,18 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
104
114
</ div >
105
115
< div className = "flex" >
106
116
< span className = "font-medium w-1/3" > Status:</ span >
107
- < span className = { `px-2 py-1 rounded-md text-xs font-medium inline-block ${
108
- data . guardrail_status === "success"
109
- ? 'bg-green-100 text-green-800'
110
- : 'bg-red-100 text-red-800'
111
- } `} >
112
- { data . guardrail_status }
113
- </ span >
117
+ < Tooltip title = { tooltipTitle } placement = "top" arrow destroyTooltipOnHide >
118
+ < span
119
+ className = { `px-2 py-1 rounded-md text-xs font-medium inline-block ${
120
+ isSuccess ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800 cursor-help"
121
+ } `}
122
+ >
123
+ { data . guardrail_status }
124
+ </ span >
125
+ </ Tooltip >
114
126
</ div >
115
127
</ div >
128
+
116
129
< div className = "space-y-2" >
117
130
< div className = "flex" >
118
131
< span className = "font-medium w-1/3" > Start Time:</ span >
@@ -158,6 +171,6 @@ const GuardrailViewer = ({ data }: GuardrailViewerProps) => {
158
171
) }
159
172
</ div >
160
173
) ;
161
- }
174
+ } ;
162
175
163
- export default GuardrailViewer ;
176
+ export default GuardrailViewer ;
0 commit comments