Skip to content

Commit b547208

Browse files
authored
feat: more informative titles for transaction/group details pages (#2222)
Signed-off-by: Simon Viénot <simon.vienot@icloud.com>
1 parent 485e2fa commit b547208

File tree

3 files changed

+75
-24
lines changed

3 files changed

+75
-24
lines changed

front-end/src/renderer/pages/TransactionDetails/components/TransactionDetailsHeader.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { AccountByIdCache } from '@renderer/caches/mirrorNode/AccountByIdCache.t
5757
import { NodeByIdCache } from '@renderer/caches/mirrorNode/NodeByIdCache.ts';
5858
import { errorToastOptions, successToastOptions } from '@renderer/utils/toastOptions.ts';
5959
import { writeTransactionFile } from '@renderer/services/transactionFileService.ts';
60+
import { getTransactionType } from '@renderer/utils/sdk/transactions.ts';
6061
6162
/* Types */
6263
type ActionButton =
@@ -152,6 +153,10 @@ const publicKeysRequiredToSign = ref<string[] | null>(null);
152153
const shouldApprove = ref<boolean>(false);
153154
154155
/* Computed */
156+
const txType = computed(() => {
157+
return props.sdkTransaction ? getTransactionType(props.sdkTransaction) : null;
158+
});
159+
155160
const creator = computed(() => {
156161
return props.organizationTransaction
157162
? contacts.contacts.find(contact =>
@@ -628,21 +633,21 @@ watch(
628633
>
629634
<i class="bi bi-arrow-left"></i>
630635
</AppButton>
631-
<NextTransactionCursor/>
632-
<h2 class="text-title text-bold">
633-
Transaction Details
634-
<span v-if="isTransactionFailed" class="badge bg-danger text-break ms-2">
636+
<NextTransactionCursor />
637+
<template v-if="txType">
638+
<h2 class="text-title text-bold">{{ txType }}</h2>
639+
<span v-if="isTransactionFailed" class="badge bg-danger text-break">
635640
{{
636641
getStatusFromCode(props.organizationTransaction?.statusCode)
637642
? getStatusFromCode(props.organizationTransaction?.statusCode)
638643
: 'FAILED'
639644
}}
640645
</span>
641-
<span v-else-if="isTransactionVersionMismatch" class="badge bg-danger text-break ms-2">
642-
Transaction Version Mismatch
643-
</span>
644-
<span v-else-if="isManualFlagVisible" class="badge bg-info text-break ms-2">Manual</span>
645-
</h2>
646+
<span v-else-if="isTransactionVersionMismatch" class="badge bg-danger text-break"
647+
>Transaction Version Mismatch</span
648+
>
649+
<span v-else-if="isManualFlagVisible" class="badge bg-info text-break">Manual</span>
650+
</template>
646651
</div>
647652

648653
<div class="flex-centered gap-4">

front-end/src/renderer/pages/TransactionGroupDetails/TransactionGroupDetails.vue

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import type { IGroup } from '@renderer/services/organization';
3-
import type { IGroupItem, ITransactionFull } from '@shared/interfaces';
3+
import { BackEndTransactionType, type IGroupItem, type ITransactionFull } from '@shared/interfaces';
44
import { TransactionStatus, TransactionTypeName } from '@shared/interfaces';
55
66
import { computed, onBeforeMount, reactive, ref, watch, watchEffect } from 'vue';
@@ -58,7 +58,10 @@ import useContactsStore from '@renderer/stores/storeContacts.ts';
5858
import AppDropDown from '@renderer/components/ui/AppDropDown.vue';
5959
import { NodeByIdCache } from '@renderer/caches/mirrorNode/NodeByIdCache.ts';
6060
import { errorToastOptions, successToastOptions } from '@renderer/utils/toastOptions.ts';
61-
import { formatTransactionType } from '@renderer/utils/sdk/transactions.ts';
61+
import {
62+
formatTransactionType,
63+
getTransactionTypeFromBackendType,
64+
} from '@renderer/utils/sdk/transactions.ts';
6265
import TransactionId from '@renderer/components/ui/TransactionId.vue';
6366
import NextTransactionCursor from '@renderer/components/NextTransactionCursor.vue';
6467
@@ -123,6 +126,35 @@ const loadingStates = reactive<{ [key: string]: string | null }>({
123126
});
124127
125128
/* Computed */
129+
const pageTitle = computed(() => {
130+
let txType: BackEndTransactionType | null = null;
131+
let result: string | null = null;
132+
133+
if (group.value) {
134+
if (group.value.groupItems.length >= 1) {
135+
txType = group.value.groupItems[0].transaction.type;
136+
for (const item of group.value.groupItems.slice(1)) {
137+
if (item.transaction.type !== txType) {
138+
txType = null;
139+
break;
140+
}
141+
}
142+
result = txType
143+
? `Group of ${group.value.groupItems.length} ${getTransactionTypeFromBackendType(txType, false, true)} transactions`
144+
: `Group of ${group.value.groupItems.length} transactions`;
145+
}
146+
}
147+
return result;
148+
});
149+
150+
const description = computed(() => {
151+
return group.value ? group.value.description : null;
152+
});
153+
154+
const isSequential = computed(() => {
155+
return group.value?.sequential ?? false;
156+
});
157+
126158
const canSignAll = computed(() => {
127159
return (
128160
isLoggedInOrganization(user.selectedOrganization) &&
@@ -638,13 +670,19 @@ function itemStatusBadgeClass(item: IGroupItem): string {
638670
<form @submit.prevent="handleSubmit" class="p-5">
639671
<div class="flex-column-100">
640672
<div class="flex-centered justify-content-between flex-wrap gap-4">
641-
<div class="d-flex align-items-center gap-4">
673+
<div class="d-flex align-items-center gap-4 flex-1">
642674
<AppButton type="button" color="secondary" class="btn-icon-only" @click="handleBack">
643675
<i class="bi bi-arrow-left"></i>
644676
</AppButton>
645677
<NextTransactionCursor />
646678

647-
<h2 class="text-title text-bold">Transaction Group Details</h2>
679+
<Transition mode="out-in" name="fade">
680+
<template v-if="pageTitle">
681+
<h2 class="text-title text-bold flex-1 text-one-line-ellipsis">
682+
{{ pageTitle }}
683+
</h2>
684+
</template>
685+
</Transition>
648686
</div>
649687

650688
<div class="flex-centered gap-4">
@@ -682,18 +720,14 @@ function itemStatusBadgeClass(item: IGroupItem): string {
682720
<Transition name="fade" mode="out-in">
683721
<template v-if="group">
684722
<div class="fill-remaining flex-column-100 mt-5">
685-
<div class="d-flex">
686-
<div class="col-6 flex-1">
687-
<label class="form-label">Transaction Group Description</label>
688-
<div>{{ group?.description }}</div>
689-
</div>
723+
<div class="mt-5">
724+
<label class="form-label">Transaction Group Description</label>
725+
<div>{{ description }}</div>
726+
</div>
690727

691-
<template v-if="isLoggedInOrganization(user.selectedOrganization)">
692-
<div class="col-6">
693-
<label class="form-label">Sequential Execution</label>
694-
<div>{{ group?.sequential ? 'Yes' : 'No' }}</div>
695-
</div>
696-
</template>
728+
<div v-if="isLoggedInOrganization(user.selectedOrganization)" class="mt-5">
729+
<label class="form-label">Sequential Execution</label>
730+
<div>{{ isSequential ? 'Yes' : 'No' }}</div>
697731
</div>
698732

699733
<hr class="separator my-5 w-100" />

front-end/src/renderer/styles/_utilities.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,15 @@
176176
word-break: break-word;
177177
min-width: 6rem;
178178
}
179+
180+
.text-one-line-ellipsis {
181+
display: -webkit-box;
182+
-webkit-box-orient: vertical;
183+
-webkit-line-clamp: 1;
184+
line-clamp: 1;
185+
overflow: hidden;
186+
text-overflow: ellipsis;
187+
white-space: normal;
188+
word-break: break-all;
189+
min-width: 6rem;
190+
}

0 commit comments

Comments
 (0)