Skip to content

Commit

Permalink
Make infra plugin optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Sep 13, 2021
1 parent be8bc70 commit ecf4b7c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ shareMock.url.locators.get = (id: IdKey) => ({

export const getAppContextMock = () => ({
isReadOnlyMode: false,
isInfraPluginAvailable: true,
kibanaVersionInfo: {
currentMajor: mockKibanaSemverVersion.major,
prevMajor: mockKibanaSemverVersion.major - 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,20 @@ describe('Overview - Fix deprecation logs step', () => {
);
});

test(`Doesn't show observability app link if infra app is not available`, async () => {
await act(async () => {
testBed = await setupOverviewPage({
isInfraPluginAvailable: false,
});
});

const { component, exists } = testBed;

component.update();

expect(exists('viewObserveLogs')).toBe(false);
});

test('Has a link to see logs in discover app', async () => {
await act(async () => {
testBed = await setupOverviewPage();
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/upgrade_assistant/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"githubTeam": "kibana-stack-management"
},
"configPath": ["xpack", "upgrade_assistant"],
"requiredPlugins": ["management", "data", "licensing", "features", "infra", "share"],
"optionalPlugins": ["usageCollection", "cloud"],
"requiredPlugins": ["management", "data", "licensing", "features", "share"],
"optionalPlugins": ["usageCollection", "cloud", "infra"],
"requiredBundles": ["esUiShared", "kibanaReact", "kibanaUtils"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,26 @@ const ObservabilityAppLink: FunctionComponent<Props> = ({ checkpoint }) => {
};

export const ExternalLinks: FunctionComponent<Props> = ({ checkpoint }) => {
const { isInfraPluginAvailable } = useAppContext();

return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiPanel>
<EuiText size="s">
<p>
<FormattedMessage
id="xpack.upgradeAssistant.overview.observe.observabilityDescription"
defaultMessage="Get insight into which deprecated APIs are being used and what applications you need to update."
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<ObservabilityAppLink checkpoint={checkpoint} />
</EuiPanel>
</EuiFlexItem>
{isInfraPluginAvailable && (
<EuiFlexItem>
<EuiPanel>
<EuiText size="s">
<p>
<FormattedMessage
id="xpack.upgradeAssistant.overview.observe.observabilityDescription"
defaultMessage="Get insight into which deprecated APIs are being used and what applications you need to update."
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<ObservabilityAppLink checkpoint={checkpoint} />
</EuiPanel>
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiPanel>
<EuiText size="s">
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/upgrade_assistant/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UpgradeAssistantUIPlugin
title: pluginName,
order: 1,
async mount(params) {
const [coreStart, { data }] = await coreSetup.getStartServices();
const [coreStart, { data, ...plugins }] = await coreSetup.getStartServices();

const {
chrome: { docTitle },
Expand All @@ -53,6 +53,10 @@ export class UpgradeAssistantUIPlugin
const appDependencies: AppDependencies = {
kibanaVersionInfo,
isReadOnlyMode: readonly,
// Infra plugin doesnt export anything as a public interface. So the only
// way we have at this stage for checking if the plugin is available or not
// is by checking if the startServices has the `infra` key.
isInfraPluginAvailable: plugins.hasOwnProperty('infra'),
plugins: {
cloud,
share,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/upgrade_assistant/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface StartDependencies {

export interface AppDependencies {
isReadOnlyMode: boolean;
isInfraPluginAvailable: boolean;
kibanaVersionInfo: KibanaVersionContext;
plugins: {
cloud?: CloudSetup;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/upgrade_assistant/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class UpgradeAssistantServerPlugin implements Plugin {

// We need to initialize the deprecation logs plugin so that we can
// navigate from this app to the observability app using a source_id.
infra.defineInternalSourceConfiguration(DEPRECATION_LOGS_SOURCE_ID, {
infra?.defineInternalSourceConfiguration(DEPRECATION_LOGS_SOURCE_ID, {
name: 'deprecationLogs',
description: 'deprecation logs',
logIndices: {
Expand Down

0 comments on commit ecf4b7c

Please sign in to comment.