-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[App Search] Convert Analytics views to new page template (#102851)
* Convert AnalyticsHeader to AnalyticsFilters - it's basically the same component as before, but without the title section/log retention tooltip, since the header/title will be handled by the new page template * Update AnalyticsLayout to use new page template + add new test_helper for header children * Update breadcrumb behavior - Set analytic breadcrumbs in AnalyticsLayout rather than AnalyticsRouter - Update individual views to pass breadcrumbs (consistent with new page template API) * Update router
- Loading branch information
Constance
committed
Jun 22, 2021
1 parent
fd0c1fa
commit 00a9f84
Showing
18 changed files
with
199 additions
and
242 deletions.
There are no files selected for viewing
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
111 changes: 111 additions & 0 deletions
111
...arch/public/applications/app_search/components/analytics/components/analytics_filters.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,111 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
import moment from 'moment'; | ||
import queryString from 'query-string'; | ||
|
||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSelect, | ||
EuiDatePickerRange, | ||
EuiDatePicker, | ||
EuiButton, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { AnalyticsLogic } from '../'; | ||
import { KibanaLogic } from '../../../../shared/kibana'; | ||
|
||
import { DEFAULT_START_DATE, DEFAULT_END_DATE, SERVER_DATE_FORMAT } from '../constants'; | ||
import { convertTagsToSelectOptions } from '../utils'; | ||
|
||
export const AnalyticsFilters: React.FC = () => { | ||
const { allTags } = useValues(AnalyticsLogic); | ||
const { history } = useValues(KibanaLogic); | ||
|
||
// Parse out existing filters from URL query string | ||
const { start, end, tag } = queryString.parse(history.location.search); | ||
const [startDate, setStartDate] = useState( | ||
start ? moment(start, SERVER_DATE_FORMAT) : moment(DEFAULT_START_DATE) | ||
); | ||
const [endDate, setEndDate] = useState( | ||
end ? moment(end, SERVER_DATE_FORMAT) : moment(DEFAULT_END_DATE) | ||
); | ||
const [currentTag, setCurrentTag] = useState((tag as string) || ''); | ||
|
||
// Set the current URL query string on filter | ||
const onApplyFilters = () => { | ||
const search = queryString.stringify({ | ||
start: moment(startDate).format(SERVER_DATE_FORMAT), | ||
end: moment(endDate).format(SERVER_DATE_FORMAT), | ||
tag: currentTag || undefined, | ||
}); | ||
history.push({ search }); | ||
}; | ||
|
||
const hasInvalidDateRange = startDate > endDate; | ||
|
||
return ( | ||
<EuiFlexGroup alignItems="center" justifyContent="flexEnd" gutterSize="m"> | ||
<EuiFlexItem> | ||
<EuiSelect | ||
options={convertTagsToSelectOptions(allTags)} | ||
value={currentTag} | ||
onChange={(e) => setCurrentTag(e.target.value)} | ||
aria-label={i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.filters.tagAriaLabel', | ||
{ defaultMessage: 'Filter by analytics tag"' } | ||
)} | ||
fullWidth | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiDatePickerRange | ||
startDateControl={ | ||
<EuiDatePicker | ||
selected={startDate} | ||
onChange={(date) => date && setStartDate(date)} | ||
startDate={startDate} | ||
endDate={endDate} | ||
isInvalid={hasInvalidDateRange} | ||
aria-label={i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.filters.startDateAriaLabel', | ||
{ defaultMessage: 'Filter by start date' } | ||
)} | ||
/> | ||
} | ||
endDateControl={ | ||
<EuiDatePicker | ||
selected={endDate} | ||
onChange={(date) => date && setEndDate(date)} | ||
startDate={startDate} | ||
endDate={endDate} | ||
isInvalid={hasInvalidDateRange} | ||
aria-label={i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.filters.endDateAriaLabel', | ||
{ defaultMessage: 'Filter by end date' } | ||
)} | ||
/> | ||
} | ||
fullWidth | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton fill isDisabled={hasInvalidDateRange} onClick={onApplyFilters}> | ||
{i18n.translate( | ||
'xpack.enterpriseSearch.appSearch.engine.analytics.filters.applyButtonLabel', | ||
{ defaultMessage: 'Apply filters' } | ||
)} | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
}; |
15 changes: 0 additions & 15 deletions
15
...arch/public/applications/app_search/components/analytics/components/analytics_header.scss
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.