Skip to content

Conversation

johnsimons
Copy link
Member

@johnsimons johnsimons commented Apr 4, 2025

This PR ensures the MessageView is reused for both successful and failure messages

body_size: number;
instance_id: string;
}
export interface ExtendedMessage extends Message {
Copy link
Member Author

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) => {
Copy link
Member Author

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" },
Copy link
Member Author

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

@johnsimons johnsimons changed the title Introducing the messageview store Adding ability to load successfully processed messages using the common MessageView component Apr 4, 2025
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.
@johnsimons johnsimons force-pushed the john/common_message_view branch from bfd1fa8 to 506a349 Compare April 4, 2025 07:33
@johnsimons johnsimons marked this pull request as ready for review April 7, 2025 00:05
Copy link
Contributor

@Copilot Copilot AI left a 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.

@johnsimons johnsimons self-assigned this Apr 7, 2025
Copy link
Contributor

@PhilBastian PhilBastian left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already set above

Copy link
Member Author

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 = {
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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;
Copy link
Contributor

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

Copy link
Member Author

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)">
Copy link
Contributor

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>
Copy link
Contributor

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)

Copy link
Member Author

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) });
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Member Author

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";
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

const message = (await response.json()) as FailedMessage;
state.data.message_id = message.message_id;
Copy link
Contributor

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;
Copy link
Contributor

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

Copy link
Member Author

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;
Copy link
Contributor

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?

Copy link
Member Author

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 = {
Copy link
Contributor

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) });
Copy link
Contributor

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

@johnsimons johnsimons enabled auto-merge April 9, 2025 06:06
@johnsimons johnsimons merged commit 95fd4a4 into master Apr 9, 2025
5 checks passed
@johnsimons johnsimons deleted the john/common_message_view branch April 9, 2025 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants