mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Route from 'consul-ui/routing/route';
|
|
import { action } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
|
|
|
export default class ApplicationRoute extends Route.extend(WithBlockingActions) {
|
|
@service('client/http') client;
|
|
@service('env') env;
|
|
@service() hcp;
|
|
|
|
data;
|
|
|
|
async model() {
|
|
if (this.env.var('CONSUL_ACLS_ENABLED')) {
|
|
await this.hcp.updateTokenIfNecessary(this.env.var('CONSUL_HTTP_TOKEN'));
|
|
}
|
|
return {};
|
|
}
|
|
|
|
@action
|
|
onClientChanged(e) {
|
|
let data = e.data;
|
|
if (data === '') {
|
|
data = { blocking: true };
|
|
}
|
|
// this.data is always undefined first time round and its the 'first read'
|
|
// of the value so we don't need to abort anything
|
|
if (typeof this.data === 'undefined') {
|
|
this.data = Object.assign({}, data);
|
|
return;
|
|
}
|
|
if (this.data.blocking === true && data.blocking === false) {
|
|
this.client.abort();
|
|
}
|
|
this.data = Object.assign({}, data);
|
|
}
|
|
|
|
@action
|
|
error(e, transition) {
|
|
// TODO: Normalize all this better
|
|
let error = {
|
|
status: e.code || e.statusCode || '',
|
|
message: e.message || e.detail || 'Error',
|
|
};
|
|
if (e.errors && e.errors[0]) {
|
|
error = e.errors[0];
|
|
error.message = error.message || error.title || error.detail || 'Error';
|
|
}
|
|
if (error.status === '') {
|
|
error.message = 'Error';
|
|
}
|
|
this.controllerFor('application').setProperties({ error: error });
|
|
return true;
|
|
}
|
|
}
|