-
Notifications
You must be signed in to change notification settings - Fork 26
Adding ability to load successfully processed messages using the common MessageView component #2311
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
Conversation
body_size: number; | ||
instance_id: string; | ||
} | ||
export interface ExtendedMessage extends Message { |
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.
It doesn't seem to be needed
}); | ||
} | ||
|
||
export const showToastAfterOperation = async (operation: () => Promise<void>, toastType: TYPE, title: string, message: string) => { |
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.
a helper function
const messagesLinks = (root: string) => { | ||
return { | ||
root, | ||
message: { link: (id: string) => `${root}/${id}`, template: "/messages/:id" }, |
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.
The way success messages vs failed messages are loaded is different hence the 2 different options
More changes
Introduces a reusable `MetadataLabel` component to streamline the display of message metadata in the message view. This improves code readability and maintainability by encapsulating the common styling and tooltip logic for metadata labels. It also makes it easier to consistently apply styling across different metadata labels.
Replaces the custom tab navigation in the message view with a reusable TabsLayout component. This change improves code maintainability and reduces duplication by centralizing the tab layout logic. The tabs are now dynamically generated based on the message context, such as whether it's an error or if MassTransit is connected.
bfd1fa8
to
506a349
Compare
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.
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
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.
review WIP, leaving current comments
headers: headers.value.data.map((header: Header) => ({ ...header })) as HeaderWithEditing[], | ||
messageBody: body.value.data.value ?? "", | ||
}; | ||
localMessage.value.isBodyEmpty = false; |
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.
already set above
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.
Fixed
function initializeMessageBodyAndHeaders() { | ||
origMessageBody = body.value.data.value ?? ""; | ||
localMessage.value = { |
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.
It's likely not affecting anything right now, but anything that's watching localMessage will be triggered by this assignment, but not by subsequent changes to the object below. This should be a local const assignment, and then at the end of the function is where the localMessage.value gets set. Subtle bug otherwise for possible future functionality
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.
I thought the trigger will only happen at the end of the function or async/await.
and the value on the watch callback will still be the end result.
but I can change it.
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.
since it's a proxy it happens on any property change
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.
fixed
function togglePanel(panelNum: number) { | ||
panel.value = panelNum; | ||
return false; |
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.
shouldn't be required since .prevent
is used
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.
removed
</tr> | ||
</tbody> | ||
</table> | ||
<div role="tabpanel" v-if="panel === 2 && !localMessage.bodyUnavailable" style="height: calc(100% - 260px)"> |
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.
local styles are better handled in styles if they don't involve any dynamic values
<CodeEditor v-else aria-label="message body" :read-only="!localMessage.isContentTypeSupported" v-model="localMessage.messageBody" :language="localMessage.language" :show-gutter="true"></CodeEditor> | ||
</div> | ||
<span class="empty-error" v-if="localMessage.isBodyEmpty"><i class="fa fa-exclamation-triangle"></i> Message body cannot be empty</span> | ||
<span class="reset-body" v-if="localMessage.isBodyChanged"><i class="fa fa-undo" v-tippy="`Reset changes`"></i> <a @click="resetBodyChanges()" href="javascript:void(0)">Reset changes</a></span> |
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.
while we're re-creating this control, we really should replace these anchor elements with button elements, fix the styling and get rid of the javascript:void(0)
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.
I’ll raise a card for this
function navigateToMessage(messageId: string) { | ||
router.push({ path: routeLinks.messages.message.link(messageId), query: { back: route.path } }); | ||
router.push({ path: routeLinks.messages.failedMessage.link(messageId) }); |
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.
why don't we need back anymore?
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.
Well, there are occasions where we navigate to the same page just with a different id.
So things started to get complex and all we are doing at the end of the day is a manual attempt at replacing the back button in the browser.
So I started questioning the complexity vs the benefit.
What are your thoughts?
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.
in the cases where they're navigating to multiple messages without changing view, I would think they would still want an easy way to get back to the list that originally brought them to the messageview, so this back value should be retained through multiple messageview id changes
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.
I have raised a card to add the back button back
@@ -0,0 +1,314 @@ | |||
import { acceptHMRUpdate, defineStore } from "pinia"; |
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.
According to how all the other stores are named, this should be MessageStore and useMessageStore rather than MessageViewStore
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.
Fixed
Co-authored-by: Phil Bastian <[email protected]>
} | ||
|
||
const message = (await response.json()) as FailedMessage; | ||
state.data.message_id = message.message_id; |
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.
this feels like it belongs in a "modelFromMessage" function
} | ||
|
||
async function loadFailedMessage(id: string) { | ||
state.data.id = id; |
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.
this is done as part of the loadMessage - probably only belongs there
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.
removed
async function archiveMessage() { | ||
if (state.data.id) { | ||
await useArchiveMessage([state.data.id]); | ||
state.data.failure_status.archiving = true; |
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.
where does this get set back to false?
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.
when it gets reloaded as part of the pollForNextUpdate
function initializeMessageBodyAndHeaders() { | ||
origMessageBody = body.value.data.value ?? ""; | ||
localMessage.value = { |
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.
since it's a proxy it happens on any property change
function navigateToMessage(messageId: string) { | ||
router.push({ path: routeLinks.messages.message.link(messageId), query: { back: route.path } }); | ||
router.push({ path: routeLinks.messages.failedMessage.link(messageId) }); |
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.
in the cases where they're navigating to multiple messages without changing view, I would think they would still want an easy way to get back to the list that originally brought them to the messageview, so this back value should be retained through multiple messageview id changes
This PR ensures the MessageView is reused for both successful and failure messages