Fixed stripe connect persistent button and "unsaved changes" warnings

no issue

- hook template up directly to the `settings.stripeConnectIntegrationToken` value
- reset `settings.stripeConnectIntegrationToken` when leaving the labs route
  - without the reset, after a failed save other settings screens will show the "unsaved changes" warning
This commit is contained in:
Kevin Ansfield 2020-06-15 17:43:02 +01:00
parent c389015b08
commit 839ebb0b59
3 changed files with 8 additions and 9 deletions

View File

@ -57,12 +57,12 @@
<h4 class="gh-setting-title">Connect to Stripe</h4>
{{#if this.stripeConnectIntegration}}
<p class="gh-setting-desc pa0 ma0">
{{#if this.stripeConnectSuccess}}
{{#if this.stripeConnectSuccess}}
{{svg-jar "check-circle" class="stroke-green w4 h4 nudge-top--3"}} <span class="green-d1">Successfully connected to {{this.stripeConnectIntegration.name}}</span>
{{else}}
Connected to <a href="https://dashboard.stripe.com/{{this.stripeConnectIntegration.id}}" target="_blank">{{this.stripeConnectIntegration.name}}</a>
{{/if}}
{{#unless this.stripeConnectIntegration.livemode}}
<span class="gh-members-connect-testmodelabel">Test mode</span>
{{/unless}}
@ -94,7 +94,7 @@
</div>
</div>
<div class="nudge-top--3">
<GhTextarea
<GhTextarea
@class="gh-members-stripe-connect-token"
@placeholder="Paste your secure key here"
@input={{action "setStripeConnectIntegrationToken" "stripe_connect_integration_token"}}
@ -116,11 +116,11 @@
</div>
</div>
<div class="gh-members-connect-savecontainer {{unless this.isStripeConnectSecureKeyEmpty "expanded"}}">
<div class="gh-members-connect-savecontainer {{if this.settings.stripeConnectIntegrationToken "expanded"}}">
<GhTaskButton @buttonText="Save Stripe settings"
@task={{this.saveStripeSettings}}
@successText="Saved"
@disabled={{this.isStripeConnectSecureKeyEmpty}}
@disabled={{is-empty this.settings.stripeConnectIntegrationToken}}
@runningText="Saving"
@class="gh-btn gh-btn-blue gh-btn-icon"
/>

View File

@ -128,10 +128,6 @@ export default Component.extend({
return !!bulkEmailSettings.isConfig;
}),
isStripeConnectSecureKeyEmpty: computed('settings.stripeConnectIntegrationToken', function () {
return this.get('settings.stripeConnectIntegrationToken') ? false : true;
}),
init() {
this._super(...arguments);
this.set('mailgunRegions', [US, EU]);

View File

@ -281,5 +281,8 @@ export default Controller.extend({
this.set('importErrors', null);
this.set('importSuccessful', false);
this.set('fromAddressUpdate', null);
// stripeConnectIntegrationToken is not a persisted value so we don't want
// to keep it around across transitions
this.settings.set('stripeConnectIntegrationToken', undefined);
}
});