forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[App Search] Engine overview layout stub (elastic#83504)
* Set up Overview file * Finish Overview page logic, stub out empty/metric views * Stub in basic empty engine overview - Minus document creation button & API code example * Stub out EngineOverviewMetrics and unavailable empty prompt * Stub out EngineOverMetrics components (stats, charts, logs) * [Refactor] Pull out some document creation i18n strings to constants - They're repeated/reused by the DocumentCreationPopover component * PR feedback: Drop the regex * PR feedback: RecentLogs -> RecentApiLogs * PR feedback: Copy * PR feedback: Copy, sentence-casing
- Loading branch information
Showing
24 changed files
with
841 additions
and
8 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...lugins/enterprise_search/public/applications/app_search/components/analytics/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const TOTAL_DOCUMENTS = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.totalDocuments', | ||
{ defaultMessage: 'Total documents' } | ||
); | ||
|
||
export const TOTAL_API_OPERATIONS = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.totalApiOperations', | ||
{ defaultMessage: 'Total API operations' } | ||
); | ||
|
||
export const TOTAL_QUERIES = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.totalQueries', | ||
{ defaultMessage: 'Total queries' } | ||
); | ||
|
||
export const TOTAL_CLICKS = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.totalClicks', | ||
{ defaultMessage: 'Total clicks' } | ||
); |
12 changes: 12 additions & 0 deletions
12
...plugins/enterprise_search/public/applications/app_search/components/api_logs/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const RECENT_API_EVENTS = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.apiLogs.recent', | ||
{ defaultMessage: 'Recent API events' } | ||
); |
54 changes: 54 additions & 0 deletions
54
...terprise_search/public/applications/app_search/components/document_creation/constants.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiCode, EuiLink } from '@elastic/eui'; | ||
|
||
import { DOCS_PREFIX } from '../../routes'; | ||
|
||
export const DOCUMENT_CREATION_DESCRIPTION = ( | ||
<FormattedMessage | ||
id="xpack.enterpriseSearch.appSearch.engine.documentCreation.description" | ||
defaultMessage="There are three ways to send documents to your engine for indexing. You can paste raw JSON, upload a {jsonCode} file, or {postCode} to the {documentsApiLink} endpoint. Click on your choice below or see {apiStrong}." | ||
values={{ | ||
jsonCode: <EuiCode>.json</EuiCode>, | ||
postCode: <EuiCode>POST</EuiCode>, | ||
documentsApiLink: ( | ||
<EuiLink target="_blank" href={`${DOCS_PREFIX}/indexing-documents-guide.html`}> | ||
documents API | ||
</EuiLink> | ||
), | ||
apiStrong: <strong>Indexing by API</strong>, | ||
}} | ||
/> | ||
); | ||
|
||
export const DOCUMENT_API_INDEXING_TITLE = i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.documentCreation.api.title', | ||
{ defaultMessage: 'Indexing by API' } | ||
); | ||
|
||
export const DOCUMENT_API_INDEXING_DESCRIPTION = ( | ||
<FormattedMessage | ||
id="xpack.enterpriseSearch.appSearch.engine.documentCreation.api.description" | ||
defaultMessage="The {documentsApiLink} can be used to add new documents to your engine, update documents, retrieve documents by id, and delete documents. There are a variety of {clientLibrariesLink} to help you get started." | ||
values={{ | ||
documentsApiLink: ( | ||
<EuiLink target="_blank" href={`${DOCS_PREFIX}/indexing-documents-guide.html`}> | ||
documents API | ||
</EuiLink> | ||
), | ||
clientLibrariesLink: ( | ||
<EuiLink target="_blank" href={`${DOCS_PREFIX}/api-clients.html`}> | ||
client libraries | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...rise_search/public/applications/app_search/components/engine_overview/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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 { UnavailablePrompt } from './unavailable_prompt'; | ||
export { TotalStats } from './total_stats'; | ||
export { TotalCharts } from './total_charts'; | ||
export { RecentApiLogs } from './recent_api_logs'; |
32 changes: 32 additions & 0 deletions
32
...ic/applications/app_search/components/engine_overview/components/recent_api_logs.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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 { setMockValues } from '../../../../__mocks__/kea.mock'; | ||
|
||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
|
||
import { EuiButton } from '../../../../shared/react_router_helpers'; | ||
|
||
import { RecentApiLogs } from './recent_api_logs'; | ||
|
||
describe('RecentApiLogs', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
beforeAll(() => { | ||
jest.clearAllMocks(); | ||
setMockValues({ | ||
engineName: 'some-engine', | ||
}); | ||
wrapper = shallow(<RecentApiLogs />); | ||
}); | ||
|
||
it('renders the recent API logs table', () => { | ||
expect(wrapper.find('h2').text()).toEqual('Recent API events'); | ||
expect(wrapper.find(EuiButton).prop('to')).toEqual('/engines/some-engine/api-logs'); | ||
// TODO: expect(wrapper.find(ApiLogsTable)).toHaveLength(1) | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
.../public/applications/app_search/components/engine_overview/components/recent_api_logs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 { useValues } from 'kea'; | ||
|
||
import { | ||
EuiPageContent, | ||
EuiPageContentHeader, | ||
EuiPageContentHeaderSection, | ||
EuiPageContentBody, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
|
||
import { EuiButton } from '../../../../shared/react_router_helpers'; | ||
|
||
import { ENGINE_API_LOGS_PATH, getEngineRoute } from '../../../routes'; | ||
import { RECENT_API_EVENTS } from '../../api_logs/constants'; | ||
import { VIEW_API_LOGS } from '../constants'; | ||
|
||
import { EngineLogic } from '../../engine'; | ||
|
||
export const RecentApiLogs: React.FC = () => { | ||
const { engineName } = useValues(EngineLogic); | ||
const engineRoute = getEngineRoute(engineName); | ||
|
||
return ( | ||
<EuiPageContent> | ||
<EuiPageContentHeader responsive={false}> | ||
<EuiPageContentHeaderSection> | ||
<EuiTitle size="xs"> | ||
<h2>{RECENT_API_EVENTS}</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeaderSection> | ||
<EuiPageContentHeaderSection> | ||
<EuiButton to={engineRoute + ENGINE_API_LOGS_PATH} size="s"> | ||
{VIEW_API_LOGS} | ||
</EuiButton> | ||
</EuiPageContentHeaderSection> | ||
</EuiPageContentHeader> | ||
<EuiPageContentBody> | ||
TODO: API Logs Table | ||
{/* <ApiLogsTable hidePagination={true} /> */} | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
); | ||
}; |
46 changes: 46 additions & 0 deletions
46
...ublic/applications/app_search/components/engine_overview/components/total_charts.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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 { setMockValues } from '../../../../__mocks__/kea.mock'; | ||
|
||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
|
||
import { EuiButton } from '../../../../shared/react_router_helpers'; | ||
|
||
import { TotalCharts } from './total_charts'; | ||
|
||
describe('TotalCharts', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
beforeAll(() => { | ||
jest.clearAllMocks(); | ||
setMockValues({ | ||
engineName: 'some-engine', | ||
startDate: '1970-01-01', | ||
endDate: '1970-01-08', | ||
queriesPerDay: [0, 1, 2, 3, 5, 10, 50], | ||
operationsPerDay: [0, 0, 0, 0, 0, 0, 0], | ||
}); | ||
wrapper = shallow(<TotalCharts />); | ||
}); | ||
|
||
it('renders the total queries chart', () => { | ||
const chart = wrapper.find('[data-test-subj="TotalQueriesChart"]'); | ||
|
||
expect(chart.find('h2').text()).toEqual('Total queries'); | ||
expect(chart.find(EuiButton).prop('to')).toEqual('/engines/some-engine/analytics'); | ||
// TODO: find chart component | ||
}); | ||
|
||
it('renders the total API operations chart', () => { | ||
const chart = wrapper.find('[data-test-subj="TotalApiOperationsChart"]'); | ||
|
||
expect(chart.find('h2').text()).toEqual('Total API operations'); | ||
expect(chart.find(EuiButton).prop('to')).toEqual('/engines/some-engine/api-logs'); | ||
// TODO: find chart component | ||
}); | ||
}); |
Oops, something went wrong.