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

[Enterprise Search] Migrate shared components used in Workplace Search Groups #76345

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';

import { EuiLink } from '@elastic/eui';

import {
getContentSourcePath,
SOURCES_PATH,
ORG_SOURCES_PATH,
SOURCE_DETAILS_PATH,
} from './routes';

const TestComponent = ({ id, isOrg }: { id: string; isOrg?: boolean }) => {
const href = getContentSourcePath(SOURCE_DETAILS_PATH, id, !!isOrg);
return <EuiLink href={href}>test</EuiLink>;
};

describe('getContentSourcePath', () => {
it('should format org route', () => {
const wrapper = shallow(<TestComponent id="123" isOrg />);
const path = wrapper.find(EuiLink).prop('href');

expect(path).toEqual(`${ORG_SOURCES_PATH}/123`);
});

it('should format user route', () => {
const wrapper = shallow(<TestComponent id="123" />);
const path = wrapper.find(EuiLink).prop('href');

expect(path).toEqual(`${SOURCES_PATH}/123`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { formatRoute } from '../shared/react_router_helpers';

import { CURRENT_MAJOR_VERSION } from '../../../common/version';

export const SETUP_GUIDE_PATH = '/setup_guide';
Expand Down Expand Up @@ -107,4 +109,8 @@ export const EDIT_SLACK_PATH = `${ORG_SETTINGS_CONNECTORS_PATH}/slack/edit`;
export const EDIT_ZENDESK_PATH = `${ORG_SETTINGS_CONNECTORS_PATH}/zendesk/edit`;
export const EDIT_CUSTOM_PATH = `${ORG_SETTINGS_CONNECTORS_PATH}/custom/edit`;

export const getSourcePath = (sourceId: string): string => `${ORG_SOURCES_PATH}/${sourceId}`;
export const getContentSourcePath = (
path: string,
sourceId: string,
isOrganization: boolean
): string => formatRoute(isOrganization ? `${ORG_PATH}/${path}` : path, { sourceId });
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { ContentSection } from '../../components/shared/content_section';
import { sendTelemetry } from '../../../shared/telemetry';
import { KibanaContext, IKibanaContext } from '../../../index';
import { getSourcePath } from '../../routes';
import { SOURCE_DETAILS_PATH, getContentSourcePath as sourcePath } from '../../routes';

import { OverviewLogic } from './overview_logic';

Expand Down Expand Up @@ -107,7 +107,7 @@ export const RecentActivityItem: React.FC<IFeedActivity> = ({
const linkProps = {
onClick,
target: '_blank',
href: getWorkplaceSearchUrl(getSourcePath(sourceId)),
href: getWorkplaceSearchUrl(sourcePath(SOURCE_DETAILS_PATH, sourceId, true)),
external: true,
color: status === 'error' ? 'danger' : 'primary',
'data-test-subj': 'viewSourceDetailsLink',
Expand Down