Files
threshold-ui/ui/desktop/app/initializers/cluster-url.js
T

34 lines
940 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { getOwner } from '@ember/application';
export function initialize(registry) {
// Lookup the application route
const ApplicationRoute = registry.resolveRegistration
? registry.resolveRegistration('route:application')
: registry.resolve('route:application');
ApplicationRoute.reopen({
init() {
this._super(...arguments);
const originalBeforeModel = this.beforeModel;
2022-07-27 10:25:01 -07:00
// Override the beforeModel hook and initialize the clusterUrl
2021-03-05 17:49:47 -05:00
this.beforeModel = async function () {
2022-07-27 10:25:01 -07:00
const clusterUrl = getOwner(this).lookup('service:clusterUrl');
return clusterUrl.updateClusterUrl().then(
() => originalBeforeModel.apply(this, arguments),
() => originalBeforeModel.apply(this, arguments)
);
};
},
});
}
export default {
after: 'ember-simple-auth',
2021-03-05 17:49:47 -05:00
initialize,
};