-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support creating alert in the chat window #217
Open
qianheng-aws
wants to merge
9
commits into
opensearch-project:main
Choose a base branch
from
qianheng-aws:createAlert
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
302123a
Support creating alert in the chat window
qianheng-aws 6f81cd3
Move "create alert" button from assistantDashboard to alertingDashboard
qianheng-aws 958ea97
Address comments and add UTs
qianheng-aws 327b68d
update CHANGELOG.md
qianheng-aws 0fb91ea
Add more UT
qianheng-aws 0b93277
Merge remote-tracking branch 'refs/remotes/origin/main' into createAlert
qianheng-aws 596573f
Merge remote-tracking branch 'refs/remotes/origin/main' into createAlert
qianheng-aws 8be87ff
Merge remote-tracking branch 'refs/remotes/origin/main' into createAlert
qianheng-aws be18261
Merge remote-tracking branch 'refs/remotes/origin/main' into createAlert
qianheng-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,53 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui'; | ||
import React, { useCallback } from 'react'; | ||
import { IChatContext, useChatContext } from '../contexts/chat_context'; | ||
import { TAB_ID } from '../utils/constants'; | ||
import { SidecarIconMenu } from '../components/sidecar_icon_menu'; | ||
|
||
export const ChatOverrideHeader = React.memo(() => { | ||
const chatContext = useChatContext() as IChatContext; | ||
const { setSelectedTabId, setFlyoutComponent, setOverrideName } = chatContext; | ||
|
||
const handleBack = useCallback(() => { | ||
setSelectedTabId(TAB_ID.CHAT); | ||
setFlyoutComponent(null); | ||
setOverrideName(undefined); | ||
}, [setSelectedTabId]); | ||
|
||
return ( | ||
<> | ||
<EuiFlexGroup | ||
gutterSize="s" | ||
justifyContent="spaceAround" | ||
alignItems="center" | ||
responsive={false} | ||
> | ||
<EuiFlexItem> | ||
<EuiFlexGroup gutterSize="none" alignItems="center" responsive={false}> | ||
<EuiButtonEmpty flush="left" size="xs" onClick={handleBack} iconType="arrowLeft"> | ||
{chatContext?.overrideName || 'Back'} | ||
</EuiButtonEmpty> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<SidecarIconMenu /> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonIcon | ||
aria-label="close" | ||
size="xs" | ||
color="text" | ||
iconType="cross" | ||
onClick={() => { | ||
chatContext.setFlyoutVisible(false); | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false} /> | ||
</EuiFlexGroup> | ||
</> | ||
); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import Qs from 'querystring'; | ||
import { | ||
IAdditionalAction, | ||
IMessage, | ||
Interaction, | ||
} from '../../common/types/chat_saved_object_attributes'; | ||
|
||
export const CreateMonitorParserHelper = (interaction: Interaction): IAdditionalAction[] => { | ||
qianheng-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const monitorParameters = | ||
(interaction.additional_info?.['CreateAlertTool.output'] as string[] | null)?.flatMap( | ||
qianheng-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(item: string): {} => { | ||
// @typescript-eslint/no-explicit-any | ||
let parameters: { [key: string]: string } = {}; | ||
try { | ||
const parsedItem = JSON.parse(item); | ||
parameters.name = parsedItem.name; | ||
parameters.index = parsedItem.search.indices; | ||
parameters.timeField = parsedItem.search.timeField; | ||
parameters.bucketValue = parsedItem.search.bucketValue; | ||
parameters.bucketUnitOfTime = parsedItem.search.bucketUnitOfTime; | ||
parameters.filters = JSON.stringify(parsedItem.search.filters); | ||
parameters.aggregations = JSON.stringify(parsedItem.search.aggregations); | ||
parameters.triggers = JSON.stringify(parsedItem.triggers); | ||
} catch (e) { | ||
parameters = {}; | ||
} | ||
|
||
return parameters; | ||
} | ||
) || []; | ||
|
||
if (!monitorParameters.length) return []; | ||
|
||
return [...new Set(monitorParameters)] | ||
qianheng-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.filter((parameters) => parameters) | ||
.map((parameters) => ({ | ||
actionType: 'create_alert_button', | ||
message: 'Create Alert', | ||
content: Qs.stringify(parameters), | ||
})); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this
ChatOverrideHeader
suitable for all override component header? Shall we just hide theChatWindowHeader
and letoverrideComponent
take over the whole screen?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this is a standard header for all override component. As UX required, we should change the title, add a back button and hide the history button. There is a mock up for AD, which also applies to alert.