Ghost/ghost/admin/app/controllers/settings/members-access.js
Kevin Ansfield 889f90f494 Added "Nobody" option to members signup access
refs https://github.com/TryGhost/Team/issues/579

- adds "Nobody" option that will set `members_signup_access` setting to `'none'`
- when selected also sets `default_content_visibility` setting to `'public'`, expands it if collapsed and disables other options (that setting doesn't make sense when members is disabled, individual post access can still be set manually if needed)
2021-04-19 16:37:00 +01:00

66 lines
1.7 KiB
JavaScript

import Controller from '@ember/controller';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators';
import {tracked} from '@glimmer/tracking';
export default class MembersAccessController extends Controller {
@service settings;
@tracked showLeaveSettingsModal = false;
@tracked signupAccessOpen = false;
@tracked postAccessOpen = false;
leaveRoute(transition) {
if (this.settings.get('hasDirtyAttributes')) {
transition.abort();
this.leaveSettingsTransition = transition;
this.showLeaveSettingsModal = true;
}
}
@action
async confirmLeave() {
this.settings.rollbackAttributes();
this.showLeaveSettingsModal = false;
this.leaveSettingsTransition.retry();
}
@action
cancelLeave() {
this.showLeaveSettingsModal = false;
this.leaveSettingsTransition = null;
}
@action
toggleSignupAccess() {
this.signupAccessOpen = !this.signupAccessOpen;
}
@action
togglePostAccess() {
this.postAccessOpen = !this.postAccessOpen;
}
@action
setDefaultContentVisibility(value) {
if (this.settings.get('membersSignupAccess') !== 'none') {
this.settings.set('defaultContentVisibility', value);
}
}
@action
setSignupAccess(value) {
this.settings.set('membersSignupAccess', value);
if (value === 'none') {
this.settings.set('defaultContentVisibility', 'public');
this.postAccessOpen = true;
}
}
@task({drop: true})
*saveSettingsTask() {
return yield this.settings.save();
}
}