-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[App Search] Engine overview layout stub #83504
Changes from 6 commits
fa9d12c
7ac0e3b
0d71c73
1097787
2be4c35
2fca086
4cd44f9
5e945c3
4d4747c
9bc3780
cc01d6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' } | ||
); | ||
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' } | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above, this title is also used in the API Logs view |
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 | ||
cee-chen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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> | ||
), | ||
}} | ||
/> | ||
); |
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 { RecentLogs } from './recent_logs'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went back and forth a little on whether I should split out the metrics view into sub-components, and I'm very happy I did in the end. The code feels much easier to test and reason about in smaller bite-sized files. I left the empty engine view as one piece/component but definitely open to splitting that up as well if folks think that will help readability. |
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 { RecentLogs } from './recent_logs'; | ||
|
||
describe('RecentLogs', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
beforeAll(() => { | ||
jest.clearAllMocks(); | ||
setMockValues({ | ||
engineName: 'some-engine', | ||
}); | ||
wrapper = shallow(<RecentLogs />); | ||
}); | ||
|
||
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) | ||
}); | ||
}); |
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 RecentLogs: React.FC = () => { | ||
cee-chen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { engineName } = useValues(EngineLogic); | ||
const engineRoute = getEngineRoute(engineName); | ||
|
||
return ( | ||
<EuiPageContent> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantically, are pages meant to have multiple EuiPageContent in EUI? Or is there some other tag available for page sections? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantically I don't see a reason why not as they're not using |
||
<EuiPageContentHeader responsive={false}> | ||
<EuiPageContentHeaderSection> | ||
<EuiTitle size="xs"> | ||
<h2>{RECENT_API_EVENTS}</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeaderSection> | ||
<EuiPageContentHeaderSection> | ||
<EuiButton to={engineRoute + ENGINE_API_LOGS_PATH} size="s"> | ||
cee-chen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{VIEW_API_LOGS} | ||
</EuiButton> | ||
</EuiPageContentHeaderSection> | ||
</EuiPageContentHeader> | ||
<EuiPageContentBody> | ||
TODO: API Logs Table | ||
{/* <ApiLogsTable hidePagination={true} /> */} | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
); | ||
}; |
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 | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These constants are also used in the Analytics view so I figured I'd do myself a favor and start a constants file early.