Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions x-pack/plugins/monitoring/public/components/logs/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React, { PureComponent } from 'react';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { upperFirst } from 'lodash';
import { Legacy } from '../../legacy_shims';
import { EuiBasicTable, EuiTitle, EuiSpacer, EuiText, EuiCallOut, EuiLink } from '@elastic/eui';
Expand Down Expand Up @@ -110,8 +111,6 @@ const clusterColumns = [
];

function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
const base = `${Legacy.shims.getBasePath()}/app/logs/link-to/${INFRA_SOURCE_ID}/logs`;

const params = [];
if (clusterUuid) {
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`);
Expand All @@ -123,11 +122,12 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
params.push(`elasticsearch.index.name:${indexUuid}`);
}

if (params.length === 0) {
return base;
}
const base = Legacy.shims.infra.locators.logsLocator.getRedirectUrl({
logView: { logViewId: INFRA_SOURCE_ID, type: 'log-view-reference' },
...(params.length ? { filter: params.join(' and ') } : {}),
});

return `${base}?filter=${params.join(' and ')}`;
return base;
}

export class Logs extends PureComponent {
Expand Down Expand Up @@ -158,7 +158,7 @@ export class Logs extends PureComponent {
}

renderCallout() {
const uiCapabilities = Legacy.shims.capabilities;
const { capabilities: uiCapabilities, infra, kibanaServices } = Legacy.shims;
const show = uiCapabilities.logs && uiCapabilities.logs.show;
const {
logs: { enabled },
Expand All @@ -170,15 +170,15 @@ export class Logs extends PureComponent {
return null;
}

return (
return infra ? (
<EuiCallOut
size="m"
title={i18n.translate('xpack.monitoring.logs.listing.calloutTitle', {
defaultMessage: 'Want to see more log entries?',
})}
iconType="logsApp"
>
<p>
<RedirectAppLinks coreStart={kibanaServices}>
<FormattedMessage
id="xpack.monitoring.logs.listing.linkText"
defaultMessage="Visit {link} to dive deeper."
Expand All @@ -192,9 +192,9 @@ export class Logs extends PureComponent {
),
}}
/>
</p>
</RedirectAppLinks>
</EuiCallOut>
);
) : null;
}

render() {
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/monitoring/public/components/logs/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ jest.mock('../../legacy_shims', () => ({
shims: {
getBasePath: () => '',
capabilities: { logs: { show: true } },
infra: {
locators: {
logsLocator: {
getRedirectUrl: () => '',
},
},
},
},
},
}));
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/monitoring/public/legacy_shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-
import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry';
import { ActionTypeModel, RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
import {
MonitoringStartPluginDependencies,
LegacyMonitoringStartPluginDependencies,
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface IShims {
usageCollection: UsageCollectionSetup;
kibanaServices: CoreStart & { usageCollection: UsageCollectionSetup };
appMountParameters: AppMountParameters;
infra?: InfraClientStartExports;
}

export class Legacy {
Expand All @@ -85,6 +87,7 @@ export class Legacy {
triggersActionsUi,
usageCollection,
appMountParameters,
infra,
}: LegacyMonitoringStartPluginDependencies) {
this._shims = {
toastNotifications: core.notifications.toasts,
Expand Down Expand Up @@ -143,6 +146,7 @@ export class Legacy {
usageCollection,
},
appMountParameters,
infra,
};
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class MonitoringPlugin
usageCollection: plugins.usageCollection,
appMountParameters: params,
dataViews: pluginsStart.dataViews,
infra: pluginsStart.infra,
};

Legacy.init({
Expand All @@ -122,6 +123,7 @@ export class MonitoringPlugin
usageCollection: deps.usageCollection,
appMountParameters: deps.appMountParameters,
dataViews: deps.dataViews,
infra: deps.infra,
});

const config = Object.fromEntries(externalConfig);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type { MLJobs } from '../server/lib/elasticsearch/get_ml_jobs';
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import { FleetStart } from '@kbn/fleet-plugin/public';
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';

export interface MonitoringStartPluginDependencies {
navigation: NavigationStart;
Expand All @@ -24,6 +25,7 @@ export interface MonitoringStartPluginDependencies {
dataViews: DataViewsPublicPluginStart;
dashboard?: DashboardStart;
fleet?: FleetStart;
infra?: InfraClientStartExports;
}

interface LegacyStartDependencies {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@kbn/fleet-plugin",
"@kbn/shared-ux-router",
"@kbn/observability-shared-plugin",
"@kbn/shared-ux-link-redirect-app",
],
"exclude": [
"target/**/*",
Expand Down