From 7e3412ce8ed3f21f5fc167744c7dc3ce89b65914 Mon Sep 17 00:00:00 2001 From: Naz Gargol Date: Thu, 26 Sep 2019 15:58:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Removed=20all=20subscriber=20fea?= =?UTF-8?q?ture=20related=20code=20(#1337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Ghost/pull/11153 - Removed all subscriber feature related code - The feature is being substituted by members --- ghost/admin/app/components/gh-feature-flag.js | 3 - .../app/components/modal-delete-subscriber.js | 20 -- .../components/modal-import-subscribers.js | 43 ---- .../app/components/modal-new-subscriber.js | 47 ---- ghost/admin/app/controllers/subscribers.js | 116 ---------- .../app/controllers/subscribers/import.js | 19 -- ghost/admin/app/helpers/event-name.js | 6 +- .../app/helpers/subscribers-query-params.js | 21 -- .../app/helpers/subscribers-sort-icon.js | 14 -- ghost/admin/app/mixins/validation-engine.js | 2 - ghost/admin/app/models/subscriber.js | 22 -- ghost/admin/app/router.js | 5 - ghost/admin/app/routes/subscribers.js | 35 --- ghost/admin/app/routes/subscribers/import.js | 4 - ghost/admin/app/routes/subscribers/new.js | 38 ---- ghost/admin/app/serializers/subscriber.js | 20 -- ghost/admin/app/services/feature.js | 1 - ghost/admin/app/styles/app-dark.css | 5 - ghost/admin/app/styles/app.css | 1 - .../admin/app/styles/layouts/subscribers.css | 105 --------- .../app/templates/components/gh-nav-menu.hbs | 3 - .../components/modal-delete-subscriber.hbs | 19 -- .../components/modal-import-subscribers.hbs | 47 ---- .../components/modal-new-subscriber.hbs | 44 ---- ghost/admin/app/templates/settings/labs.hbs | 14 -- ghost/admin/app/templates/subscribers.hbs | 100 --------- .../app/templates/subscribers/import.hbs | 4 - ghost/admin/app/templates/subscribers/new.hbs | 5 - ghost/admin/mirage/config.js | 2 - ghost/admin/mirage/config/subscribers.js | 50 ----- ghost/admin/mirage/factories/subscriber.js | 20 -- ghost/admin/mirage/fixtures/configs.js | 2 +- ghost/admin/mirage/fixtures/settings.js | 2 +- ghost/admin/mirage/scenarios/default.js | 1 - .../tests/acceptance/error-handling-test.js | 13 -- .../tests/acceptance/subscribers-test.js | 208 ------------------ .../tests/unit/validators/subscriber-test.js | 73 ------ 37 files changed, 3 insertions(+), 1131 deletions(-) delete mode 100644 ghost/admin/app/components/modal-delete-subscriber.js delete mode 100644 ghost/admin/app/components/modal-import-subscribers.js delete mode 100644 ghost/admin/app/components/modal-new-subscriber.js delete mode 100644 ghost/admin/app/controllers/subscribers.js delete mode 100644 ghost/admin/app/controllers/subscribers/import.js delete mode 100644 ghost/admin/app/helpers/subscribers-query-params.js delete mode 100644 ghost/admin/app/helpers/subscribers-sort-icon.js delete mode 100644 ghost/admin/app/models/subscriber.js delete mode 100644 ghost/admin/app/routes/subscribers.js delete mode 100644 ghost/admin/app/routes/subscribers/import.js delete mode 100644 ghost/admin/app/routes/subscribers/new.js delete mode 100644 ghost/admin/app/serializers/subscriber.js delete mode 100644 ghost/admin/app/styles/layouts/subscribers.css delete mode 100644 ghost/admin/app/templates/components/modal-delete-subscriber.hbs delete mode 100644 ghost/admin/app/templates/components/modal-import-subscribers.hbs delete mode 100644 ghost/admin/app/templates/components/modal-new-subscriber.hbs delete mode 100644 ghost/admin/app/templates/subscribers.hbs delete mode 100644 ghost/admin/app/templates/subscribers/import.hbs delete mode 100644 ghost/admin/app/templates/subscribers/new.hbs delete mode 100644 ghost/admin/mirage/config/subscribers.js delete mode 100644 ghost/admin/mirage/factories/subscriber.js delete mode 100644 ghost/admin/tests/acceptance/subscribers-test.js delete mode 100644 ghost/admin/tests/unit/validators/subscriber-test.js diff --git a/ghost/admin/app/components/gh-feature-flag.js b/ghost/admin/app/components/gh-feature-flag.js index 820bd4a872..7aac678593 100644 --- a/ghost/admin/app/components/gh-feature-flag.js +++ b/ghost/admin/app/components/gh-feature-flag.js @@ -20,9 +20,6 @@ const FeatureFlagComponent = Component.extend({ return this._flagValue; }, set(key, value) { - if (this.flag === 'members' && value === true) { - this.set(`feature.subscribers`, false); - } return this.set(`feature.${this.flag}`, value); } }), diff --git a/ghost/admin/app/components/modal-delete-subscriber.js b/ghost/admin/app/components/modal-delete-subscriber.js deleted file mode 100644 index 25e623d703..0000000000 --- a/ghost/admin/app/components/modal-delete-subscriber.js +++ /dev/null @@ -1,20 +0,0 @@ -import ModalComponent from 'ghost-admin/components/modal-base'; -import {alias} from '@ember/object/computed'; -import {task} from 'ember-concurrency'; - -export default ModalComponent.extend({ - // Allowed actions - confirm: () => {}, - - subscriber: alias('model'), - - actions: { - confirm() { - this.deleteSubscriber.perform(); - } - }, - - deleteSubscriber: task(function* () { - yield this.confirm(); - }).drop() -}); diff --git a/ghost/admin/app/components/modal-import-subscribers.js b/ghost/admin/app/components/modal-import-subscribers.js deleted file mode 100644 index b0e905bc5c..0000000000 --- a/ghost/admin/app/components/modal-import-subscribers.js +++ /dev/null @@ -1,43 +0,0 @@ -import ModalComponent from 'ghost-admin/components/modal-base'; -import ghostPaths from 'ghost-admin/utils/ghost-paths'; -import {computed} from '@ember/object'; - -export default ModalComponent.extend({ - labelText: 'Select or drag-and-drop a CSV File', - - response: null, - closeDisabled: false, - - // Allowed actions - confirm: () => {}, - - uploadUrl: computed(function () { - return `${ghostPaths().apiRoot}/subscribers/csv/`; - }), - - actions: { - uploadStarted() { - this.set('closeDisabled', true); - }, - - uploadFinished() { - this.set('closeDisabled', false); - }, - - uploadSuccess(response) { - this.set('response', response.meta.stats); - // invoke the passed in confirm action - this.confirm(); - }, - - confirm() { - // noop - we don't want the enter key doing anything - }, - - closeModal() { - if (!this.closeDisabled) { - this._super(...arguments); - } - } - } -}); diff --git a/ghost/admin/app/components/modal-new-subscriber.js b/ghost/admin/app/components/modal-new-subscriber.js deleted file mode 100644 index 03b8fdd02f..0000000000 --- a/ghost/admin/app/components/modal-new-subscriber.js +++ /dev/null @@ -1,47 +0,0 @@ -import ModalComponent from 'ghost-admin/components/modal-base'; -import {alias} from '@ember/object/computed'; -import {A as emberA} from '@ember/array'; -import {isInvalidError} from 'ember-ajax/errors'; -import {task} from 'ember-concurrency'; - -export default ModalComponent.extend({ - - subscriber: alias('model'), - - actions: { - updateEmail(newEmail) { - this.set('subscriber.email', newEmail); - this.set('subscriber.hasValidated', emberA()); - this.get('subscriber.errors').clear(); - }, - - confirm() { - this.addSubscriber.perform(); - } - }, - - addSubscriber: task(function* () { - try { - yield this.confirm(); - this.send('closeModal'); - } catch (error) { - // TODO: server-side validation errors should be serialized - // properly so that errors are added to model.errors automatically - if (error && isInvalidError(error)) { - let [firstError] = error.payload.errors; - let {context} = firstError; - - if (context && context.match(/email/i)) { - this.get('subscriber.errors').add('email', context); - this.get('subscriber.hasValidated').pushObject('email'); - return; - } - } - - // route action so it should bubble up to the global error handler - if (error) { - throw error; - } - } - }).drop() -}); diff --git a/ghost/admin/app/controllers/subscribers.js b/ghost/admin/app/controllers/subscribers.js deleted file mode 100644 index 2b75397978..0000000000 --- a/ghost/admin/app/controllers/subscribers.js +++ /dev/null @@ -1,116 +0,0 @@ -import $ from 'jquery'; -import Controller from '@ember/controller'; -import ghostPaths from 'ghost-admin/utils/ghost-paths'; -import moment from 'moment'; -import {computed} from '@ember/object'; -import {inject as service} from '@ember/service'; -import {task} from 'ember-concurrency'; - -const orderMap = { - email: 'email', - created_at: 'createdAtUTC', - status: 'status' -}; - -/* eslint-disable ghost/ember/alias-model-in-controller */ -export default Controller.extend({ - session: service(), - - queryParams: ['order', 'direction'], - order: 'created_at', - direction: 'desc', - - subscribers: null, - subscriberToDelete: null, - - init() { - this._super(...arguments); - this.set('subscribers', this.store.peekAll('subscriber')); - }, - - filteredSubscribers: computed('subscribers.@each.{email,createdAtUTC}', function () { - return this.subscribers.toArray().filter((subscriber) => { - return !subscriber.isNew && !subscriber.isDeleted; - }); - }), - - sortedSubscribers: computed('order', 'direction', 'subscribers.@each.{email,createdAtUTC,status}', function () { - let {filteredSubscribers, order, direction} = this; - - let sorted = filteredSubscribers.sort((a, b) => { - let values = [a.get(orderMap[order]), b.get(orderMap[order])]; - - if (direction === 'desc') { - values = values.reverse(); - } - - if (typeof values[0] === 'string') { - return values[0].localeCompare(values[1], undefined, {ignorePunctuation: true}); - } - - if (typeof values[0] === 'object' && values[0]._isAMomentObject) { - return values[0].valueOf() - values[1].valueOf(); - } - - return values[0] - values[1]; - }); - - return sorted; - }), - - actions: { - deleteSubscriber(subscriber) { - this.set('subscriberToDelete', subscriber); - }, - - confirmDeleteSubscriber() { - let subscriber = this.subscriberToDelete; - - return subscriber.destroyRecord().then(() => { - this.set('subscriberToDelete', null); - }); - }, - - cancelDeleteSubscriber() { - this.set('subscriberToDelete', null); - }, - - exportData() { - let exportUrl = ghostPaths().url.api('subscribers/csv'); - let accessToken = this.get('session.data.authenticated.access_token'); - let downloadURL = `${exportUrl}?access_token=${accessToken}`; - let iframe = $('#iframeDownload'); - - if (iframe.length === 0) { - iframe = $('