Skip to content

Commit

Permalink
Remove path prefix from ViewSourceConfigurationButton
Browse files Browse the repository at this point in the history
In the NP the routes have already the app name on them. Adding it to
this button made the app name double

    /app/metrics/metrics/settings
    /app/logs/logs/settings

The button only needs to go to the settings page within the app where
it's being loaded, so we can safely drop the prefix.

Closes #58233
  • Loading branch information
Alejandro Fernández Gómez committed Feb 21, 2020
1 parent c91b6ce commit 042f085
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@
*/

export { SourceConfigurationSettings } from './source_configuration_settings';
export {
ViewSourceConfigurationButton,
ViewSourceConfigurationButtonHrefBase,
} from './view_source_configuration_button';
export { ViewSourceConfigurationButton } from './view_source_configuration_button';
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@ import { EuiButton } from '@elastic/eui';
import React from 'react';
import { Route } from 'react-router-dom';

export enum ViewSourceConfigurationButtonHrefBase {
infrastructure = 'infrastructure',
logs = 'logs',
}

interface ViewSourceConfigurationButtonProps {
'data-test-subj'?: string;
hrefBase: ViewSourceConfigurationButtonHrefBase;
children: React.ReactNode;
}

export const ViewSourceConfigurationButton = ({
'data-test-subj': dataTestSubj,
hrefBase,
children,
}: ViewSourceConfigurationButtonProps) => {
const href = `/${hrefBase}/settings`;
const href = '/settings';

return (
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import { ColumnarPage } from '../../../components/page';

import { SourceErrorPage } from '../../../components/source_error_page';
import { SourceLoadingPage } from '../../../components/source_loading_page';
import {
ViewSourceConfigurationButton,
ViewSourceConfigurationButtonHrefBase,
} from '../../../components/source_configuration';
import { ViewSourceConfigurationButton } from '../../../components/source_configuration';
import { Source } from '../../../containers/source';
import { WithWaffleFilterUrlState } from '../../../containers/waffle/with_waffle_filters';
import { WithWaffleOptionsUrlState } from '../../../containers/waffle/with_waffle_options';
Expand Down Expand Up @@ -92,10 +89,7 @@ export const SnapshotPage = () => {
</EuiFlexItem>
{uiCapabilities?.infrastructure?.configureSource ? (
<EuiFlexItem>
<ViewSourceConfigurationButton
data-test-subj="configureSourceButton"
hrefBase={ViewSourceConfigurationButtonHrefBase.infrastructure}
>
<ViewSourceConfigurationButton data-test-subj="configureSourceButton">
{i18n.translate('xpack.infra.configureSourceActionLabel', {
defaultMessage: 'Change source configuration',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { identity } from 'fp-ts/lib/function';
import React from 'react';

import { NoIndices } from '../../../components/empty_states/no_indices';
import {
ViewSourceConfigurationButton,
ViewSourceConfigurationButtonHrefBase,
} from '../../../components/source_configuration';
import { ViewSourceConfigurationButton } from '../../../components/source_configuration';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';

export const LogsPageNoIndicesContent = () => {
Expand Down Expand Up @@ -49,10 +46,7 @@ export const LogsPageNoIndicesContent = () => {
</EuiFlexItem>
{canConfigureSource ? (
<EuiFlexItem>
<ViewSourceConfigurationButton
data-test-subj="configureSourceButton"
hrefBase={ViewSourceConfigurationButtonHrefBase.logs}
>
<ViewSourceConfigurationButton data-test-subj="configureSourceButton">
{i18n.translate('xpack.infra.configureSourceActionLabel', {
defaultMessage: 'Change source configuration',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { identity } from 'fp-ts/lib/function';
import React from 'react';

import { euiStyled } from '../../../../../observability/public';
import {
ViewSourceConfigurationButton,
ViewSourceConfigurationButtonHrefBase,
} from '../../../components/source_configuration';
import { ViewSourceConfigurationButton } from '../../../components/source_configuration';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';

interface InvalidNodeErrorProps {
Expand Down Expand Up @@ -59,10 +56,7 @@ export const InvalidNodeError: React.FunctionComponent<InvalidNodeErrorProps> =
</EuiButton>
</EuiFlexItem>
<EuiFlexItem>
<ViewSourceConfigurationButton
data-test-subj="configureSourceButton"
hrefBase={ViewSourceConfigurationButtonHrefBase.infrastructure}
>
<ViewSourceConfigurationButton data-test-subj="configureSourceButton">
<FormattedMessage
id="xpack.infra.configureSourceActionLabel"
defaultMessage="Change source configuration"
Expand Down

0 comments on commit 042f085

Please sign in to comment.