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] Update apps to use a service for docs links #89425

Merged
11 changes: 0 additions & 11 deletions x-pack/plugins/enterprise_search/common/version.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { EuiButton } from '@elastic/eui';

import { CURRENT_MAJOR_VERSION } from '../../../../../common/version';
import { docLinks } from '../../../shared/doc_links';

import { DocumentCreationButtons, DocumentCreationFlyout } from '../document_creation';
import { EmptyEngineOverview } from './engine_overview_empty';
Expand All @@ -24,10 +24,8 @@ describe('EmptyEngineOverview', () => {
expect(wrapper.find('h1').text()).toEqual('Engine setup');
});

it('renders correctly versioned documentation URLs', () => {
expect(wrapper.find(EuiButton).prop('href')).toEqual(
`https://www.elastic.co/guide/en/app-search/${CURRENT_MAJOR_VERSION}/index.html`
);
it('renders a documentation link', () => {
expect(wrapper.find(EuiButton).prop('href')).toEqual(`${docLinks.appSearchBase}/index.html`);
});

it('renders document creation components', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { CURRENT_MAJOR_VERSION } from '../../../common/version';
import { docLinks } from '../shared/doc_links';

export const DOCS_PREFIX = `https://www.elastic.co/guide/en/app-search/${CURRENT_MAJOR_VERSION}`;
export const DOCS_PREFIX = docLinks.appSearchBase;

export const ROOT_PATH = '/';
export const SETUP_GUIDE_PATH = '/setup_guide';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
*/

export { DEFAULT_META } from './default_meta';
export * from './documentation_links';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { docLinks } from './';

describe('DocLinks', () => {
it('setDocLinks', () => {
const links = {
DOC_LINK_VERSION: '',
ELASTIC_WEBSITE_URL: 'https://elastic.co/',
links: {
enterpriseSearch: {
base: 'http://elastic.enterprise.search',
appSearchBase: 'http://elastic.app.search',
workplaceSearchBase: 'http://elastic.workplace.search',
},
},
};

docLinks.setDocLinks(links as any);

expect(docLinks.enterpriseSearchBase).toEqual('http://elastic.enterprise.search');
expect(docLinks.appSearchBase).toEqual('http://elastic.app.search');
expect(docLinks.workplaceSearchBase).toEqual('http://elastic.workplace.search');
expect(docLinks.cloudBase).toEqual('https://elastic.co/guide/en/cloud/current');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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 { DocLinksStart } from 'kibana/public';

class DocLinks {
public enterpriseSearchBase: string;
public appSearchBase: string;
public workplaceSearchBase: string;
public cloudBase: string;

constructor() {
this.enterpriseSearchBase = '';
this.appSearchBase = '';
this.workplaceSearchBase = '';
this.cloudBase = '';
}

public setDocLinks(docLinks: DocLinksStart): void {
this.enterpriseSearchBase = docLinks.links.enterpriseSearch.base;
this.appSearchBase = docLinks.links.enterpriseSearch.appSearchBase;
this.workplaceSearchBase = docLinks.links.enterpriseSearch.workplaceSearchBase;
this.cloudBase = `${docLinks.ELASTIC_WEBSITE_URL}guide/en/cloud/current`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[not a blocker, just leaving this comment here before I forget it] It would be awesome to directly add cloudBase into the Kibana core helper someday! I'm sure other plugins might need it at some point

}
}

export const docLinks = new DocLinks();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* 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.
*/

export { docLinks } from './doc_links';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiPageContent, EuiSteps, EuiText, EuiLink, EuiCallOut } from '@elastic/eui';

import { CLOUD_DOCS_PREFIX, ENT_SEARCH_DOCS_PREFIX } from '../../constants';
import { docLinks } from '../../doc_links';

interface Props {
productName: string;
Expand Down Expand Up @@ -73,7 +73,7 @@ export const CloudSetupInstructions: React.FC<Props> = ({ productName, cloudDepl
values={{
optionsLink: (
<EuiLink
href={`${ENT_SEARCH_DOCS_PREFIX}/configuration.html`}
href={`${docLinks.enterpriseSearchBase}/configuration.html`}
target="_blank"
>
configurable options
Expand Down Expand Up @@ -115,7 +115,7 @@ export const CloudSetupInstructions: React.FC<Props> = ({ productName, cloudDepl
productName,
configurePolicyLink: (
<EuiLink
href={`${CLOUD_DOCS_PREFIX}/ec-configure-index-management.html`}
href={`${docLinks.cloudBase}/ec-configure-index-management.html`}
target="_blank"
>
configure an index lifecycle policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import { generatePath } from 'react-router-dom';

import { CURRENT_MAJOR_VERSION } from '../../../common/version';
import { ENT_SEARCH_DOCS_PREFIX } from '../shared/constants';
import { docLinks } from '../shared/doc_links';

export const SETUP_GUIDE_PATH = '/setup_guide';

Expand All @@ -16,7 +15,7 @@ export const NOT_FOUND_PATH = '/404';
export const LEAVE_FEEDBACK_EMAIL = 'support@elastic.co';
export const LEAVE_FEEDBACK_URL = `mailto:${LEAVE_FEEDBACK_EMAIL}?Subject=Elastic%20Workplace%20Search%20Feedback`;

export const DOCS_PREFIX = `https://www.elastic.co/guide/en/workplace-search/${CURRENT_MAJOR_VERSION}`;
export const DOCS_PREFIX = docLinks.workplaceSearchBase;
export const DOCUMENT_PERMISSIONS_DOCS_URL = `${DOCS_PREFIX}/workplace-search-sources-document-permissions.html`;
export const DOCUMENT_PERMISSIONS_SYNC_DOCS_URL = `${DOCUMENT_PERMISSIONS_DOCS_URL}#sources-permissions-synchronizing`;
export const PRIVATE_SOURCES_DOCS_URL = `${DOCUMENT_PERMISSIONS_DOCS_URL}#sources-permissions-org-private`;
Expand All @@ -42,7 +41,7 @@ export const ZENDESK_DOCS_URL = `${DOCS_PREFIX}/workplace-search-zendesk-connect
export const CUSTOM_SOURCE_DOCS_URL = `${DOCS_PREFIX}/workplace-search-custom-api-sources.html`;
export const CUSTOM_API_DOCS_URL = `${DOCS_PREFIX}/workplace-search-custom-sources-api.html`;
export const CUSTOM_API_DOCUMENT_PERMISSIONS_DOCS_URL = `${CUSTOM_SOURCE_DOCS_URL}#custom-api-source-document-level-access-control`;
export const ENT_SEARCH_LICENSE_MANAGEMENT = `${ENT_SEARCH_DOCS_PREFIX}/license-management.html`;
export const ENT_SEARCH_LICENSE_MANAGEMENT = `${docLinks.enterpriseSearchBase}/license-management.html`;

export const PERSONAL_PATH = '/p';

Expand Down
9 changes: 8 additions & 1 deletion x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import {
AppMountParameters,
CoreStart,
CoreSetup,
HttpSetup,
Plugin,
Expand All @@ -27,6 +28,8 @@ import {
} from '../common/constants';
import { InitialAppData } from '../common/types';

import { docLinks } from './applications/shared/doc_links';

export interface ClientConfigType {
host?: string;
}
Expand Down Expand Up @@ -153,7 +156,11 @@ export class EnterpriseSearchPlugin implements Plugin {
}
}

public start() {}
public start(core: CoreStart) {
// This must be called here in start() and not in `applications/index.tsx` to prevent loading
// race conditions with our apps' `routes.ts` being initialized before `renderApp()`
docLinks.setDocLinks(core.docLinks);
}

public stop() {}

Expand Down