Skip to content

Commit

Permalink
Merge pull request #746 from telosnetwork/dev
Browse files Browse the repository at this point in the history
Update Production Branch with Dev
  • Loading branch information
rozzaswap authored May 16, 2024
2 parents 3a26560 + aaa4f25 commit 9d7cff0
Show file tree
Hide file tree
Showing 39 changed files with 1,029 additions and 194 deletions.
97 changes: 56 additions & 41 deletions src/boot/errorHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const errorNotification = function(error, dismiss = false) {
timeout: dismiss ? 0 : 5000,
message: `${errorStr}`,
actions: dismiss ? [
{ label: this.$t('notification.dismiss_label'), color: 'white' },
{ label: $t('notification.dismiss_label'), color: 'white' },
] : [],
});
};
Expand Down Expand Up @@ -54,6 +54,10 @@ const successNotification = function(message) {

// ---------- new notification layouts ---------------

let $t = function(message) {
return message;
};

class NotificationAction {
constructor(payload) {
this.label = payload.label;
Expand All @@ -70,6 +74,13 @@ const infoIcon = require('src/assets/icon--info.svg');
const checkIcon = require('src/assets/icon--check.svg');
const discoIcon = require('src/assets/icon--disconnected.svg');
const warningIcon = require('src/assets/icon--warning.svg');
const icons = {
cross: crossIcon,
info: infoIcon,
check: checkIcon,
disco: discoIcon,
warning: warningIcon,
};

const html = `
<div class="c-notify__container c-notify__container--{type} c-notify__container--{random}">
Expand All @@ -92,11 +103,11 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '
// action buttons
const actions = [];
const dismiss_btn = {
label: this.$t('notification.dismiss_label'),
label: $t('notification.dismiss_label'),
class: 'c-notify__action-btn',
};
const link_btn = {
label: this.$t('notification.success_see_trx_label'),
label: $t('notification.success_see_trx_label'),
color: 'positive',
iconRight: 'launch',
class: 'c-notify__action-btn',
Expand All @@ -105,7 +116,7 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '
},
};
const details_btn = {
label: this.$t('notification.error_see_details_label'),
label: $t('notification.error_see_details_label'),
class: 'c-notify__action-btn ',
handler: () => {
let content = '';
Expand Down Expand Up @@ -135,14 +146,14 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '

Dialog.create({
class: 'c-notify__dialog',
title: this.$t('notification.error_details_title'),
title: $t('notification.error_details_title'),
message: '<q-card-section>' + content + '</q-card-section>',
html: true,
});
},
};
const action_btn = {
label: this.$t(payload?.label ?? '') ?? this.$t('notification.error_see_details_label'),
label: $t(payload?.label ?? '') ?? $t('notification.error_see_details_label'),
color: payload?.color ?? type === 'error' ? 'negative' : 'positive',
iconRight: payload?.iconRight,
class: 'c-notify__action-btn ' + payload?.class ? payload?.class : '',
Expand Down Expand Up @@ -172,7 +183,7 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '
actions.splice(0, actions.length);
}

let final_message = '<span>' + this.$t(message.toString() ?? '') + '</span>';
let final_message = '<span>' + $t(message.toString() ?? '') + '</span>';
if (Array.isArray(message)) {
final_message = message.map(
m => ` <${m.tag ?? 'span'} class="${m.class}">${m.text}</${m.tag ?? 'span'}> `,
Expand Down Expand Up @@ -208,7 +219,7 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '
'{random}': random,
'{remember}': remember,
'{message}': final_message,
'{remember-my-choice}': this.$t('notification.dont_show_message_again'),
'{remember-my-choice}': $t('notification.dont_show_message_again'),
};

const finalHtml = replaceAllOccurrences(html, replacements);
Expand All @@ -225,75 +236,75 @@ const notifyMessage = function(type, icon, title, message, payload, remember = '
};

const notifySuccessTransaction = function(link) {
return notifyMessage.bind(this)(
return notifyMessage (
'success',
checkIcon,
this.$t('notification.success_title_trx').toUpperCase(),
this.$t('notification.success_message_trx'),
$t('notification.success_title_trx').toUpperCase(),
$t('notification.success_message_trx'),
link,
);
};

const notifySuccessMessage = function(message, payload) {
return notifyMessage.bind(this)(
return notifyMessage (
'success',
checkIcon,
this.$t('notification.success_title_trx').toUpperCase(),
$t('notification.success_title_trx').toUpperCase(),
message,
payload,
);
};

const notifySuccessCopy = function() {
return notifyMessage.bind(this)(
return notifyMessage (
'success',
checkIcon,
this.$t('notification.success_title_copied').toUpperCase(),
this.$t('notification.success_message_copied'),
$t('notification.success_title_copied').toUpperCase(),
$t('notification.success_message_copied'),
);
};

const notifyFailure = function(message, payload) {
return notifyMessage.bind(this)(
return notifyMessage (
'error',
crossIcon,
this.$t('notification.error_title').toUpperCase(),
$t('notification.error_title').toUpperCase(),
message,
payload,
);
};

const notifyFailureWithAction = function(message, payload) {
return notifyMessage.bind(this)(
return notifyMessage (
'error',
crossIcon,
this.$t('notification.error_title').toUpperCase(),
$t('notification.error_title').toUpperCase(),
message,
new NotificationAction(payload),
);
};

const notifyWarningWithAction = function(message, payload) {
return notifyMessage.bind(this)(
return notifyMessage (
'error',
warningIcon,
this.$t('notification.warning_title').toUpperCase(),
$t('notification.warning_title').toUpperCase(),
message,
new NotificationAction(payload),
);
};

const notifyDisconnected = function() {
return notifyMessage.bind(this)(
return notifyMessage (
'error',
discoIcon,
this.$t('notification.error_title_disconnect'),
this.$t('notification.error_message_disconnect'),
$t('notification.error_title_disconnect'),
$t('notification.error_message_disconnect'),
);
};

const notifyNeutralMessage = function(message) {
return notifyMessage.bind(this)(
return notifyMessage (
'neutral',
null,
null,
Expand All @@ -308,7 +319,7 @@ const notifyRememberInfo = function(title, message, payload, key) {
if (dismissed[id]) {
return;
}
const notification = notifyMessage.bind(this)(
const notification = notifyMessage (
'info',
infoIcon,
title,
Expand Down Expand Up @@ -342,25 +353,25 @@ const notifyRememberInfo = function(title, message, payload, key) {


export default boot(({ app, store }) => {
app.config.globalProperties.$errorNotification = errorNotification.bind(store);
app.config.globalProperties.$unexpectedErrorNotification = unexpectedErrorNotification.bind(store);
app.config.globalProperties.$warningNotification = warningNotification.bind(store);
app.config.globalProperties.$successNotification = successNotification.bind(store);
app.config.globalProperties.$errorNotification = errorNotification;
app.config.globalProperties.$unexpectedErrorNotification = unexpectedErrorNotification;
app.config.globalProperties.$warningNotification = warningNotification;
app.config.globalProperties.$successNotification = successNotification;
store['$errorNotification'] = app.config.globalProperties.$errorNotification;
store['$unexpectedErrorNotification'] = app.config.globalProperties.$unexpectedErrorNotification;
store['$warningNotification'] = app.config.globalProperties.$warningNotification;
store['$successNotification'] = app.config.globalProperties.$successNotification;

// new Message notifications handlers
app.config.globalProperties.$notifySuccessTransaction = notifySuccessTransaction.bind(store);
app.config.globalProperties.$notifySuccessMessage = notifySuccessMessage.bind(store);
app.config.globalProperties.$notifySuccessCopy = notifySuccessCopy.bind(store);
app.config.globalProperties.$notifyFailure = notifyFailure.bind(store);
app.config.globalProperties.$notifyFailureWithAction = notifyFailureWithAction.bind(store);
app.config.globalProperties.$notifyWarningWithAction = notifyWarningWithAction.bind(store);
app.config.globalProperties.$notifyDisconnected = notifyDisconnected.bind(store);
app.config.globalProperties.$notifyNeutralMessage = notifyNeutralMessage.bind(store);
app.config.globalProperties.$notifyRememberInfo = notifyRememberInfo.bind(store);
app.config.globalProperties.$notifySuccessTransaction = notifySuccessTransaction;
app.config.globalProperties.$notifySuccessMessage = notifySuccessMessage;
app.config.globalProperties.$notifySuccessCopy = notifySuccessCopy;
app.config.globalProperties.$notifyFailure = notifyFailure;
app.config.globalProperties.$notifyFailureWithAction = notifyFailureWithAction;
app.config.globalProperties.$notifyWarningWithAction = notifyWarningWithAction;
app.config.globalProperties.$notifyDisconnected = notifyDisconnected;
app.config.globalProperties.$notifyNeutralMessage = notifyNeutralMessage;
app.config.globalProperties.$notifyRememberInfo = notifyRememberInfo;
store['$notifySuccessTransaction'] = app.config.globalProperties.$notifySuccessTransaction;
store['$notifySuccessMessage'] = app.config.globalProperties.$notifySuccessMessage;
store['$notifySuccessCopy'] = app.config.globalProperties.$notifySuccessCopy;
Expand All @@ -373,7 +384,7 @@ export default boot(({ app, store }) => {

// transaction notifications handlers
store['$t'] = app.config.globalProperties.$t;

$t = app.config.globalProperties.$t;
});

export {
Expand All @@ -386,7 +397,11 @@ export {
notifySuccessCopy,
notifyFailure,
notifyFailureWithAction,
notifyWarningWithAction,
notifyDisconnected,
notifyNeutralMessage,
notifyRememberInfo,
notifyMessage,
icons,
NotificationAction,
};
24 changes: 11 additions & 13 deletions src/components/AddressField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import { getIcon } from 'src/lib/token-utils';
import { toChecksumAddress } from 'src/lib/utils';

import CopyButton from 'components/CopyButton.vue';
import { useStore } from 'vuex';

const props = defineProps({
highlightAddress: {
type: String,
required: false,
default: '',
},
address: {
type: String,
required: true,
Expand All @@ -38,9 +34,12 @@ const props = defineProps({
type: Boolean,
default: false,
},
useHighlight: {
type: Boolean,
default: true,
},
});

const emit = defineEmits(['highlight']);

const displayName = ref('');
const fullName = ref(toChecksumAddress(props.address));
Expand All @@ -61,7 +60,9 @@ const restart = async () => {
await getDisplay();
};


const $store = useStore();
const setHighlightAddress = (method: string) => props.useHighlight ? $store.dispatch('general/setHighlightAddress', method) : null;
const highlightAddress = computed(() => props.useHighlight ? $store.state.general.highlightAddress : '');

watch(() => props.address, async () => {
restart();
Expand Down Expand Up @@ -90,6 +91,7 @@ const getDisplay = async () => {
return;
}
let address = toChecksumAddress(props.address);
fullName.value = address;
if (contractName.value) {
if(tokenList.value?.tokens){
tokenList.value.tokens.forEach((token: any) => {
Expand Down Expand Up @@ -125,18 +127,14 @@ const loadContract = async () => {
}
};

function emitHighlight(val: string) {
emit('highlight', val);
}

</script>

<template>
<div
:key="displayName + checksum"
:class="['c-address-field', props.class]"
@mouseover="emitHighlight(checksum)"
@mouseleave="emitHighlight('')"
@mouseover="setHighlightAddress(checksum)"
@mouseleave="setHighlightAddress('')"
>
<router-link
:to="`/${isToken?'token':'address'}/${checksum}`"
Expand Down
5 changes: 5 additions & 0 deletions src/components/AddressOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ onBeforeMount(() => {
width="18"
>
{{ getBalanceDisplay(tokenQty) }}
<ValueField
:value="tokenQty"
:symbol="'TLOS'"
:decimals="WEI_PRECISION"
/>
</div>
</q-card-section>
<q-card-section v-if="!loadingComplete" >
Expand Down
1 change: 1 addition & 0 deletions src/components/ContractMoreInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const props = defineProps({
<AddressField
:address="props.address"
:truncate="18"
:useHighlight="false"
/>
<CopyButton
:text="props.address"
Expand Down
9 changes: 8 additions & 1 deletion src/components/ContractTab/ContractInterface.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ onMounted(async () => {
</script>

<template>
<div class="q-pt-md">
<div class="c-contract-interface q-pt-md">
<AppHeaderWallet v-if="props.write" class="c-login-button c-contract-interface__login"/>
<q-list class="c-contract-interface__container">
<q-expansion-item
Expand Down Expand Up @@ -81,6 +81,13 @@ onMounted(async () => {
margin-bottom: 0.75rem !important;
margin-left: 1rem;
}
.q-item__label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
Loading

0 comments on commit 9d7cff0

Please sign in to comment.