Skip to content

Commit

Permalink
feat(infra): add logs settings page navigation entry and deprecation …
Browse files Browse the repository at this point in the history
…banner
  • Loading branch information
Marco Antonio Ghiani committed Oct 2, 2024
1 parent bc8ef2c commit 4b02294
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,38 @@ import { css } from '@emotion/css';
import { SharePublicStart } from '@kbn/share-plugin/public/plugin';
import { useKibanaContextForPlugin } from '../hooks/use_kibana';

const DISMISSAL_STORAGE_KEY = 'log_stream_deprecation_callout_dismissed';
const pageConfigurations = {
stream: {
dismissalStorageKey: 'log_stream_deprecation_callout_dismissed',
message: i18n.translate('xpack.infra.logsDeprecationCallout.p.theNewLogsExplorerLabel', {
defaultMessage:
'The new Logs Explorer makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation. We recommend switching to Logs Explorer, as it will replace Logs Stream in a future version.',
}),
},
settings: {
dismissalStorageKey: 'log_settings_deprecation_callout_dismissed',
message: i18n.translate(
'xpack.infra.logsSettingsDeprecationCallout.p.theNewLogsExplorerLabel',
{
defaultMessage:
'The new Logs Explorer makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation. These settings will not affect the Logs Explorer behaviour, and is now discouraged configuring them for the legacy Stream application.',
}
),
},
};

interface LogsDeprecationCalloutProps {
page: keyof typeof pageConfigurations;
}

export const LogsDeprecationCallout = () => {
export const LogsDeprecationCallout = ({ page }: LogsDeprecationCalloutProps) => {
const {
services: { share },
} = useKibanaContextForPlugin();

const [isDismissed, setDismissed] = useLocalStorage(DISMISSAL_STORAGE_KEY, false);
const { dismissalStorageKey, message } = pageConfigurations[page];

const [isDismissed, setDismissed] = useLocalStorage(dismissalStorageKey, false);

if (isDismissed) {
return null;
Expand All @@ -42,12 +66,7 @@ export const LogsDeprecationCallout = () => {
onDismiss={() => setDismissed(true)}
className={calloutStyle}
>
<p>
{i18n.translate('xpack.infra.logsDeprecationCallout.p.theNewLogsExplorerLabel', {
defaultMessage:
'The new Logs Explorer makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation. We recommend switching to Logs Explorer, as it will replace Logs Stream in a future version.',
})}
</p>
<p>{message}</p>
<EuiButton
fill
data-test-subj="infraLogsDeprecationCalloutTryLogsExplorerButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export interface LogsAppRoutes {
export const getLogsAppRoutes = ({ isLogsStreamEnabled }: { isLogsStreamEnabled: boolean }) => {
const routes: LogsAppRoutes = {
logsAnomalies: {
id: 'logs-anomalies',
id: 'anomalies',
title: logsAnomaliesTitle,
path: '/anomalies',
},
logsCategories: {
id: 'logs-categories',
id: 'log-categories',
title: logCategoriesTitle,
path: '/log-categories',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useKibana } from '@kbn/kibana-react-plugin/public';
import { Prompt } from '@kbn/observability-shared-plugin/public';
import { useTrackPageview } from '@kbn/observability-shared-plugin/public';
import { useLogViewContext } from '@kbn/logs-shared-plugin/public';
import { LogsDeprecationCallout } from '../../../components/logs_deprecation_callout';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import { useLogsBreadcrumbs } from '../../../hooks/use_logs_breadcrumbs';
import { settingsTitle } from '../../../translations';
Expand Down Expand Up @@ -98,6 +99,7 @@ export const LogsSettingsPage = () => {
data-test-subj="sourceConfigurationContent"
restrictWidth
>
<LogsDeprecationCallout page="settings" />
<Prompt
prompt={sourceConfigurationFormElement.isDirty ? unsavedFormPromptMessage : undefined}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const StreamPageLogsContent = React.memo<{

return (
<>
<LogsDeprecationCallout />
<LogsDeprecationCallout page="stream" />
<WithLogTextviewUrlState />
<WithFlyoutOptionsUrlState />
<LogsToolbar />
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/observability_solution/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,13 @@ const getLogsNavigationEntries = ({
});
}

// Display Stream nav entry when Logs Stream is enabled
if (routes.stream) entries.push(createNavEntryFromRoute(routes.stream));
// Display always Logs Anomalies and Logs Categories entries
entries.push(createNavEntryFromRoute(routes.logsAnomalies));
entries.push(createNavEntryFromRoute(routes.logsCategories));
// Display Logs Settings entry when Logs Stream is not enabled
if (!routes.stream) entries.push(createNavEntryFromRoute(routes.settings));

return entries;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ export function createNavTree(pluginsStart: ObservabilityPublicPluginsStart) {
defaultMessage: 'Logs stream',
}),
},
{
link: 'logs:settings',
title: i18n.translate('xpack.observability.obltNav.otherTools.logsSettings', {
defaultMessage: 'Logs settings',
}),
},
{ link: 'maps' },
{ link: 'canvas' },
{ link: 'graph' },
Expand Down

0 comments on commit 4b02294

Please sign in to comment.