Skip to content

Commit

Permalink
replace others with view proposal link
Browse files Browse the repository at this point in the history
  • Loading branch information
andremury committed Dec 15, 2023
1 parent 980d36e commit 779ac72
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 39 deletions.
6 changes: 3 additions & 3 deletions assets/javascripts/discourse/components/karma-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default Component.extend({
availableDaos: [],

karmaDelegatorsUrl: computed(function () {
return `https://karmahq.xyz/dao/${this.daoName}/delegators/${this.profile.username}`;
return `https://karmahq.xyz/dao/${this.daoName?.toLowerCase()}/delegators/${this.profile.username}`;
}),

setProfile(profile) {
Expand All @@ -40,8 +40,8 @@ export default Component.extend({

@action
selectDao(daoName) {
if (!daoName) { return };
if (!this.availableDaos.find(d => d.name === daoName)) { return };
if(!daoName) { return };
if(!this.availableDaos.find(d => d.name === daoName)) { return };
set(this, 'daoName', daoName);
window.selectedDao = daoName;
this.fetchProfile();
Expand Down
9 changes: 8 additions & 1 deletion assets/javascripts/discourse/components/vote-breakdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from "@ember/component";
import { set } from "@ember/object";
import { set, action } from "@ember/object";
import { shortenNumber } from "../../lib/shorten-number";

export default Component.extend({
Expand All @@ -9,6 +9,8 @@ export default Component.extend({

loading: false,

proposalUrl: "",

sortVotes(votes) {
if (
Array.isArray(votes) &&
Expand Down Expand Up @@ -72,4 +74,9 @@ export default Component.extend({
const truncatedArray = this.truncateVotesArray(this.sortVotes(votesPct));
set(this, "values", truncatedArray);
},

@action
redirect() {
window.open(this.link, "_blank");
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
</span> }}
</div>
</div>
<div class="vote-breakdown">
{{vote-breakdown loading=loading breakdown=proposal.voteBreakdown}}
</div>
{{#if link}}
<div class="vote-breakdown">
{{vote-breakdown loading=loading breakdown=proposal.voteBreakdown proposalUrl=link}}
</div>
{{/if}}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,56 @@
</div>
</div>
{{else}}

{{#if values.length}}

{{#each values as |value|}}
<div class="breakdown">
<div style="display:flex;justify-content:space-between">
<div>
<b class="mr-3">
{{value.shortname}}
</b>
<span class="t-light">
{{#if (eq value.shortname "Others")}}
<div style="color: var(--tertiary)">
<button onclick={{redirect}} type="button" style="border:none;background:transparent">
View more options
{{d-icon "link"}}
</button>
</div>
{{else}}
<div class="breakdown">
<div style="display:flex;justify-content:space-between">
<div>
<b class="mr-3">
{{value.shortname}}
</b>
<span class="t-light">
{{#if siteSettings.Show_results}}
<b>
{{value.count}}
votes
</b>
{{/if}}
</span>
</div>
<div>
{{#if siteSettings.Show_results}}
<b>
{{value.count}} votes
{{value.pct}}
</b>
{{/if}}
</span>
</div>
</div>
<div>
<div
class="breakdown-progress"
style="max-height:100%;width:100%;overflow:hidden"
>

{{#if siteSettings.Show_results}}
<b>
{{value.pct}}
</b>
<div
class="breakdown-progress-fill"
style={{html-safe (concat "width:" value.fillPct)}}
>
</div>
{{/if}}
</div>
</div>
<div
class="breakdown-progress"
style="max-height:100%;width:100%;overflow:hidden"
>
{{#if (eq value.shortname "Others")}}
{{karma-tooltip label=value.name}}
{{/if}}
{{#if siteSettings.Show_results}}
<div
class="breakdown-progress-fill"
style={{html-safe (concat "width:" value.fillPct)}}
>
</div>
{{/if}}
</div>
</div>
{{/if}}
{{/each}}
{{/if}}
{{/if}}
4 changes: 2 additions & 2 deletions assets/javascripts/lib/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const KarmaStats = {
if (delegates) {
const { stats } = delegates;
userStats.delegatedVotes = `
<a href="https://karmahq.xyz/dao/${daoName}/delegators/${data.ensName || data.address
<a href="https://karmahq.xyz/dao/${daoName.toLowerCase()}/delegators/${data.ensName || data.address
}" target="_blank">${shortenNumber(delegates.delegatedVotes || 0)}</a>`;

userStats.snapshotVotingStats =
Expand Down Expand Up @@ -117,7 +117,7 @@ const KarmaStats = {
<a
target="_blank"
rel="noopener noreferrer"
href="https://www.karmahq.xyz/dao/link/forum?dao=${daoName}"
href="https://www.karmahq.xyz/dao/link/forum?dao=${daoName?.toLowerCase()}"
>
Link Wallet
</a>`
Expand Down
3 changes: 2 additions & 1 deletion assets/stylesheets/proposal-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
top: -35px;
width: 0;
.__karma-tooltip {
top: -40px;
z-index: -1;
position: relative;
opacity: 0;
Expand Down Expand Up @@ -287,7 +288,7 @@
width: 100%;
}


}
}
}
Expand Down

0 comments on commit 779ac72

Please sign in to comment.