Skip to content

Commit

Permalink
[Upgrade Assistant] Make infra plugin optional (elastic#111960)
Browse files Browse the repository at this point in the history
* Make infra plugin optional

* Fix CR requests
  • Loading branch information
sabarasaba committed Oct 20, 2021
1 parent 388bc2f commit a7e5461
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const getAppContextMock = () => ({
},
plugins: {
share: shareMock,
infra: undefined,
cloud: {
...cloudMock.createSetup(),
isCloudEnabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ describe('Overview - Fix deprecation logs step', () => {
prepend: (url: string) => url,
},
},
plugins: {
infra: {},
},
});
});

Expand All @@ -211,6 +214,14 @@ describe('Overview - Fix deprecation logs step', () => {
);
});

test(`Doesn't show observability app link if infra app is not available`, async () => {
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", "security"],
"requiredPlugins": ["management", "data", "licensing", "features", "share"],
"optionalPlugins": ["usageCollection", "cloud", "security", "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 { infra: hasInfraPlugin } = useAppContext().plugins;

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>
{hasInfraPlugin && (
<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 @@ -43,7 +43,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 @@ -57,6 +57,10 @@ export class UpgradeAssistantUIPlugin
plugins: {
cloud,
share,
// 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.
infra: plugins.hasOwnProperty('infra') ? {} : undefined,
},
services: {
core: coreStart,
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 @@ -45,6 +45,7 @@ export interface AppDependencies {
plugins: {
cloud?: CloudSetup;
share: SharePluginSetup;
infra: object | undefined;
};
services: {
core: CoreStart;
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 @@ -99,7 +99,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 a7e5461

Please sign in to comment.