From ba91f8d6fe76fbe0181434572bd656f36224d8a9 Mon Sep 17 00:00:00 2001 From: MateuszMichalowski <79852198+MateuszMichalowski@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:58:58 +0200 Subject: [PATCH] feat(frontend): links and emails in messages (#3377) * feat(frontend): Transform links and mails in transaction messages into clickable links and mailto links. * feat(frontend): Lint fix --- .../DecayInformation-BeforeStartblock.vue | 33 +++++++++++++------ .../DecayInformation-Long.vue | 25 +++++++++++++- .../components/TransactionRows/MemoRow.vue | 24 +++++++++++++- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue b/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue index a3c4611d2..61d64500e 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-BeforeStartblock.vue @@ -2,21 +2,34 @@
{{ $t('form.memo') }}
-
{{ memo }}
+
{{ $t('decay.before_startblock_transaction') }}
- diff --git a/frontend/src/components/DecayInformations/DecayInformation-Long.vue b/frontend/src/components/DecayInformations/DecayInformation-Long.vue index 46f9051a5..96cdfb5c5 100644 --- a/frontend/src/components/DecayInformations/DecayInformation-Long.vue +++ b/frontend/src/components/DecayInformations/DecayInformation-Long.vue @@ -2,7 +2,7 @@
{{ $t('form.memo') }}
-
{{ memo }}
+
@@ -73,6 +73,7 @@ diff --git a/frontend/src/components/TransactionRows/MemoRow.vue b/frontend/src/components/TransactionRows/MemoRow.vue index f59cb506a..8303408e4 100644 --- a/frontend/src/components/TransactionRows/MemoRow.vue +++ b/frontend/src/components/TransactionRows/MemoRow.vue @@ -5,7 +5,7 @@
{{ $t('form.memo') }}
-
{{ memo }}
+
@@ -19,5 +19,27 @@ export default { required: true, }, }, + computed: { + displayData() { + return this.formatLinks(this.memo) + }, + }, + methods: { + formatLinks(text) { + const urlPattern = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim + const emailPattern = /(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)/g + + // Replace URLs with clickable links + text = text.replace( + urlPattern, + '$1', + ) + + // Replace email addresses with mailto links + text = text.replace(emailPattern, '$1') + + return text + }, + }, }