Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Upgrade Assistant] Make infra plugin optional #111960

Merged
merged 3 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"],
"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 { 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 @@ -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 @@ -56,6 +56,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 @@ -38,6 +38,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 @@ -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