forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Licensing plugin and XPackInfo uses the same license data (elastic#52507) * convert xpackinfo to TS * use NP Licensing plugin in XPackInfo * update mocks * put license regresh hack back. otherwise new license won't be re-fetched when signature changed. was deleted by mistake * add functional test for legacy xpackmain * declare setup types on client & server explicitly * rename mock license --> licensing to match plugin name * add tests for createLicensePoller * fix type error * adopt tests for xpack_info * createXPackInfo uses new platform API * put back error mute * address comments * fix renamed import * address comment * update tests to reduce delays * deprecate xpack.xpack_main.xpack_api_polling_frequency_millis * use snake_case in config * fix wrong import
- Loading branch information
Showing
40 changed files
with
736 additions
and
774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/legacy/plugins/xpack_main/public/hacks/check_xpack_info_change.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { identity } from 'lodash'; | ||
import { uiModules } from 'ui/modules'; | ||
import { Path } from 'plugins/xpack_main/services/path'; | ||
import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; | ||
import { xpackInfoSignature } from 'plugins/xpack_main/services/xpack_info_signature'; | ||
|
||
const module = uiModules.get('xpack_main', []); | ||
|
||
module.factory('checkXPackInfoChange', ($q, Private, $injector) => { | ||
/** | ||
* Intercept each network response to look for the kbn-xpack-sig header. | ||
* When that header is detected, compare its value with the value cached | ||
* in the browser storage. When the value is new, call `xpackInfo.refresh()` | ||
* so that it will pull down the latest x-pack info | ||
* | ||
* @param {object} response - the angular $http response object | ||
* @param {function} handleResponse - callback, expects to receive the response | ||
* @return | ||
*/ | ||
function interceptor(response, handleResponse) { | ||
if (Path.isUnauthenticated()) { | ||
return handleResponse(response); | ||
} | ||
|
||
const currentSignature = response.headers('kbn-xpack-sig'); | ||
const cachedSignature = xpackInfoSignature.get(); | ||
|
||
if (currentSignature && cachedSignature !== currentSignature) { | ||
// Signature from the server differ from the signature of our | ||
// cached info, so we need to refresh it. | ||
// Intentionally swallowing this error | ||
// because nothing catches it and it's an ugly console error. | ||
xpackInfo.refresh($injector).catch(() => {}); | ||
} | ||
|
||
return handleResponse(response); | ||
} | ||
|
||
return { | ||
response: response => interceptor(response, identity), | ||
responseError: response => interceptor(response, $q.reject), | ||
}; | ||
}); | ||
|
||
module.config($httpProvider => { | ||
$httpProvider.interceptors.push('checkXPackInfoChange'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.