mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 08:31:43 +03:00
404d3c44cf
no issue The full edit newsletter form with all the settings, design options, and preview felt quite overwhelming when the only piece of data that's required to create a newsletter is the name. - re-organised the newsletter modal components by renaming `modals/edit-newlsetter` to `modals/newsletters` to better represent the full suite of modals that are used in newsletter management - added a `modals/newsletters/new` component containing a minimal form with name/description/opt-in-existing fields - switched the `new-newsletter` route to open the new modal rather than the previous dual-purpose edit modal - moved message about newsletter creation into the create modal and dropped the separate create confirmation modal - dropped unnecessary unsaved-changes confirmation - removed the now-unused opt-in-existing behaviour from the edit newsletter modal Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class VerifyNewsletterEmail extends Component {
|
|
@service ajax;
|
|
@service ghostPaths;
|
|
@service router;
|
|
@service store;
|
|
|
|
@tracked error = null;
|
|
@tracked newsletter = null;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.verifyEmailTask.perform(this.args.data.token);
|
|
|
|
this.router.on('routeDidChange', this.handleRouteChange);
|
|
}
|
|
|
|
willDestroy() {
|
|
super.willDestroy(...arguments);
|
|
this.router.off('routeDidChange', this.handleRouteChange);
|
|
}
|
|
|
|
@task
|
|
*verifyEmailTask(token) {
|
|
try {
|
|
const url = this.ghostPaths.url.api('newsletters', 'verifications');
|
|
|
|
const response = yield this.ajax.put(url, {data: {token}});
|
|
|
|
if (response.newsletters) {
|
|
this.store.pushPayload('newsletter', response);
|
|
const newsletter = this.store.peekRecord('newsletter', response.newsletters[0].id);
|
|
this.newsletter = newsletter;
|
|
}
|
|
} catch (e) {
|
|
this.error = e.message;
|
|
}
|
|
}
|
|
|
|
@action
|
|
handleRouteChange() {
|
|
this.args.close();
|
|
}
|
|
}
|