Skip to content

Commit cd411f2

Browse files
committed
msg: working-completely;
achieves all the functionalities needed might need testing and use set for storing files needs more styling, refer previous versions
1 parent cd11065 commit cd411f2

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ export class ChatWrapper {
398398
const size = Object.keys(this.allRenderedModifiedFileChatItems).length;
399399
chatItem.title = size === 1 ? '1 file modified!' : `${size} files modified!`;
400400
}
401-
// else clear the component and render empty
402-
// previous implementation was not working; Need a fix
403401
this.modifiedFilesTracker.addChatItem(chatItem);
404402
return;
405403
}

src/components/modified-files-tracker.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,34 @@ export class ModifiedFilesTracker {
166166
return messageId.startsWith('modified-files-') ? messageId.replace('modified-files-', '') : messageId;
167167
}
168168

169+
private renderUndoAllButton (chatItem: ChatItem): void {
170+
let undoAllMessageId: String;
171+
const contentWrapper = this.collapsibleContent.render.querySelector('.mynah-collapsible-content-label-content-wrapper');
172+
if (contentWrapper == null || chatItem.buttons == null) return;
173+
174+
if (chatItem.messageId !== undefined && chatItem.messageId !== null && chatItem.messageId !== '') {
175+
undoAllMessageId = this.getOriginalMessageId(chatItem.messageId);
176+
} else {
177+
return;
178+
}
179+
180+
const buttonsWrapper = new ChatItemButtonsWrapper({
181+
tabId: this.props.tabId,
182+
classNames: [ 'mynah-modified-files-undo-all-buttons' ],
183+
formItems: null,
184+
buttons: chatItem.buttons,
185+
onActionClick: action => {
186+
MynahUIGlobalEvents.getInstance().dispatch(MynahEventNames.BODY_ACTION_CLICKED, {
187+
tabId: this.props.tabId,
188+
messageId: undoAllMessageId,
189+
actionId: action.id,
190+
actionText: action.text
191+
});
192+
}
193+
});
194+
contentWrapper.appendChild(buttonsWrapper.render);
195+
}
196+
169197
private updateTitleText (chatItem: ChatItem): void {
170198
// check if chatItem
171199
if (chatItem.title !== undefined && chatItem.title !== '') {
@@ -180,6 +208,10 @@ export class ModifiedFilesTracker {
180208
// Store the current chatItem for button handling
181209
this.props.chatItem = chatItem;
182210
this.renderModifiedFiles(chatItem.header.fileList, chatItem.messageId);
211+
} else if (chatItem.buttons != null && Array.isArray(chatItem.buttons) && chatItem.buttons.length > 0) {
212+
// Handle case where only buttons (like undo all) are provided without fileList
213+
this.props.chatItem = chatItem;
214+
this.renderUndoAllButton(chatItem);
183215
}
184216
}
185217

0 commit comments

Comments
 (0)