Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 9256d6a

Browse files
authored
Merge pull request #1211 from OpenBazaar/checkModCoin
Don't allow adding moderators without compatible coins
2 parents a151b16 + 3155819 commit 9256d6a

File tree

4 files changed

+52
-20
lines changed

4 files changed

+52
-20
lines changed

js/languages/en_US.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@
367367
"termsOfService": "Terms of Service",
368368
"addAsModeratorButton": "Add as Moderator",
369369
"disclaimer": "**The moderator service charge only applies when a dispute arises.",
370-
"languages": "Languages"
370+
"languages": "Languages",
371+
"currenciesSupported": "Currencies Supported",
372+
"noCoinSupport": "This moderator does not support %{coin}."
371373
},
372374
"about": {
373375
"linkText": "About OpenBazaar",
@@ -917,6 +919,7 @@
917919
"type": "Type: %{type}",
918920
"condition": "Condition: %{condition}",
919921
"tags": "Tags",
922+
"paymentsAccepted": "Payments Accepted",
920923
"noTags": "No tags entered",
921924
"buyNow": "BUY NOW",
922925
"description": "Description",

js/templates/modals/listingDetail/listing.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<div class="flex gutterHLg">
4444
<h2 class="txUnb flexExpand"><%= ob.item.title %></h2>
4545
<h2 class="txUnb flexNoShrink js-price">
46-
<%=
46+
<%=
4747
ob.currencyMod.formattedCurrency(
4848
ob.item.price,
4949
ob.metadata.pricingCurrency,
@@ -104,7 +104,7 @@ <h2 class="txUnb flexNoShrink js-price">
104104
unpurchaseable = false;
105105
}
106106

107-
let unpurchasableMarkup = `<div class="flexHRight clrTErr">${ob.polyT('listingDetail.unableToPurchase.unpurchaseable') } &nbsp;<span class="toolTip" data-tip="${tip}" style="text-align: left"><span class="ion-alert-circled clrTErr"></span></span></div>`;
107+
let unpurchasableMarkup = `<div class="flexHRight clrTErr">${ob.polyT('listingDetail.unableToPurchase.unpurchaseable') } &nbsp;<span class="toolTip" data-tip="${tip}" style="text-align: left"><span class="ion-alert-circled clrTErr"></span></span></div>`;
108108
%>
109109
<button class="btnHg clrBAttGrad clrBrDec1 clrTOnEmph js-purchaseBtn <%= buyNowClass %>">
110110
<%= ob.polyT('listingDetail.buyNow') %>
@@ -136,7 +136,7 @@ <h5><%= ob.polyT('listingDetail.tags') %></h5>
136136
}); %>
137137
<% if(!ob.item.tags.length) { print(`<i class="clrT2">${ob.polyT('listingDetail.noTags')}</i>`) } %>
138138
</div>
139-
<h5>Payments Accepted</h5>
139+
<h5><%= ob.polyT('listingDetail.paymentsAccepted') %></h5>
140140
<ul class="unstyled">
141141
<% ob.metadata.acceptedCurrencies.forEach(cur => {
142142
const curData = ob.currencyMod.getCryptoCurByCode(cur);
@@ -146,7 +146,7 @@ <h5>Payments Accepted</h5>
146146
<%= ob.currencyMod.cryptoIcon({ code: curData.code }) %>
147147
<div class="acceptedCurName"><%= ob.polyT(`cryptoCurrencies.${curData.code}`) %></div>
148148
</li>
149-
<% }
149+
<% }
150150
}) %>
151151
</ul>
152152
</div>

js/templates/modals/moderatorDetails.html

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,25 @@
4444
</div>
4545
</div>
4646
<div class="contentBox mDetailBox padMd clrP clrBr clrSh3 tx5">
47+
<div class="rowMd">
48+
<h4><%= ob.polyT('moderatorDetails.currenciesSupported') %></h4>
49+
<ul class="unstyled">
50+
<% ob.moderatorInfo.acceptedCurrencies.forEach(cur => {
51+
const curData = ob.currencyMod.getCryptoCurByCode(cur);
52+
if (curData) { %>
53+
<li class="flexVCent gutterHSm clrBr">
54+
<span class="ion-ios-checkmark-empty clrTEm tx2"></span>
55+
<%= ob.currencyMod.cryptoIcon({ code: curData.code }) %>
56+
<div class="acceptedCurName"><%= ob.polyT(`cryptoCurrencies.${curData.code}`) %></div>
57+
</li>
58+
<% }
59+
}) %>
60+
</ul>
61+
</div>
4762
<div class="rowLg">
4863
<h4><%= ob.polyT('moderatorDetails.languages') %></h4>
4964
<% ob.modLanguages.forEach(lang => { %>
50-
<div class="rowSm txSm"><%= lang %></div>
65+
<div class="rowSm txSm"><%= lang %></div>
5166
<% }); %>
5267
</div>
5368
<div class="row">
@@ -57,13 +72,23 @@ <h4><%= ob.polyT('moderatorDetails.termsOfService') %></h4>
5772
</div>
5873
<div class="flexCol flexHCent gutterV">
5974
<% if (ob.cardState !== 'selected' && (!ob.ownMod || ob.purchase)) { %>
60-
<button class="btn clrP clrBr js-addAsModerator">
61-
<% if (ob.purchase) { %>
62-
<%= ob.polyT('purchase.chooseModerator') %>
63-
<% } else { %>
64-
<%= ob.polyT('moderatorDetails.addAsModeratorButton') %>
65-
<% } %>
66-
</button>
75+
<%
76+
const curSupported = ob.moderatorInfo.acceptedCurrencies.includes(
77+
ob.currencyMod.getServerCurrency().isTestnet ? ob.currencyMod.getServerCurrency().testnetCode : ob.currencyMod.getServerCurrency().code
78+
);
79+
if (curSupported) { %>
80+
<button class="btn clrP clrBr js-addAsModerator">
81+
<% if (ob.purchase) { %>
82+
<%= ob.polyT('purchase.chooseModerator') %>
83+
<% } else { %>
84+
<%= ob.polyT('moderatorDetails.addAsModeratorButton') %>
85+
<% } %>
86+
</button>
87+
<% } else { %>
88+
<strong>
89+
<%= ob.polyT('moderatorDetails.noCoinSupport', { coin: ob.currencyMod.getServerCurrency().code }) %>
90+
</strong>
91+
<% } %>
6792
<% } %>
6893
<div>
6994
<em class="tx6 clrT2"><%= ob.polyT('moderatorDetails.disclaimer') %></em>

js/templates/userCard.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<% } %>>
99
<div class="blockedOverlay clrP flexCent tx5">
1010
<div><%= ob.polyT('userShort.blockedUserOverlayText') %></div>
11-
</div>
11+
</div>
1212
<div class="userIconWrap">
1313
<a class="userIcon disc clrBr2 clrSh1"
1414
<% var avatarHash = ob.avatarHashes ? ob.isHiRez() ? ob.avatarHashes.small : ob.avatarHashes.tiny : ''; %>
@@ -23,12 +23,16 @@
2323
<% if (!ob.hideControls) { %>
2424
<div class="userControls flexHRight gutterHSm">
2525
<% if (!ob.ownGuid) { %>
26-
<% if (ob.moderator) { %>
27-
<%= ob.processingButton({
28-
className: `iconBtnSm clrP clrBr toolTipNoWrap toolTipTop js-mod ${ob.ownMod ? 'active' : ''}`,
29-
btnText: '<i class="ion-briefcase"></i>',
30-
attrs: `data-tip="${ob.getModTip(ob.ownMod)}"`,
31-
}) %>
26+
<%
27+
const curSupported = ob.moderator && ob.moderatorInfo.acceptedCurrencies.includes(
28+
ob.currencyMod.getServerCurrency().isTestnet ? ob.currencyMod.getServerCurrency().testnetCode : ob.currencyMod.getServerCurrency().code
29+
);
30+
if (curSupported) { %>
31+
<%= ob.processingButton({
32+
className: `iconBtnSm clrP clrBr toolTipNoWrap toolTipTop js-mod ${ob.ownMod ? 'active' : ''}`,
33+
btnText: '<i class="ion-briefcase"></i>',
34+
attrs: `data-tip="${ob.getModTip(ob.ownMod)}"`,
35+
}) %>
3236
<% } %>
3337
<%= ob.processingButton({
3438
className: `iconBtnSm clrP clrBr toolTipNoWrap toolTipTop js-follow ${ob.followedByYou ? 'active' : ''}`,

0 commit comments

Comments
 (0)