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

Updates app ids to solve routing problem when no base path is used #8

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
4 changes: 2 additions & 2 deletions x-pack/plugins/infra/public/pages/infrastructure/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', {
defaultMessage: 'Metrics Explorer',
}),
path: `${match.path}/metrics-explorer`,
path: `${match.path}/explorer`,
},
{
title: i18n.translate('xpack.infra.homePage.settingsTabTitle', {
Expand All @@ -86,7 +86,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
<Switch>
<Route path={`${match.path}/inventory`} component={SnapshotPage} />
<Route
path={`${match.path}/metrics-explorer`}
path={`${match.path}/explorer`}
render={props => (
<WithSource>
{({ configuration, createDerivedIndexPattern }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const RedirectToNodeDetail = ({
getToFromLocation(location)
)('');

return <Redirect to={`/infrastructure/metrics/${nodeType}/${nodeId}?${searchString}`} />;
return <Redirect to={`/metrics/detail/${nodeType}/${nodeId}?${searchString}`} />;
};

export const getNodeDetailUrl = ({
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export class Plugin
pluginsSetup.data.autocomplete.addQuerySuggestionProvider('kuery', kueryProvider);

core.application.register({
id: 'infra:logs',
id: 'logs',
title: i18n.translate('xpack.infra.logs.pluginTitle', {
defaultMessage: 'Logs',
}),
euiIconType: 'logsApp',
order: 8001,
appRoute: '/app/infra/logs',
appRoute: '/app/logs',
category: DEFAULT_APP_CATEGORIES.observability,
mount: async (params: AppMountParameters) => {
const [coreStart, pluginsStart] = await core.getStartServices();
Expand All @@ -76,13 +76,13 @@ export class Plugin
});

core.application.register({
id: 'infra:home',
id: 'metrics',
title: i18n.translate('xpack.infra.metrics.pluginTitle', {
defaultMessage: 'Metrics',
}),
euiIconType: 'metricsApp',
order: 8000,
appRoute: '/app/infra/infrastructure',
appRoute: '/app/metrics',
category: DEFAULT_APP_CATEGORIES.observability,
mount: async (params: AppMountParameters) => {
const [coreStart, pluginsStart] = await core.getStartServices();
Expand Down
26 changes: 11 additions & 15 deletions x-pack/plugins/infra/public/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,33 @@ export const PageRouter: React.FC<RouterProps> = ({ history }) => {
<Router history={history}>
<Switch>
{uiCapabilities?.infrastructure?.show && (
<RedirectWithQueryParams from="/" exact={true} to="/infrastructure/inventory" />
<RedirectWithQueryParams from="/" exact={true} to="/metrics/inventory" />
)}
{uiCapabilities?.infrastructure?.show && (
<RedirectWithQueryParams
from="/infrastructure"
exact={true}
to="/infrastructure/inventory"
/>
<RedirectWithQueryParams from="/metrics" exact={true} to="/metrics/inventory" />
)}
{uiCapabilities?.infrastructure?.show && (
<RedirectWithQueryParams
from="/infrastructure/snapshot"
exact={true}
to="/infrastructure/inventory"
/>
<RedirectWithQueryParams from="/metrics/snapshot" exact={true} to="/metrics/inventory" />
)}
{uiCapabilities?.infrastructure?.show && (
<RedirectWithQueryParams from="/home" exact={true} to="/infrastructure/inventory" />
<RedirectWithQueryParams from="/home" exact={true} to="/metrics/inventory" />
)}
{uiCapabilities?.infrastructure?.show && (
<Route path="/infrastructure/metrics/:type/:node" component={MetricDetail} />
<RedirectWithQueryParams
from="/metrics/metrics-explorer"
exact={true}
to="/metrics/explorer"
/>
)}
{uiCapabilities?.infrastructure?.show && (
<RedirectWithQueryParams from="/metrics" to="/infrastructure/metrics" />
<Route path="/metrics/detail/:type/:node" component={MetricDetail} />
)}
{uiCapabilities?.logs?.show && (
<RedirectWithQueryParams from="/logs" exact={true} to="/logs/stream" />
)}
{uiCapabilities?.logs?.show && <Route path="/logs" component={LogsPage} />}
{uiCapabilities?.infrastructure?.show && (
<Route path="/infrastructure" component={InfrastructurePage} />
<Route path="/metrics" component={InfrastructurePage} />
)}
<Route path="/link-to" component={LinkToPage} />
<Route component={NotFoundPage} />
Expand Down