Skip to content

Commit

Permalink
Make spaces dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
iblancof committed Oct 10, 2024
1 parent d880fb6 commit a2239e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 2 additions & 3 deletions x-pack/plugins/observability_solution/inventory/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
"features",
"unifiedSearch",
"data",
"share",
"spaces"
"share"
],
"requiredBundles": ["kibanaReact"],
"optionalPlugins": [],
"optionalPlugins": ["spaces"],
"extraPublicDirs": []
}
}
24 changes: 14 additions & 10 deletions x-pack/plugins/observability_solution/inventory/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { INVENTORY_APP_ID } from '@kbn/deeplinks-observability/constants';
import { i18n } from '@kbn/i18n';
import type { Logger } from '@kbn/logging';
import { from, map, mergeMap } from 'rxjs';
import { from, map, mergeMap, of } from 'rxjs';
import { createCallInventoryAPI } from './api';
import { TelemetryService } from './services/telemetry/telemetry_service';
import { InventoryServices } from './services/types';
Expand Down Expand Up @@ -57,15 +57,19 @@ export class InventoryPlugin
const getStartServices = coreSetup.getStartServices();

const hideInventory$ = from(getStartServices).pipe(
mergeMap(([coreStart, pluginsStart]) =>
from(pluginsStart.spaces.getActiveSpace()).pipe(
map(
(space) =>
space.disabledFeatures.includes(INVENTORY_APP_ID) ||
!coreStart.application.capabilities.inventory.show
)
)
)
mergeMap(([coreStart, pluginsStart]) => {
if (pluginsStart.spaces) {
return from(pluginsStart.spaces.getActiveSpace()).pipe(
map(
(space) =>
space.disabledFeatures.includes(INVENTORY_APP_ID) ||
!coreStart.application.capabilities.inventory.show
)
);
}

return of(!coreStart.application.capabilities.inventory.show);
})
);

const sections$ = hideInventory$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface InventoryStartDependencies {
data: DataPublicPluginStart;
entityManager: EntityManagerPublicPluginStart;
share: SharePluginStart;
spaces: SpacesPluginStart;
spaces?: SpacesPluginStart;
}

export interface InventoryPublicSetup {}
Expand Down

0 comments on commit a2239e0

Please sign in to comment.