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

[Logs] Update logs stream links to logs explorer #190835

Merged
merged 5 commits into from
Sep 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jest.mock('@kbn/logs-shared-plugin/public', () => {
jest.mock('@kbn/logs-shared-plugin/common', () => {
return {
getLogsLocatorsFromUrlService: jest.fn().mockReturnValue({
logsLocator: { getRedirectUrl: jest.fn(() => 'https://discover-redirect-url') },
logsLocator: { getRedirectUrl: jest.fn(() => 'https://logs-explorer-redirect-url') },
}),
};
});
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('AgentLogsUI', () => {
const result = renderComponent();
expect(result.getByTestId('viewInLogsBtn')).toHaveAttribute(
'href',
`https://discover-redirect-url`
`https://logs-explorer-redirect-url`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/

import React, { useMemo } from 'react';
import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';

import moment from 'moment';

import { useDiscoverLocator, useStartServices, useAuthz } from '../../../../../hooks';
import { EuiButton } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';

import { useStartServices, useAuthz } from '../../../../../hooks';

interface ViewLogsProps {
logStreamQuery: string;
Expand All @@ -32,8 +34,6 @@ export const ViewLogsButton: React.FunctionComponent<ViewLogsProps> = ({
startTime,
endTime,
}) => {
const discoverLocator = useDiscoverLocator();

const { share } = useStartServices();
const { logsLocator } = getLogsLocatorsFromUrlService(share.url);
const authz = useAuthz();
Expand All @@ -54,11 +54,11 @@ export const ViewLogsButton: React.FunctionComponent<ViewLogsProps> = ({
});
}, [endTime, logStreamQuery, logsLocator, startTime]);

return authz.fleet.readAgents && (logsLocator || discoverLocator) ? (
return authz.fleet.readAgents && logsLocator ? (
<EuiButton href={logsUrl} iconType="popout" data-test-subj="viewInLogsBtn">
<FormattedMessage
id="xpack.fleet.agentLogs.openInLogsUiLinkText"
defaultMessage="Open in Logs"
defaultMessage="Open in Logs Explorer"
/>
</EuiButton>
) : null;
Expand Down
17 changes: 8 additions & 9 deletions x-pack/plugins/fleet/public/custom_logs_assets_extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@
import React from 'react';
import { i18n } from '@kbn/i18n';

import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';

import { CustomAssetsAccordion } from './components/custom_assets_accordion';
import type { CustomAssetsAccordionProps } from './components/custom_assets_accordion';
import { useStartServices } from './hooks';
import type { PackageAssetsComponent } from './types';

export const CustomLogsAssetsExtension: PackageAssetsComponent = () => {
const { http, cloud } = useStartServices();
const isLogsUIAvailable = !cloud?.isServerlessEnabled;
// if logs ui is not available, link to discover
// TODO: move away from hardcoded link and use locators instead
const logStreamUrl = isLogsUIAvailable
? http.basePath.prepend('/app/logs/stream')
: http.basePath.prepend('/app/discover');
const {
share: { url },
} = useStartServices();
const { logsLocator } = getLogsLocatorsFromUrlService(url);
tonyghiani marked this conversation as resolved.
Show resolved Hide resolved

const views: CustomAssetsAccordionProps['views'] = [
{
name: i18n.translate('xpack.fleet.assets.customLogs.name', { defaultMessage: 'Logs' }),
url: logStreamUrl,
url: logsLocator.getRedirectUrl({}),
description: i18n.translate('xpack.fleet.assets.customLogs.description', {
defaultMessage: 'View Custom logs data in Logs app',
defaultMessage: 'View Custom logs data in Logs Explorer',
}),
},
];
Expand Down
113 changes: 0 additions & 113 deletions x-pack/plugins/observability_solution/infra/common/locators/helpers.ts

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading