mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-08 04:03:12 +03:00
6dabb84e0a
closes https://github.com/TryGhost/Ghost/issues/8269 - swaps the usage of our custom `gh-dropdown` component in the user menu dropdown for the `ember-wormhole` based `ember-basic-dropdown` that is used elsewhere in the app and will fully replace `gh-dropdown` in the future - adds `gh-basic-dropdown` component that extends from `ember-basic-dropdown` and hooks into our `dropdown` service so that we can programatically close dropdowns from disparate areas of the app - modifies the `body-event-listener` mixin to pass the click event through to it's consumers - modifies the `bodyClick` handler in the `dropdown` service to check if the click actually originated from an ember-basic-dropdown element - this body click handler will go away once we've fully switched to `gh-basic-dropdown` - adds `ember-native-dom-helpers` to provide consistency between acceptance and integration tests (this is the start of another refactor, eventually this addon will disappear as part of ember's [grand testing unification project](https://github.com/rwjblue/rfcs/blob/42/text/0000-grand-testing-unification.md))
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
import Controller from 'ember-controller';
|
|
import computed from 'ember-computed';
|
|
import injectService from 'ember-service/inject';
|
|
|
|
export default Controller.extend({
|
|
dropdown: injectService(),
|
|
session: injectService(),
|
|
|
|
showNavMenu: computed('currentPath', 'session.isAuthenticated', 'session.user.isFulfilled', function () {
|
|
// we need to defer showing the navigation menu until the session.user
|
|
// promise has fulfilled so that gh-user-can-admin has the correct data
|
|
if (!this.get('session.isAuthenticated') || !this.get('session.user.isFulfilled')) {
|
|
return false;
|
|
}
|
|
|
|
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
|
|
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
|
|
}),
|
|
|
|
topNotificationCount: 0,
|
|
showMobileMenu: false,
|
|
showSettingsMenu: false,
|
|
showMarkdownHelpModal: false,
|
|
|
|
autoNav: false,
|
|
autoNavOpen: computed('autoNav', {
|
|
get() {
|
|
return false;
|
|
},
|
|
set(key, value) {
|
|
if (this.get('autoNav')) {
|
|
return value;
|
|
}
|
|
return false;
|
|
}
|
|
}),
|
|
|
|
actions: {
|
|
topNotificationChange(count) {
|
|
this.set('topNotificationCount', count);
|
|
},
|
|
|
|
toggleAutoNav() {
|
|
this.toggleProperty('autoNav');
|
|
},
|
|
|
|
openAutoNav() {
|
|
this.set('autoNavOpen', true);
|
|
},
|
|
|
|
closeAutoNav() {
|
|
if (this.get('autoNavOpen')) {
|
|
this.get('dropdown').closeDropdowns();
|
|
}
|
|
this.set('autoNavOpen', false);
|
|
},
|
|
|
|
closeMobileMenu() {
|
|
this.set('showMobileMenu', false);
|
|
}
|
|
}
|
|
});
|