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 1 commit
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 @@ -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 && (
sabarasaba marked this conversation as resolved.
Show resolved Hide resolved
<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'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this comment! How about we expose an infra property on the plugins object to make the interface more consistent?

// line 60
plugins: {
  // 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,
  cloud,
  share,
  /* ... */
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I've addressed this with 9f5325d

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