forked from TencentBlueKing/bk-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 新版api错误信息展示 --Story=119271711 (TencentBlueKing#2603)
# Reviewed, transaction id: 15962
- Loading branch information
1 parent
ee84255
commit 288a8b5
Showing
11 changed files
with
175 additions
and
77 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
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
67 changes: 67 additions & 0 deletions
67
bkmonitor/webpack/src/monitor-pc/common/transform-message-props.ts
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,67 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available. | ||
* | ||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License. | ||
* | ||
* License for 蓝鲸智云PaaS平台 (BlueKing PaaS): | ||
* | ||
* --------------------------------------------------- | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
* the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
const MESSAGE_FIELD = 'popup_message'; | ||
const MESSAGE_THEME_LIST = ['error', 'warning']; | ||
/** | ||
* | ||
* @param props { theme: string, message: Record<string, any>} | Record<string, any> | ||
* @returns Record<string, any> | ||
*/ | ||
export const transformMessageProps = (params: Record<string, any>) => { | ||
let props = params; | ||
if (!props || typeof props !== 'object') return props; | ||
if (MESSAGE_FIELD in props) { | ||
props = { | ||
message: props, | ||
}; | ||
} | ||
if (props.message && typeof props.message !== 'string' && MESSAGE_FIELD in props.message) { | ||
return { | ||
actions: [ | ||
{ | ||
id: 'assistant', | ||
disabled: !props.message.assistant, | ||
}, | ||
{ | ||
id: 'details', | ||
disabled: false, | ||
}, | ||
], | ||
message: { | ||
code: props.message.exc_code || props.message.code, | ||
overview: props.message.overview || props.message.overview, | ||
suggestion: props.message.suggestion || '', | ||
type: 'json', | ||
details: JSON.stringify({ ...props.message }), | ||
assistant: props.message.assistant || undefined, | ||
}, | ||
theme: MESSAGE_THEME_LIST.includes(props.message.popup_message) ? props.message.popup_message : 'error', | ||
ellipsisLine: 2, | ||
ellipsisCopy: true, | ||
}; | ||
} | ||
return props; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available. | ||
* | ||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License. | ||
* | ||
* License for 蓝鲸智云PaaS平台 (BlueKing PaaS): | ||
* | ||
* --------------------------------------------------- | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
* the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO | ||
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
import { Message } from 'bkui-vue'; | ||
import { transformMessageProps } from 'monitor-pc/common/transform-message-props'; | ||
export const bkUiMessage = (params: Record<string, any>) => { | ||
const props = transformMessageProps(params); | ||
return Message(props); | ||
}; |
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