diff --git a/ghost/admin/app/components/gh-datetime-input.js b/ghost/admin/app/components/gh-datetime-input.js index ce8d5ec88f..09e2b1b4bb 100644 --- a/ghost/admin/app/components/gh-datetime-input.js +++ b/ghost/admin/app/components/gh-datetime-input.js @@ -17,7 +17,7 @@ export default Component.extend(TextInputMixin, { didReceiveAttrs() { let datetime = this.get('datetime') || moment(); - if (!this.attrs.update) { + if (!this.get('update')) { throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`); } @@ -27,6 +27,6 @@ export default Component.extend(TextInputMixin, { focusOut() { let datetime = this.get('datetime'); - this.attrs.update(datetime); + this.get('update')(datetime); } }); diff --git a/ghost/admin/app/components/gh-ed-editor.js b/ghost/admin/app/components/gh-ed-editor.js index 1d87a6ad5f..da7626a048 100644 --- a/ghost/admin/app/components/gh-ed-editor.js +++ b/ghost/admin/app/components/gh-ed-editor.js @@ -32,7 +32,7 @@ export default TextArea.extend(EditorAPI, EditorShortcuts, EditorScroll, { this.setFocus(); - this.attrs.setEditor(this); + this.get('setEditor')(this); run.scheduleOnce('afterRender', this, this.afterRenderEvent); }, @@ -45,7 +45,7 @@ export default TextArea.extend(EditorAPI, EditorShortcuts, EditorScroll, { actions: { toggleCopyHTMLModal(generatedHTML) { - this.attrs.toggleCopyHTMLModal(generatedHTML); + this.get('toggleCopyHTMLModal')(generatedHTML); } } }); diff --git a/ghost/admin/app/components/gh-editor.js b/ghost/admin/app/components/gh-editor.js index 4383131c33..b2a247ea6c 100644 --- a/ghost/admin/app/components/gh-editor.js +++ b/ghost/admin/app/components/gh-editor.js @@ -52,8 +52,8 @@ export default Component.extend(ShortcutsMixin, { }, willDestroyElement() { - if (this.attrs.onTeardown) { - this.attrs.onTeardown(); + if (this.get('onTeardown')) { + this.get('onTeardown')(); } this.removeShortcuts(); }, diff --git a/ghost/admin/app/components/gh-fullscreen-modal.js b/ghost/admin/app/components/gh-fullscreen-modal.js index be8b3003fc..2f65580ec8 100644 --- a/ghost/admin/app/components/gh-fullscreen-modal.js +++ b/ghost/admin/app/components/gh-fullscreen-modal.js @@ -50,8 +50,8 @@ const FullScreenModalComponent = LiquidTether.extend({ actions: { close() { - if (this.attrs.close) { - return this.attrs.close(); + if (this.get('close')) { + return this.get('close')(); } return new Promise((resolve) => { @@ -60,8 +60,8 @@ const FullScreenModalComponent = LiquidTether.extend({ }, confirm() { - if (this.attrs.confirm) { - return this.attrs.confirm(); + if (this.get('confirm')) { + return this.get('confirm')(); } return new Promise((resolve) => { diff --git a/ghost/admin/app/components/gh-navitem-url-input.js b/ghost/admin/app/components/gh-navitem-url-input.js index b05198e10d..1e1cb47ecf 100644 --- a/ghost/admin/app/components/gh-navitem-url-input.js +++ b/ghost/admin/app/components/gh-navitem-url-input.js @@ -67,7 +67,7 @@ export default TextField.extend({ }, keyPress(event) { - this.attrs.clearErrors(); + this.get('clearErrors')(); // enter key if (event.keyCode === 13) { diff --git a/ghost/admin/app/components/gh-posts-list-item.js b/ghost/admin/app/components/gh-posts-list-item.js index 5b82c9d8e3..f613a6454d 100644 --- a/ghost/admin/app/components/gh-posts-list-item.js +++ b/ghost/admin/app/components/gh-posts-list-item.js @@ -50,8 +50,8 @@ export default Component.extend(ActiveLinkWrapper, { willDestroyElement() { this._super(...arguments); this.removeObserver('active', this, this.scrollIntoView); - if (this.get('post.isDeleted') && this.attrs.onDelete) { - this.attrs.onDelete(); + if (this.get('post.isDeleted') && this.get('onDelete')) { + this.get('onDelete')(); } }, diff --git a/ghost/admin/app/components/gh-tag-settings-form.js b/ghost/admin/app/components/gh-tag-settings-form.js index b91bd19a83..28de28ee28 100644 --- a/ghost/admin/app/components/gh-tag-settings-form.js +++ b/ghost/admin/app/components/gh-tag-settings-form.js @@ -108,15 +108,15 @@ export default Component.extend({ actions: { setProperty(property, value) { - this.attrs.setProperty(property, value); + this.get('setProperty')(property, value); }, setCoverImage(image) { - this.attrs.setProperty('image', image); + this.get('setProperty')('image', image); }, clearCoverImage() { - this.attrs.setProperty('image', ''); + this.get('setProperty')('image', ''); }, setUploaderReference() { @@ -132,7 +132,7 @@ export default Component.extend({ }, deleteTag() { - this.attrs.showDeleteTagModal(); + this.get('showDeleteTagModal')(); } } diff --git a/ghost/admin/app/components/gh-tag.js b/ghost/admin/app/components/gh-tag.js index 6136ea5e10..84b50d8a46 100644 --- a/ghost/admin/app/components/gh-tag.js +++ b/ghost/admin/app/components/gh-tag.js @@ -4,8 +4,8 @@ export default Ember.Component.extend({ willDestroyElement() { this._super(...arguments); - if (this.get('tag.isDeleted') && this.attrs.onDelete) { - this.attrs.onDelete(); + if (this.get('tag.isDeleted') && this.get('onDelete')) { + this.get('onDelete')(); } } }); diff --git a/ghost/admin/app/components/modals/base.js b/ghost/admin/app/components/modals/base.js index 1f8231facc..043c615352 100644 --- a/ghost/admin/app/components/modals/base.js +++ b/ghost/admin/app/components/modals/base.js @@ -49,7 +49,7 @@ export default Component.extend({ }, closeModal() { - this.attrs.closeModal(); + this.get('closeModal')(); } } }); diff --git a/ghost/admin/app/components/modals/delete-tag.js b/ghost/admin/app/components/modals/delete-tag.js index 9ddd21dbd5..921da5bc8d 100644 --- a/ghost/admin/app/components/modals/delete-tag.js +++ b/ghost/admin/app/components/modals/delete-tag.js @@ -18,7 +18,7 @@ export default ModalComponent.extend({ confirm() { this.set('submitting', true); - this.attrs.confirm().finally(() => { + this.get('confirm')().finally(() => { this.send('closeModal'); }); } diff --git a/ghost/admin/app/components/modals/delete-user.js b/ghost/admin/app/components/modals/delete-user.js index 7cccf0be55..85dd65e1a6 100644 --- a/ghost/admin/app/components/modals/delete-user.js +++ b/ghost/admin/app/components/modals/delete-user.js @@ -10,7 +10,7 @@ export default ModalComponent.extend({ confirm() { this.set('submitting', true); - this.attrs.confirm().finally(() => { + this.get('confirm')().finally(() => { this.send('closeModal'); }); } diff --git a/ghost/admin/app/components/modals/leave-editor.js b/ghost/admin/app/components/modals/leave-editor.js index 498c2a37ea..43692de940 100644 --- a/ghost/admin/app/components/modals/leave-editor.js +++ b/ghost/admin/app/components/modals/leave-editor.js @@ -3,7 +3,7 @@ import ModalComponent from 'ghost/components/modals/base'; export default ModalComponent.extend({ actions: { confirm() { - this.attrs.confirm().finally(() => { + this.get('confirm').finally(() => { this.send('closeModal'); }); } diff --git a/ghost/admin/app/components/modals/transfer-owner.js b/ghost/admin/app/components/modals/transfer-owner.js index 117dcf193d..d2adaff12a 100644 --- a/ghost/admin/app/components/modals/transfer-owner.js +++ b/ghost/admin/app/components/modals/transfer-owner.js @@ -8,7 +8,7 @@ export default ModalComponent.extend({ confirm() { this.set('submitting', true); - this.attrs.confirm().finally(() => { + this.get('confirm')().finally(() => { this.send('closeModal'); }); } diff --git a/ghost/admin/app/mixins/ed-editor-scroll.js b/ghost/admin/app/mixins/ed-editor-scroll.js index 24cfe9da31..355e7be99a 100644 --- a/ghost/admin/app/mixins/ed-editor-scroll.js +++ b/ghost/admin/app/mixins/ed-editor-scroll.js @@ -61,7 +61,7 @@ export default Mixin.create({ */ scrollHandler() { this.set('scrollThrottle', run.throttle(this, () => { - this.attrs.updateScrollInfo(this.getScrollInfo()); + this.get('updateScrollInfo')(this.getScrollInfo()); }, 10)); }, diff --git a/ghost/admin/app/utils/link-component.js b/ghost/admin/app/utils/link-component.js index 1608957efe..2edcec4ba7 100644 --- a/ghost/admin/app/utils/link-component.js +++ b/ghost/admin/app/utils/link-component.js @@ -6,8 +6,8 @@ LinkComponent.reopen({ active: computed('attrs.params', '_routing.currentState', function () { let isActive = this._super(...arguments); - if (typeof this.attrs.alternateActive === 'function') { - this.attrs.alternateActive(isActive); + if (typeof this.get('alternateActive') === 'function') { + this.get('alternateActive')(isActive); } return isActive; diff --git a/ghost/admin/tests/integration/components/transfer-owner-test.js b/ghost/admin/tests/integration/components/transfer-owner-test.js new file mode 100644 index 0000000000..77ccad7960 --- /dev/null +++ b/ghost/admin/tests/integration/components/transfer-owner-test.js @@ -0,0 +1,39 @@ +/* jshint expr:true */ +import { expect } from 'chai'; +import { + describeComponent, + it +} from 'ember-mocha'; +import hbs from 'htmlbars-inline-precompile'; +import Ember from 'ember'; +import sinon from 'sinon'; + +const {RSVP, run} = Ember; + +describeComponent( + 'transfer-owner', + 'Integration: Component: modals/transfer-owner', + { + integration: true + }, + function() { + it('triggers confirm action', function() { + let confirm = sinon.stub(); + let closeModal = sinon.spy(); + + confirm.returns(RSVP.resolve({})); + + this.on('confirm', confirm); + this.on('closeModal', closeModal); + + this.render(hbs`{{modals/transfer-owner confirm=(action 'confirm') closeModal=(action 'closeModal')}}`); + + run(() => { + this.$('.btn.btn-red').click(); + }); + + expect(confirm.calledOnce, 'confirm called').to.be.true; + expect(closeModal.calledOnce, 'closeModal called').to.be.true; + }); + } +);