Enterprise Search: handle optional spaces plugin (#153230)

## Summary

Updated spaces to be an optional plugin
This commit is contained in:
Rodney Norris 2023-03-27 09:51:25 -04:00 committed by GitHub
parent b616950d07
commit fd8508a4f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 7 deletions

View file

@ -12,7 +12,6 @@
],
"requiredPlugins": [
"features",
"spaces",
"security",
"licensing",
"data",
@ -26,10 +25,11 @@
"embeddable",
],
"optionalPlugins": [
"usageCollection",
"home",
"customIntegrations",
"ml"
"home",
"ml",
"spaces",
"usageCollection"
],
"requiredBundles": [
"kibanaReact",

View file

@ -118,6 +118,16 @@ describe('checkAccess', () => {
expect(expectedError).toEqual('Error');
});
});
describe('when spaces plugin is not available', () => {
it('should not throw', async () => {
await expect(checkAccess({ ...mockDependencies, spaces: undefined })).resolves.toEqual({
hasAppSearchAccess: false,
hasSearchEnginesAccess: false,
hasWorkplaceSearchAccess: false,
});
});
});
});
describe('when the space is enabled', () => {

View file

@ -18,7 +18,7 @@ import { callEnterpriseSearchConfigAPI } from './enterprise_search_config_api';
interface CheckAccess {
request: KibanaRequest;
security: SecurityPluginSetup;
spaces: SpacesPluginStart;
spaces?: SpacesPluginStart;
config: ConfigType;
log: Logger;
}
@ -54,7 +54,7 @@ export const checkAccess = async ({
}
// We can only retrieve the active space when security is enabled and the request has already been authenticated
const attemptSpaceRetrieval = request.auth.isAuthenticated;
const attemptSpaceRetrieval = request.auth.isAuthenticated && !!spaces;
let allowedAtSpace = false;
if (attemptSpaceRetrieval) {

View file

@ -89,7 +89,7 @@ interface PluginsSetup {
}
interface PluginsStart {
spaces: SpacesPluginStart;
spaces?: SpacesPluginStart;
security: SecurityPluginStart;
data: DataPluginStart;
}