Skip to content

Commit

Permalink
fix app links in index management
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Jul 7, 2020
1 parent aeff8c1 commit 21f231d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const services = {
services.uiMetricService.setup({ reportUiStats() {} } as any);
setExtensionsService(services.extensionsService);
setUiMetricService(services.uiMetricService);
const appDependencies = { services, core: { getUrlForApp: () => {} }, plugins: {} } as any;
const appDependencies = {
services,
core: { getUrlForApp: () => {}, navigateToApp: () => {} },
plugins: {},
} as any;

export const setupEnvironment = () => {
// Mock initialization of services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface AppDependencies {
core: {
fatalErrors: CoreStart['fatalErrors'];
getUrlForApp: CoreStart['application']['getUrlForApp'];
navigateToApp: CoreStart['application']['navigateToApp'];
};
plugins: {
usageCollection: UsageCollectionSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function mountManagementSection(
core: {
fatalErrors,
getUrlForApp: application.getUrlForApp,
navigateToApp: application.navigateToApp,
},
plugins: {
usageCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const HEADERS = {

export class IndexTable extends Component {
static getDerivedStateFromProps(props, state) {
// Deselct any indices which no longer exist, e.g. they've been deleted.
// Deselect any indices which no longer exist, e.g. they've been deleted.
const { selectedIndicesMap } = state;
const indexNames = props.indices.map((index) => index.name);
const selectedIndexNames = Object.keys(selectedIndicesMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import {
EuiFlexItem,
EuiCodeBlock,
} from '@elastic/eui';
import { useAppContext } from '../../../../../app_context';
import { TemplateDeserialized } from '../../../../../../../common';
import { getILMPolicyPath } from '../../../../../services/navigation';
import { getILMPolicyPath } from '../../../../../services/routing';

interface Props {
templateDetails: TemplateDeserialized;
Expand Down Expand Up @@ -51,6 +52,10 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })

const numIndexPatterns = indexPatterns.length;

const {
core: { navigateToApp },
} = useAppContext();

return (
<EuiFlexGroup data-test-subj="summaryTab">
<EuiFlexItem>
Expand Down Expand Up @@ -153,7 +158,13 @@ export const TabSummary: React.FunctionComponent<Props> = ({ templateDetails })
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{ilmPolicy && ilmPolicy.name ? (
<EuiLink href={getILMPolicyPath(ilmPolicy.name)}>{ilmPolicy.name}</EuiLink>
<EuiLink
onClick={() =>
navigateToApp('management', { path: getILMPolicyPath(ilmPolicy.name) })
}
>
{ilmPolicy.name}
</EuiLink>
) : (
i18nTexts.none
)}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ export const getTemplateCloneLink = (name: string, isLegacy?: boolean) => {
return encodeURI(url);
};

export const getILMPolicyPath = (policyName: string) => {
return encodeURI(
`/data/index_lifecycle_management/policies/edit/${encodeURIComponent(policyName)}`
);
};

export const getIndexListUri = (filter: any) => {
if (filter) {
// React router tries to decode url params but it can't because the browser partially
// decodes them. So we have to encode both the URL and the filter to get it all to
// work correctly for filters with URL unsafe characters in them.
return encodeURI(`/indices?includeHiddenIndices=true&filter=${encodeURIComponent(filter)}`);
}

// If no filter, URI is already safe so no need to encode.
return '/indices';
};

export const decodePathFromReactRouter = (pathname: string): string => {
let decodedPath;
try {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/index_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const plugin = () => {

export { IndexManagementPluginSetup };

export { getIndexListUri } from './application/services/navigation';
export { getIndexListUri } from './application/services/routing';

0 comments on commit 21f231d

Please sign in to comment.