mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
Added new modal settings behind dev flag (#1615)
no issue depends on77e1ada6c6
- reverts commit6760527
with modifications for naming - Adds new portal settings UI in Labs -> Members setting - Allows customization of new portal-* settings upstream - Updates settings service to include portal group - Updates settings modal to include new portal-* settings
This commit is contained in:
parent
440591cc21
commit
c6d12cbe5b
@ -291,6 +291,19 @@
|
||||
</div>
|
||||
{{/liquid-if}}
|
||||
</section>
|
||||
{{#if this.config.enableDeveloperExperiments}}
|
||||
<section class="bb b--whitegrey pa5">
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
<h4 class="gh-setting-title">Modal settings</h4>
|
||||
<p class="gh-setting-desc pa0 ma0">Customize members modal signup flow</p>
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" class="gh-btn" {{action (toggle "showMembersModalSettings" this)}} data-test-toggle-membersFrom><span> Customize </span></button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
{{#unless this.hasBulkEmailConfig}}
|
||||
<section class="bb b--whitegrey pa5">
|
||||
<div class="flex justify-between">
|
||||
@ -353,4 +366,14 @@
|
||||
{{/liquid-if}}
|
||||
</section>
|
||||
{{/unless}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if this.showMembersModalSettings}}
|
||||
<GhFullscreenModal @modal="members-modal-settings"
|
||||
@model={{hash
|
||||
subscriptionSettings=this.subscriptionSettings
|
||||
stripeConnectIntegration=this.stripeConnectIntegration
|
||||
}}
|
||||
@close={{action "closeMembersModalSettings"}}
|
||||
@modifier="action wide" />
|
||||
{{/if}}
|
@ -39,6 +39,7 @@ export default Component.extend({
|
||||
|
||||
currencies: null,
|
||||
showFromAddressConfirmation: false,
|
||||
showMembersModalSettings: false,
|
||||
|
||||
// passed in actions
|
||||
setMembersSubscriptionSettings() {},
|
||||
@ -139,6 +140,10 @@ export default Component.extend({
|
||||
this.toggleProperty('showFromAddressConfirmation');
|
||||
},
|
||||
|
||||
closeMembersModalSettings() {
|
||||
this.set('showMembersModalSettings', false);
|
||||
},
|
||||
|
||||
setDefaultContentVisibility(value) {
|
||||
this.setDefaultContentVisibility(value);
|
||||
},
|
||||
|
130
ghost/admin/app/components/modal-members-modal-settings.hbs
Normal file
130
ghost/admin/app/components/modal-members-modal-settings.hbs
Normal file
@ -0,0 +1,130 @@
|
||||
<header class="modal-header" data-test-modal="custom-view-form">
|
||||
<h1>Members modal settings</h1>
|
||||
</header>
|
||||
{{!-- disable mouseDown so it doesn't trigger focus-out validations --}}
|
||||
<button class="close" href title="Close" {{action "closeModal"}} {{action (optional this.noop) on="mouseDown"}}>
|
||||
{{svg-jar "close"}}
|
||||
</button>
|
||||
|
||||
<div class="modal-body">
|
||||
<fieldset>
|
||||
<div class="pt3">
|
||||
<GhFormGroup @classNames="gh-members-subscribed-checkbox pb4 mb0">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h4 class="gh-setting-title">Display name in signup form</h4>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<label class="switch" for="signup-name-checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={{this.settings.portalName}}
|
||||
id="signup-name-checkbox"
|
||||
name="signup-name-checkbox" onclick={{action "togglePortalName" value="target.checked"}}>
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</GhFormGroup>
|
||||
<div>
|
||||
<div class="mb3">
|
||||
<h4 class="gh-setting-title">Plans available at signup</h4>
|
||||
</div>
|
||||
<div class="form-group mb0 for-checkbox">
|
||||
<label
|
||||
class="checkbox"
|
||||
for="free-plan"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={{this.isFreeChecked}}
|
||||
id="free-plan"
|
||||
name="free-plan"
|
||||
disabled={{not this.subscriptionSettings.allowSelfSignup}}
|
||||
class="gh-input post-settings-featured"
|
||||
onclick={{action "toggleFreePlan" value="target.checked"}}
|
||||
data-test-checkbox="featured"
|
||||
>
|
||||
<span class="input-toggle-component"></span>
|
||||
<p>Free</p>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group mb0 for-checkbox">
|
||||
<label
|
||||
class="checkbox"
|
||||
for="monthly-plan"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="monthly-plan"
|
||||
name="monthly-plan"
|
||||
checked={{this.isMonthlyChecked}}
|
||||
disabled={{not this.isStripeConfigured}}
|
||||
class="gh-input post-settings-featured"
|
||||
onclick={{action "toggleMonthlyPlan" value="target.checked"}}
|
||||
data-test-checkbox="featured"
|
||||
>
|
||||
<span class="input-toggle-component"></span>
|
||||
<p>Monthly</p>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-group mb0 for-checkbox">
|
||||
<label
|
||||
class="checkbox"
|
||||
for="yearly-plan"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="yearly-plan"
|
||||
name="yearly-plan"
|
||||
checked={{this.isYearlyChecked}}
|
||||
disabled={{not this.isStripeConfigured}}
|
||||
class="gh-input post-settings-featured"
|
||||
onclick={{action "toggleYearlyPlan" value="target.checked"}}
|
||||
data-test-checkbox="featured"
|
||||
>
|
||||
<span class="input-toggle-component"></span>
|
||||
<p>Yearly</p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<GhFormGroup @classNames="gh-members-subscribed-checkbox mb0 bt pt3 b--whitegrey">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h4 class="gh-setting-title">Show beacon</h4>
|
||||
</div>
|
||||
<div class="for-switch">
|
||||
<label class="switch" for="portal-button-checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={{this.settings.portalButton}}
|
||||
id="portal-button-checkbox"
|
||||
name="portal-button-checkbox" onclick={{action "togglePortalButton" value="target.checked"}}>
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</GhFormGroup>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
class="gh-btn"
|
||||
{{action "closeModal"}}
|
||||
{{!-- disable mouseDown so it doesn't trigger focus-out validations --}}
|
||||
{{on "mousedown" (optional this.noop)}}
|
||||
data-test-button="cancel-custom-view-form"
|
||||
>
|
||||
<span>Cancel</span>
|
||||
</button>
|
||||
|
||||
<GhTaskButton
|
||||
@buttonText="Save and close"
|
||||
@successText="Saved"
|
||||
@task={{this.saveTask}}
|
||||
@idleClass="gh-btn-green"
|
||||
@class="gh-btn gh-btn-icon"
|
||||
data-test-button="save-members-modal-setting" />
|
||||
</div>
|
83
ghost/admin/app/components/modal-members-modal-settings.js
Normal file
83
ghost/admin/app/components/modal-members-modal-settings.js
Normal file
@ -0,0 +1,83 @@
|
||||
import ModalComponent from 'ghost-admin/components/modal-base';
|
||||
import {alias} from '@ember/object/computed';
|
||||
import {computed} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
export default ModalComponent.extend({
|
||||
settings: service(),
|
||||
confirm() {},
|
||||
|
||||
subscriptionSettings: alias('model.subscriptionSettings'),
|
||||
stripeConnectIntegration: alias('model.stripeConnectIntegration'),
|
||||
|
||||
isFreeChecked: computed('settings.{portalPlans.[],membersSubscriptionSettings}', function () {
|
||||
const allowSelfSignup = this.subscriptionSettings.allowSelfSignup;
|
||||
const allowedPlans = this.settings.get('portalPlans') || [];
|
||||
return (allowSelfSignup && allowedPlans.includes('free'));
|
||||
}),
|
||||
|
||||
isStripeConfigured: computed('settings.{stripeConnectIntegration,membersSubscriptionSettings}', function () {
|
||||
const stripeConfig = this.subscriptionSettings.stripeConfig;
|
||||
const stripeIntegration = this.stripeConnectIntegration;
|
||||
return (!!stripeConfig.public_token && !!stripeConfig.secret_token) || stripeIntegration;
|
||||
}),
|
||||
|
||||
isMonthlyChecked: computed('settings.portalPlans.[]', 'isStripeConfigured', function () {
|
||||
const allowedPlans = this.settings.get('portalPlans') || [];
|
||||
return (this.isStripeConfigured && allowedPlans.includes('monthly'));
|
||||
}),
|
||||
|
||||
isYearlyChecked: computed('settings.portalPlans.[]', 'isStripeConfigured', function () {
|
||||
const allowedPlans = this.settings.get('portalPlans') || [];
|
||||
return (this.isStripeConfigured && allowedPlans.includes('yearly'));
|
||||
}),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
actions: {
|
||||
toggleFreePlan(isChecked) {
|
||||
this.updateAllowedPlan('free', isChecked);
|
||||
},
|
||||
toggleMonthlyPlan(isChecked) {
|
||||
this.updateAllowedPlan('monthly', isChecked);
|
||||
},
|
||||
toggleYearlyPlan(isChecked) {
|
||||
this.updateAllowedPlan('yearly', isChecked);
|
||||
},
|
||||
togglePortalButton(showBeacon) {
|
||||
this.settings.set('portalButton', showBeacon);
|
||||
},
|
||||
|
||||
togglePortalName(showSignupName) {
|
||||
this.settings.set('portalName', showSignupName);
|
||||
},
|
||||
|
||||
confirm() {
|
||||
return this.saveTask.perform();
|
||||
},
|
||||
|
||||
isPlanSelected(plan) {
|
||||
const allowedPlans = this.settings.get('portalPlans');
|
||||
return allowedPlans.includes(plan);
|
||||
}
|
||||
},
|
||||
|
||||
updateAllowedPlan(plan, isChecked) {
|
||||
const allowedPlans = this.settings.get('portalPlans') || [];
|
||||
|
||||
if (!isChecked) {
|
||||
this.settings.set('portalPlans', allowedPlans.filter(p => p !== plan));
|
||||
} else {
|
||||
allowedPlans.push(plan);
|
||||
this.settings.set('portalPlans', [...allowedPlans]);
|
||||
}
|
||||
},
|
||||
|
||||
saveTask: task(function* () {
|
||||
yield this.settings.save();
|
||||
this.closeModal();
|
||||
}).drop()
|
||||
});
|
@ -43,5 +43,8 @@ export default Model.extend(ValidationEngine, {
|
||||
ogDescription: attr('string'),
|
||||
ogImage: attr('string'),
|
||||
bulkEmailSettings: attr('json-string'),
|
||||
portalButton: attr('boolean'),
|
||||
portalName: attr('boolean'),
|
||||
portalPlans: attr('json-string'),
|
||||
sharedViews: attr('string')
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {
|
||||
_loadSettings() {
|
||||
if (!this._loadingPromise) {
|
||||
this._loadingPromise = this.store
|
||||
.queryRecord('setting', {type: 'blog,theme,private,members,bulk_email'})
|
||||
.queryRecord('setting', {type: 'blog,theme,private,members,bulk_email,portal'})
|
||||
.then((settings) => {
|
||||
this._loadingPromise = null;
|
||||
return settings;
|
||||
|
Loading…
Reference in New Issue
Block a user