mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
e01ffa3620
no issue - review use of Ember core hooks and add a call to `this._super` if missing - fix a few occurrences of using the wrong component lifecycle hooks that could result in multiple/duplicate event handlers being attached `_super` should always be called when overriding Ember's base hooks so that core functionality or app functionality added through extensions, mixins or addons is not lost. This is important as it guards against issues arising from later refactorings or core changes. As example of lost functionality, there were a number of routes that extended from `AuthenticatedRoute` but then overrode the `beforeModel` hook without calling `_super` which meant that the route was no longer treated as authenticated.
36 lines
925 B
JavaScript
36 lines
925 B
JavaScript
import Ember from 'ember';
|
|
|
|
const {Component, computed} = Ember;
|
|
|
|
// See gh-tabs-manager.js for use
|
|
export default Component.extend({
|
|
tabsManager: computed(function () {
|
|
return this.nearestWithProperty('isTabsManager');
|
|
}),
|
|
|
|
active: computed('tabsManager.activeTab', function () {
|
|
return this.get('tabsManager.activeTab') === this;
|
|
}),
|
|
|
|
index: computed('tabsManager.tabs.[]', function () {
|
|
return this.get('tabsManager.tabs').indexOf(this);
|
|
}),
|
|
|
|
// Select on click
|
|
click() {
|
|
this.get('tabsManager').select(this);
|
|
},
|
|
|
|
willRender() {
|
|
this._super(...arguments);
|
|
// register the tabs with the tab manager
|
|
this.get('tabsManager').registerTab(this);
|
|
},
|
|
|
|
willDestroyElement() {
|
|
this._super(...arguments);
|
|
// unregister the tabs with the tab manager
|
|
this.get('tabsManager').unregisterTab(this);
|
|
}
|
|
});
|