mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Crowdfund: Improve no perks case (#5378)
If there are no perks configured, do not display the perks sidebar and contribute custom amount directly, when the main CTA "Contribute" is clicked. Before it opened a mopdal, where one had to select the only option (custom amount) manually — so this gets rid of the extra step. Closes #5376.
This commit is contained in:
parent
d8422a979f
commit
1d210eb6e3
3 changed files with 39 additions and 7 deletions
|
@ -1107,7 +1107,7 @@ namespace BTCPayServer.Tests
|
||||||
s.Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
|
s.Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
|
||||||
s.Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
|
s.Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
|
||||||
s.Driver.FindElement(By.Id("TargetCurrency")).Clear();
|
s.Driver.FindElement(By.Id("TargetCurrency")).Clear();
|
||||||
s.Driver.FindElement(By.Id("TargetCurrency")).SendKeys("JPY");
|
s.Driver.FindElement(By.Id("TargetCurrency")).SendKeys("EUR");
|
||||||
s.Driver.FindElement(By.Id("TargetAmount")).SendKeys("700");
|
s.Driver.FindElement(By.Id("TargetAmount")).SendKeys("700");
|
||||||
|
|
||||||
// test wrong dates
|
// test wrong dates
|
||||||
|
@ -1122,7 +1122,8 @@ namespace BTCPayServer.Tests
|
||||||
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
||||||
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
||||||
var appId = s.Driver.Url.Split('/')[4];
|
var appId = s.Driver.Url.Split('/')[4];
|
||||||
|
|
||||||
|
// CHeck public page
|
||||||
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
||||||
var windows = s.Driver.WindowHandles;
|
var windows = s.Driver.WindowHandles;
|
||||||
Assert.Equal(2, windows.Count);
|
Assert.Equal(2, windows.Count);
|
||||||
|
@ -1132,6 +1133,26 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Equal("Currently active!",
|
Assert.Equal("Currently active!",
|
||||||
s.Driver.FindElement(By.CssSelector("[data-test='time-state']")).Text);
|
s.Driver.FindElement(By.CssSelector("[data-test='time-state']")).Text);
|
||||||
|
|
||||||
|
// Contribute
|
||||||
|
s.Driver.FindElement(By.Id("crowdfund-body-header-cta")).Click();
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
s.Driver.WaitUntilAvailable(By.Name("btcpay"));
|
||||||
|
|
||||||
|
var frameElement = s.Driver.FindElement(By.Name("btcpay"));
|
||||||
|
Assert.True(frameElement.Displayed);
|
||||||
|
var iframe = s.Driver.SwitchTo().Frame(frameElement);
|
||||||
|
iframe.WaitUntilAvailable(By.Id("Checkout-v2"));
|
||||||
|
|
||||||
|
IWebElement closebutton = null;
|
||||||
|
TestUtils.Eventually(() =>
|
||||||
|
{
|
||||||
|
closebutton = iframe.FindElement(By.Id("close"));
|
||||||
|
Assert.True(closebutton.Displayed);
|
||||||
|
});
|
||||||
|
closebutton.Click();
|
||||||
|
s.Driver.AssertElementNotFound(By.Name("btcpay"));
|
||||||
|
|
||||||
|
// Back to admin view
|
||||||
s.Driver.Close();
|
s.Driver.Close();
|
||||||
s.Driver.SwitchTo().Window(windows[0]);
|
s.Driver.SwitchTo().Window(windows[0]);
|
||||||
|
|
||||||
|
|
|
@ -211,11 +211,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center mb-4" id="crowdfund-body-header">
|
<div class="text-center mb-4" id="crowdfund-body-header">
|
||||||
<button v-if="active" id="crowdfund-body-header-cta" class="btn btn-lg btn-primary py-2 px-5 only-for-js" v-on:click="contributeModalOpen = true">Contribute</button>
|
<button v-if="active" id="crowdfund-body-header-cta" class="btn btn-lg btn-primary py-2 px-5 only-for-js" v-on:click="contribute">Contribute</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mt-4 justify-content-between gap-5">
|
<div class="row mt-4 justify-content-between gap-5">
|
||||||
<div class="col-lg-7 col-sm-12" id="crowdfund-body-description-container">
|
<div :class="{ 'col-lg-7 col-sm-12': hasPerks, 'col-12': !hasPerks }" id="crowdfund-body-description-container">
|
||||||
<template v-if="srvModel.disqusEnabled && srvModel.disqusShortname">
|
<template v-if="srvModel.disqusEnabled && srvModel.disqusShortname">
|
||||||
<b-tabs>
|
<b-tabs>
|
||||||
<b-tab title="Details" active>
|
<b-tab title="Details" active>
|
||||||
|
@ -232,7 +232,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-sm-12" id="crowdfund-body-contribution-container">
|
<div class="col-lg-4 col-sm-12" id="crowdfund-body-contribution-container" v-if="hasPerks">
|
||||||
<contribute :target-currency="srvModel.targetCurrency"
|
<contribute :target-currency="srvModel.targetCurrency"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:display-perks-ranking="srvModel.displayPerksRanking"
|
:display-perks-ranking="srvModel.displayPerksRanking"
|
||||||
|
@ -266,7 +266,6 @@
|
||||||
:in-modal="true">
|
:in-modal="true">
|
||||||
</contribute>
|
</contribute>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
|
|
||||||
<footer class="store-footer">
|
<footer class="store-footer">
|
||||||
<a class="store-powered-by" href="https://btcpayserver.org" target="_blank" rel="noreferrer noopener">
|
<a class="store-powered-by" href="https://btcpayserver.org" target="_blank" rel="noreferrer noopener">
|
||||||
Powered by <partial name="_StoreFooterLogo" />
|
Powered by <partial name="_StoreFooterLogo" />
|
||||||
|
|
|
@ -38,7 +38,7 @@ document.addEventListener("DOMContentLoaded",function (ev) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
if(!this.active || this.loading){
|
if (!this.active || this.loading){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,9 @@ document.addEventListener("DOMContentLoaded",function (ev) {
|
||||||
result.push(currentPerk);
|
result.push(currentPerk);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
},
|
||||||
|
hasPerks() {
|
||||||
|
return this.srvModel.perks && this.srvModel.perks.length > 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -214,6 +217,15 @@ document.addEventListener("DOMContentLoaded",function (ev) {
|
||||||
},
|
},
|
||||||
formatAmount: function(amount) {
|
formatAmount: function(amount) {
|
||||||
return formatAmount(amount, this.srvModel.currencyData.divisibility)
|
return formatAmount(amount, this.srvModel.currencyData.divisibility)
|
||||||
|
},
|
||||||
|
contribute() {
|
||||||
|
if (!this.active || this.loading) return;
|
||||||
|
|
||||||
|
if (this.hasPerks){
|
||||||
|
this.contributeModalOpen = true
|
||||||
|
} else {
|
||||||
|
eventAggregator.$emit("contribute", {amount: null, choiceKey: null});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue