Skip to content

Commit ea09910

Browse files
committed
feature: added onMessageDismiss event
1 parent 6cc823d commit ea09910

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

example/src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,9 @@ export const createMynahUI = (initialData?: MynahUIDataModel): MynahUI => {
11771177
onInfoLinkClick: (tabId, link, mouseEvent) => {
11781178
Log(`Link inside prompt info field clicked: <b>${link}</b>`);
11791179
},
1180+
onMessageDismiss: (tabId, messageId) => {
1181+
Log(`Card dismissed: tabId: <b>${tabId}</b>, messageId: <b>${messageId}</b>`);
1182+
},
11801183
});
11811184

11821185
setTimeout(() => {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@aws/mynah-ui",
33
"displayName": "AWS Mynah UI",
4-
"version": "4.31.0-beta.3",
4+
"version": "4.31.0-beta.4",
55
"description": "AWS Toolkit VSCode and Intellij IDE Extension Mynah UI",
66
"publisher": "Amazon Web Services",
77
"license": "Apache License 2.0",

src/components/chat-item/chat-item-card.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export class ChatItemCard {
279279
icon: new Icon({ icon: 'cancel' }).render,
280280
onClick: () => {
281281
this.render.remove();
282+
MynahUIGlobalEvents.getInstance().dispatch(MynahEventNames.CARD_DISMISS, { tabId: this.props.tabId, messageId: this.props.chatItem.messageId });
282283
if (this.props.chatItem.messageId !== undefined) {
283284
const currentChatItems: ChatItem[] = MynahUITabsStore.getInstance().getTabDataStore(this.props.tabId).getValue('chatItems');
284285
MynahUITabsStore.getInstance()

src/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ export interface MynahUIProps {
274274
deleted: boolean,
275275
messageId?: string,
276276
eventId?: string) => void;
277+
onMessageDismiss?: (
278+
tabId: string,
279+
messageId: string,
280+
eventId?: string) => void;
277281
onFileActionClick?: (
278282
tabId: string,
279283
messageId: string,
@@ -735,6 +739,13 @@ ${(item.task ? marked.parseInline : marked.parse)(item.text, { breaks: false })
735739
}
736740
});
737741

742+
MynahUIGlobalEvents.getInstance().addListener(MynahEventNames.CARD_DISMISS, (data) => {
743+
this.props.onMessageDismiss?.(
744+
data.tabId,
745+
data.messageId,
746+
this.getUserEventId());
747+
});
748+
738749
MynahUIGlobalEvents.getInstance().addListener(MynahEventNames.FILE_ACTION_CLICK, (data) => {
739750
if (this.props.onFileActionClick !== undefined) {
740751
this.props.onFileActionClick(

src/static.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export enum MynahEventNames {
201201
FORM_TEXTUAL_ITEM_KEYPRESS = 'formTextualItemKeyPress',
202202
FORM_CHANGE = 'formChange',
203203
ADD_ATTACHMENT = 'addAttachment',
204+
CARD_DISMISS = 'cardDismiss',
204205
REMOVE_ATTACHMENT = 'removeAttachment',
205206
TAB_BAR_BUTTON_CLICK = 'tabBarButtonClick',
206207
PROMPT_PROGRESS_ACTION_CLICK = 'promptProgressActionClick',

0 commit comments

Comments
 (0)