[ML] Fixing ml when spaces feature is disabled (#42564) (#42588)

* [ML] Fixing ml when spaces feature is disabled

* correcting grammar in comment

* fixing typo
This commit is contained in:
James Gowdy 2019-08-05 12:43:39 +01:00 committed by GitHub
parent 97d6773fda
commit 7a021fde0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -26,7 +26,7 @@ interface Response {
export function privilegesProvider(
callWithRequest: callWithRequestType,
xpackMainPlugin: XPackMainPlugin,
isMlEnabled: () => Promise<boolean>
isMlEnabledInSpace: () => Promise<boolean>
) {
const { isUpgradeInProgress } = upgradeCheckProvider(callWithRequest);
async function getPrivileges(): Promise<Response> {
@ -37,7 +37,7 @@ export function privilegesProvider(
const securityDisabled = isSecurityDisabled(xpackMainPlugin);
const license = checkLicense(xpackMainPlugin.info);
const isPlatinumOrTrialLicense = license.licenseType === LICENSE_TYPE.FULL;
const mlFeatureEnabledInSpace = await isMlEnabled();
const mlFeatureEnabledInSpace = await isMlEnabledInSpace();
const setGettingPrivileges = isPlatinumOrTrialLicense
? setFullGettingPrivileges

View file

@ -98,8 +98,12 @@ export function systemRoutes({
async handler(request) {
const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request);
try {
const { isMlEnabled } = spacesUtilsProvider(spacesPlugin, request, config);
const { getPrivileges } = privilegesProvider(callWithRequest, xpackMainPlugin, isMlEnabled);
const spacesFeature = xpackMainPlugin.info.feature('spaces');
const { isMlEnabledInSpace } = spacesFeature.isEnabled() ?
spacesUtilsProvider(spacesPlugin, request, config) :
{ isMlEnabledInSpace: async () => true }; // if spaces is disabled force isMlEnabledInSpace to be true
const { getPrivileges } = privilegesProvider(callWithRequest, xpackMainPlugin, isMlEnabledInSpace);
return await getPrivileges();
} catch (error) {
return wrapError(error);