Skip to content

Commit

Permalink
fix(token-logo): integrated with dao treasury-currency (#1332) (#2652)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenibir authored Jul 15, 2024
1 parent dbfa632 commit c855626
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
21 changes: 19 additions & 2 deletions src/components/common/token-logo.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<script lang="ts">
import { defineComponent } from 'vue'
import { mapGetters } from 'vuex'
import IpfsImageViewer from '~/components/ipfs/ipfs-image-viewer.vue'
import currency from 'src/data/currency.json'
const mapCurrency = (currency) => (_) => ({
label: `${currency[_]?.symbol} - ${currency[_]?.name}`,
value: currency[_].code,
...currency[_]
})
/**
* Displays a token, icon
Expand Down Expand Up @@ -38,7 +46,16 @@ export default defineComponent({
}
},
methods: {}
computed: {
...mapGetters('dao', ['daoSettings']),
currencies () { return Object.keys(currency).map(mapCurrency(currency)) }
},
methods: {
getCurrencySymbol(code) {
return this.currencies.find(currency => currency.code === code).symbol
}
}
})
</script>

Expand All @@ -52,7 +69,7 @@ export default defineComponent({
ipfs-image-viewer(:color="daoLogo ? 'white' : 'secondary'" :ipfsCid="daoLogo" :size="size" showDefault)
.div.absolute.text-white.token-overlay(v-if="type === 'voice' || type === 'cash'")
.div.absolute.text-white.token-text(v-if="type === 'voice'") V
.div.absolute.text-white.token-text(v-if="type === 'cash'") $
.div.absolute.text-white.token-text(v-if="type === 'cash'") {{ daoSettings.treasuryCurrency ? getCurrencySymbol(daoSettings.treasuryCurrency): '$' }}
</template>
<style scoped lang="stylus">
.token-text
Expand Down
1 change: 1 addition & 0 deletions src/components/common/token-value.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default defineComponent({
span.text-bold.q-mx-sm(:class="coefficientPercentage && coefficientPercentage >= 0 ? 'text-positive' : 'text-negative'" v-else-if="coefficient && (coefficientPercentage !== undefined || coefficientPercentage !== null)") x
| {{coefficientPercentage}}
q-tooltip(:content-style="{'font-size': '1em'}" anchor="top right" self="top right" v-if="tooltip") {{tooltip}}
div {{ detail }}
.text-caption.text-left.inline-block.q-ml-sm.text-italic(v-if="detail") {{'(' + detail + ')'}}
</template>
<style scoped lang="stylus">
Expand Down
4 changes: 2 additions & 2 deletions src/components/dao/settings-tokens.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default {
)
q-tooltip(:content-style="{ 'font-size': '1em' }" anchor="top middle" self="bottom middle" v-if="!selectedDao.hasCustomToken") {{ $t('common.onlyDaoAdmins') }}
.col-12(:class="{ 'invisible': selectedDao.hasCustomToken }")
.col-12
label.h-label {{ $t('configuration.settings-tokens.tresury.form.currency.label') }}
q-select.q-my-xs(
:disable="!isAdmin"
Expand All @@ -228,7 +228,7 @@ export default {
options-dense
outlined
rounded
v-model="tokens.treasuryCurrency"
v-model="form.treasuryCurrency"
)
q-tooltip(:content-style="{ 'font-size': '1em' }" anchor="top middle" self="bottom middle" v-if="!selectedDao.hasCustomToken") {{ $t('common.onlyDaoAdmins') }}
Expand Down
4 changes: 2 additions & 2 deletions src/components/proposals/proposal-card-chips.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
},
computed: {
...mapGetters('dao', ['selectedDao']),
...mapGetters('dao', ['daoSettings', 'selectedDao']),
originalType () {
return this.proposal.original[0] ? this.proposal.original[0].__typename : null
},
Expand Down Expand Up @@ -260,7 +260,7 @@ export default {
if (this.compensation) {
const usdAmount = Number.parseFloat(this.compensation.amount.split(' ')[0])
result.push(
{ color: 'primary', outline: true, label: `${this.getFormatedTokenAmount(usdAmount, 3, 0)} USDE`, tooltip: this.compensation.tooltip })
{ color: 'primary', outline: true, label: `${this.getFormatedTokenAmount(usdAmount, 3, 0)} ${this.daoSettings.treasuryCurrency ? this.daoSettings.treasuryCurrency : 'USD'}E`, tooltip: this.compensation.tooltip })
}
if (this.salary) {
Expand Down
1 change: 1 addition & 0 deletions src/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const ACTIVE_DAO_QUERY = `
settings_exploreParagraph_s
settings_documentationUrl_s
settings_treasuryCurrency_s
}
memberAggregate {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/dho/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const settingsMapper = (data) => {
...(exist(form.votingQuorumPercent) ? { votingQuorumX100: form.votingQuorumPercent } : {}),
...(exist(form.communityVotingEnabled) ? { communityVotingEnabled: form.communityVotingEnabled ? 1 : 0 } : {}),
...(exist(form.treasuryCurrency) ? { treasuryCurrency: form.treasuryCurrency.value } : {})
...(exist(form.showUpvoteElection) ? { showUpvoteElection: form.showUpvoteElection ? 1 : 0 } : {})
}
}
Expand Down Expand Up @@ -63,6 +64,7 @@ const defaultSettings = {
communityVotingDurationSec: 604800,
communityVotingAlignmentPercent: 20,
communityVotingQuorumPercent: 50,
treasuryCurrency: 'USD',
// TODO:
// communityVotingMethod: 'CLASSIC',
Expand Down Expand Up @@ -164,6 +166,7 @@ export default {
// upvoteCheifDelegateDuration: this.daoSettings?.upvoteCheifDelegateDuration ? this.daoSettings?.upvoteCheifDelegateDuration : defaultSettings.upvoteCheifDelegateDuration,
// upvoteHeadDelegateRound: this.daoSettings?.upvoteHeadDelegateRound ? this.daoSettings?.upvoteHeadDelegateRound : defaultSettings.upvoteHeadDelegateRound,
// upvoteHeadDelegateDuration: this.daoSettings?.upvoteHeadDelegateDuration ? this.daoSettings?.upvoteHeadDelegateDuration : defaultSettings.upvoteHeadDelegateDuration,
treasuryCurrency: this.daoSettings?.treasuryCurrency ? this.daoSettings?.treasuryCurrency : defaultSettings.treasuryCurrency,
showUpvoteElection: this?.daoSettings?.showUpvoteElection != null ? this?.daoSettings?.showUpvoteElection : defaultSettings.showUpvoteElection
}
Expand Down
3 changes: 2 additions & 1 deletion src/store/dao/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const settingsMapper = (settings) => {
exploreTitle: settings?.settings_exploreTitle_s,
exploreParagraph: settings?.settings_exploreParagraph_s,

onboarderAccount: settings?.settings_onboarderAccount_n
onboarderAccount: settings?.settings_onboarderAccount_n,
treasuryCurrency: settings?.settings_treasuryCurrency_s
}
}

Expand Down

0 comments on commit c855626

Please sign in to comment.