-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
resolves #3179 (FR-532)  Improves error handling and visualization in the model service UI by: 1. Adding a new JSON viewer modal component for displaying error details  2. Replacing question mark icons with exclamation icons for error indicators 3. Adding error data visualization for both session and route errors 4. Adding translations for JSON format errors and route errors across all languages
- Loading branch information
Showing
25 changed files
with
212 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useThemeMode } from '../hooks/useThemeMode'; | ||
import BAICodeEditor from './BAICodeEditor'; | ||
import BAIModal, { BAIModalProps } from './BAIModal'; | ||
import Flex from './Flex'; | ||
import { Alert } from 'antd'; | ||
import React, { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface BAIJSONViewerModalProps extends Omit<BAIModalProps, 'children'> { | ||
json?: object | string; | ||
description?: React.ReactNode; | ||
} | ||
|
||
const BAIJSONViewerModal: React.FC<BAIJSONViewerModalProps> = ({ | ||
json, | ||
description, | ||
...modalProps | ||
}) => { | ||
const { t } = useTranslation(); | ||
const { isDarkMode } = useThemeMode(); | ||
|
||
const { formattedJson, hasError } = useMemo(() => { | ||
if (typeof json === 'string') { | ||
try { | ||
return { | ||
formattedJson: JSON.stringify(JSON.parse(json), null, 2), | ||
hasError: false, | ||
}; | ||
} catch (e) { | ||
return { | ||
formattedJson: json, | ||
hasError: true, | ||
}; | ||
} | ||
} | ||
return { | ||
formattedJson: JSON.stringify(json, null, 2), | ||
hasError: false, | ||
}; | ||
}, [json]); | ||
|
||
return ( | ||
<BAIModal footer={null} width={800} {...modalProps}> | ||
<Flex direction="column" align="stretch" gap={'sm'}> | ||
{hasError && ( | ||
<Alert | ||
type="warning" | ||
message={t('general.InvalidJSONFormat')} | ||
showIcon | ||
/> | ||
)} | ||
{description} | ||
<BAICodeEditor | ||
value={formattedJson} | ||
language={'json'} | ||
theme={isDarkMode ? 'dark' : 'light'} | ||
editable={false} | ||
/> | ||
</Flex> | ||
</BAIModal> | ||
); | ||
}; | ||
|
||
export default BAIJSONViewerModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.