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
17 changes: 16 additions & 1 deletion ui/src/components/yaml/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
PoweroffOutlined,
FullscreenExitOutlined,
FullscreenOutlined,
ReloadOutlined,
} from '@ant-design/icons'
import hljs from 'highlight.js'
import yaml from 'js-yaml'
Expand Down Expand Up @@ -37,6 +38,7 @@ type InterpretStatus =
type IProps = {
data: any
height?: string | number
onRefresh?: () => void
}

const Yaml = (props: IProps) => {
Expand All @@ -47,7 +49,7 @@ const Yaml = (props: IProps) => {
const interpretEndRef = useRef<HTMLDivElement>(null)
const contentRef = useRef<HTMLDivElement>(null)
const observerRef = useRef<MutationObserver | null>(null)
const { data } = props
const { data, onRefresh } = props
const [moduleHeight, setModuleHeight] = useState<number>(500)
const [interpretStatus, setInterpretStatus] =
useState<InterpretStatus>('idle')
Expand All @@ -57,6 +59,10 @@ const Yaml = (props: IProps) => {
const { aiOptions } = useSelector((state: any) => state.globalSlice)
const isAIEnabled = aiOptions?.AIModel && aiOptions?.AIAuthToken

useEffect(() => {
onRefresh?.()
}, [])

useEffect(() => {
const yamlStatusJson = yaml2json(data)
if (yamlRef.current && yamlStatusJson?.data) {
Expand Down Expand Up @@ -297,6 +303,15 @@ const Yaml = (props: IProps) => {
/>
</Tooltip>
)}
{!handle.active && onRefresh && (
<Tooltip title={t('YAML.Refresh')}>
<Button
type="text"
onClick={onRefresh}
icon={<ReloadOutlined />}
/>
</Tooltip>
)}
{!handle.active && (
<Button
type="primary"
Expand Down
3 changes: 2 additions & 1 deletion ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@
"InterpretConnectionError": "Interpretation connection error",
"FailedToStartInterpret": "Failed to start interpretation",
"FailedToInterpret": "Failed to interpret",
"TabName": "YAML"
"TabName": "YAML",
"Refresh": "Refresh"
},
"Yesterday": "Yesterday",
"Collapse": "Collapse",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/insightDetail/cluster/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const ClusterDetail = () => {
}
}
if (currentTab === 'YAML') {
return <Yaml data={yamlData || ''} />
return <Yaml data={yamlData || ''} onRefresh={getClusterDetail} />
}
if (currentTab === 'K8s') {
return (
Expand Down
Loading