From 42a67f44e88492f5ff1567376df307606d134dba Mon Sep 17 00:00:00 2001 From: elliotxx <951376975@qq.com> Date: Tue, 31 Dec 2024 11:47:39 +0800 Subject: [PATCH] refactor(yaml): simplify AI enabled check and improve code formatting (#696) ## What type of PR is this? /kind refactor ## What this PR does / why we need it: This PR simplifies the AI enabled check and improves code formatting in the YAML-related code. Key changes include: - Simplified the logic for checking if AI is enabled, making it more readable and maintainable. - Improved code formatting to adhere to consistent style guidelines, enhancing overall code quality. ## Which issue(s) this PR fixes: Fixes # --- ui/src/components/yaml/index.tsx | 3 ++- ui/src/components/yaml/styles.module.less | 8 ++++++-- .../components/eventAggregator/styles.module.less | 6 +----- .../components/topologyMap/style.module.less | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/src/components/yaml/index.tsx b/ui/src/components/yaml/index.tsx index 6b30b4b2..37937276 100644 --- a/ui/src/components/yaml/index.tsx +++ b/ui/src/components/yaml/index.tsx @@ -44,6 +44,7 @@ const Yaml = (props: IProps) => { const [isStreaming, setStreaming] = useState(false) const abortControllerRef = useRef(null) const { aiOptions } = useSelector((state: any) => state.globalSlice) + const isAIEnabled = aiOptions?.AIModel && aiOptions?.AIAuthToken useEffect(() => { const yamlStatusJson = yaml2json(data) @@ -276,7 +277,7 @@ const Yaml = (props: IProps) => { {t('Copy')} )} - {aiOptions?.AIAuthToken && ( + {isAIEnabled && (