Skip to content

Commit

Permalink
Merge branch 'main' into 152438-improve-preview-loading-state
Browse files Browse the repository at this point in the history
  • Loading branch information
maryam-saeidi committed Mar 10, 2023
2 parents 0f22e44 + ca393b2 commit c47f680
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 19 deletions.
2 changes: 0 additions & 2 deletions x-pack/plugins/infra/public/apps/logs_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Route } from '@kbn/shared-ux-router';
import { AppMountParameters } from '@kbn/core/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import '../index.scss';
import { NotFoundPage } from '../pages/404';
import { LinkToLogsPage } from '../pages/link_to/link_to_logs';
import { LogsPage } from '../pages/logs';
import { InfraClientStartDeps, InfraClientStartExports } from '../types';
Expand Down Expand Up @@ -78,7 +77,6 @@ const LogsApp: React.FC<{
<Switch>
<Route path="/link-to" component={LinkToLogsPage} />
{uiCapabilities?.logs?.show && <Route path="/" component={LogsPage} />}
<Route component={NotFoundPage} />
</Switch>
</KbnUrlStateStorageFromRouterProvider>
</Router>
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/infra/public/apps/metrics_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Route } from '@kbn/shared-ux-router';
import { AppMountParameters } from '@kbn/core/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import '../index.scss';
import { NotFoundPage } from '../pages/404';
import { LinkToMetricsPage } from '../pages/link_to/link_to_metrics';
import { InfrastructurePage } from '../pages/metrics';
import { InfraClientStartDeps, InfraClientStartExports } from '../types';
Expand Down Expand Up @@ -86,7 +85,6 @@ const MetricsApp: React.FC<{
{uiCapabilities?.infrastructure?.show && (
<Route path="/" component={InfrastructurePage} />
)}
<Route component={NotFoundPage} />
</Switch>
</Router>
</CommonInfraProviders>
Expand Down
29 changes: 17 additions & 12 deletions x-pack/plugins/infra/public/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
* 2.0.
*/

import { FormattedMessage } from '@kbn/i18n-react';
import React from 'react';
import { NotFoundPrompt } from '@kbn/shared-ux-prompt-not-found';
import { MetricsPageTemplate } from './metrics/page_template';

export class NotFoundPage extends React.PureComponent {
public render() {
return (
<div data-test-subj="infraNotFoundPage">
<FormattedMessage
id="xpack.infra.notFoundPage.noContentFoundErrorTitle"
defaultMessage="No content found"
/>
</div>
);
}
interface NotFoundPageProps {
title: string;
}

export const NotFoundPage = ({ title }: NotFoundPageProps) => {
return (
<MetricsPageTemplate
pageHeader={{
pageTitle: title,
}}
data-test-subj="infraNotFoundPage"
>
<NotFoundPrompt />
</MetricsPageTemplate>
);
};
2 changes: 2 additions & 0 deletions x-pack/plugins/infra/public/pages/logs/page_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LogEntryCategoriesPage } from './log_entry_categories';
import { LogEntryRatePage } from './log_entry_rate';
import { LogsSettingsPage } from './settings';
import { StreamPage } from './stream';
import { NotFoundPage } from '../404';

export const LogsPageContent: React.FunctionComponent = () => {
const uiCapabilities = useKibana().services.application?.capabilities;
Expand Down Expand Up @@ -90,6 +91,7 @@ export const LogsPageContent: React.FunctionComponent = () => {
<RedirectWithQueryParams from={'/analysis'} to={anomaliesTab.pathname} exact />
<RedirectWithQueryParams from={'/log-rate'} to={anomaliesTab.pathname} exact />
<RedirectWithQueryParams from={'/'} to={streamTab.pathname} exact />
<Route render={() => <NotFoundPage title="Logs" />} />
</Switch>
</>
);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/infra/public/pages/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { InfraMLCapabilitiesProvider } from '../../containers/ml/infra_ml_capabi
import { AnomalyDetectionFlyout } from './inventory_view/components/ml/anomaly_detection/anomaly_detection_flyout';
import { HeaderActionMenuContext } from '../../utils/header_action_menu_provider';
import { CreateDerivedIndexPattern } from '../../containers/metrics_source';
import { NotFoundPage } from '../404';

const ADD_DATA_LABEL = i18n.translate('xpack.infra.metricsHeaderAddDataButtonLabel', {
defaultMessage: 'Add data',
Expand Down Expand Up @@ -130,6 +131,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
<Route path="/detail/:type/:node" component={MetricDetail} />
<Route path={'/hosts'} component={HostsLandingPage} />
<Route path={'/settings'} component={MetricsSettingsPage} />
<Route render={() => <NotFoundPage title="Infrastructure" />} />
</Switch>
</InfraMLCapabilitiesProvider>
</QueryClientProvider>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/infra/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@kbn/shared-ux-router",
"@kbn/alerts-as-data-utils",
"@kbn/cases-plugin",
"@kbn/shared-ux-prompt-not-found",
],
"exclude": ["target/**/*"]
}
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -17047,7 +17047,6 @@
"xpack.infra.nodeDetails.yes": "Oui",
"xpack.infra.nodesToWaffleMap.groupsWithGroups.allName": "Tous",
"xpack.infra.nodesToWaffleMap.groupsWithNodes.allName": "Tous",
"xpack.infra.notFoundPage.noContentFoundErrorTitle": "Aucun contenu trouvé",
"xpack.infra.openView.actionNames.deleteConfirmation": "Supprimer la vue ?",
"xpack.infra.openView.cancelButton": "Annuler",
"xpack.infra.openView.columnNames.actions": "Actions",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -17032,7 +17032,6 @@
"xpack.infra.nodeDetails.yes": "はい",
"xpack.infra.nodesToWaffleMap.groupsWithGroups.allName": "すべて",
"xpack.infra.nodesToWaffleMap.groupsWithNodes.allName": "すべて",
"xpack.infra.notFoundPage.noContentFoundErrorTitle": "コンテンツがありません",
"xpack.infra.openView.actionNames.deleteConfirmation": "ビューを削除しますか?",
"xpack.infra.openView.cancelButton": "キャンセル",
"xpack.infra.openView.columnNames.actions": "アクション",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -17052,7 +17052,6 @@
"xpack.infra.nodeDetails.yes": "是",
"xpack.infra.nodesToWaffleMap.groupsWithGroups.allName": "全部",
"xpack.infra.nodesToWaffleMap.groupsWithNodes.allName": "全部",
"xpack.infra.notFoundPage.noContentFoundErrorTitle": "未找到任何内容",
"xpack.infra.openView.actionNames.deleteConfirmation": "删除视图?",
"xpack.infra.openView.cancelButton": "取消",
"xpack.infra.openView.columnNames.actions": "操作",
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ loadTestFile }: FtrProviderContext) => {
describe('InfraOps App', function () {
loadTestFile(require.resolve('./feature_controls'));
loadTestFile(require.resolve('./page_not_found'));
loadTestFile(require.resolve('./tour'));

describe('Metrics UI', function () {
Expand Down
82 changes: 82 additions & 0 deletions x-pack/test/functional/apps/infra/page_not_found.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

const logsPages = [
'logs/stream',
'logs/anomalies',
'logs/log-categories',
'logs/settings',
'logs/analysis',
'logs/log-rate',
'logs',
'logs/link-to',
];

const metricsPages = [
'metrics/inventory',
'metrics/hosts',
'metrics/explorer',
'metrics/settings',
'metrics/detail/hosts/host_name',
'metrics',
'metrics/snapshot',
'metrics/metrics-explorer',
'metrics/link-to',
];

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const find = getService('find');
const pageObjects = getPageObjects(['common', 'infraHome']);
const testSubjects = getService('testSubjects');

describe('Infra Not Found page', function () {
this.tags('includeFirefox');

describe('Logs', () => {
it('should render the not found page when the route does not exist', async () => {
await pageObjects.common.navigateToApp('logs/broken-link');
await testSubjects.existOrFail('infraNotFoundPage');

const titleElement = await find.byCssSelector('h1');
const title = await titleElement.getVisibleText();

expect(title).to.contain('Logs');
});

it('should NOT render the not found page when the route exist', async () => {
// Sequential browsing across pages
for (const appName of logsPages) {
await pageObjects.common.navigateToApp(appName);
await testSubjects.missingOrFail('infraNotFoundPage');
}
});
});

describe('Metrics', () => {
it('should render the not found page when the route does not exist', async () => {
await pageObjects.common.navigateToApp('metrics/broken-link');
await testSubjects.existOrFail('infraNotFoundPage');

const titleElement = await find.byCssSelector('h1');
const title = await titleElement.getVisibleText();

expect(title).to.contain('Infrastructure');
});

it('should NOT render the not found page when the route exist', async () => {
// Sequential browsing across pages
for (const appName of metricsPages) {
await pageObjects.common.navigateToApp(appName);
await testSubjects.missingOrFail('infraNotFoundPage');
}
});
});
});
};

0 comments on commit c47f680

Please sign in to comment.