-
Notifications
You must be signed in to change notification settings - Fork 58
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
Cypress test update and related linting fixes #220
Changes from all commits
b03d9ab
a773079
512a0ef
7fc31ae
91d1eee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,7 +290,7 @@ export interface PatternTableData { | |
pattern: string; | ||
sampleLog: string; | ||
anomalyCount?: number; | ||
}; | ||
} | ||
|
||
export interface ConfigListEntry { | ||
label: string; | ||
|
@@ -380,7 +380,7 @@ export interface VisMeta { | |
} | ||
|
||
export interface VisualizationState { | ||
query: Query; | ||
queryState: Query; | ||
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. any reason why this was changed? 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. linting fix, there's a global 'query' within the context where scoped 'query' will shadow the global one. |
||
visData: any; | ||
visConfMetadata: ConfigList; | ||
visMeta: VisMeta; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import './search.scss'; | ||
|
||
import React, { useState } from 'react'; | ||
import { isEqual } from 'lodash'; | ||
import { | ||
EuiFlexGroup, | ||
EuiButton, | ||
|
@@ -16,7 +17,7 @@ import { | |
EuiBadge, | ||
EuiContextMenuPanel, | ||
EuiToolTip, | ||
EuiCallOut | ||
EuiCallOut, | ||
} from '@elastic/eui'; | ||
import { DatePicker } from './date_picker'; | ||
import '@algolia/autocomplete-theme-classic'; | ||
|
@@ -26,6 +27,7 @@ import { PPLReferenceFlyout } from '../helpers'; | |
import { uiSettingsService } from '../../../../common/utils'; | ||
import { APP_ANALYTICS_TAB_ID_REGEX } from '../../../../common/constants/explorer'; | ||
import { LiveTailButton, StopLiveButton } from '../live_tail/live_tail_button'; | ||
import { PPL_SPAN_REGEX } from '../../../../common/constants/shared'; | ||
export interface IQueryBarProps { | ||
query: string; | ||
tempQuery: string; | ||
|
@@ -68,7 +70,6 @@ export const Search = (props: any) => { | |
showSavePanelOptionsList, | ||
showSaveButton = true, | ||
handleTimeRangePickerRefresh, | ||
liveTailButton, | ||
isLiveTailPopoverOpen, | ||
closeLiveTailPopover, | ||
popoverItems, | ||
|
@@ -84,14 +85,9 @@ export const Search = (props: any) => { | |
liveTailName, | ||
searchError = null, | ||
curVisId, | ||
spanValue, | ||
setSubType, | ||
metricMeasure, | ||
setMetricMeasure, | ||
setMetricLabel, | ||
metricChecked, | ||
} = props; | ||
|
||
const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX); | ||
const [isSavePanelOpen, setIsSavePanelOpen] = useState(false); | ||
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); | ||
|
@@ -221,15 +217,12 @@ export const Search = (props: any) => { | |
showOptionList={ | ||
showSavePanelOptionsList && | ||
searchBarConfigs[selectedSubTabId]?.showSavePanelOptionsList | ||
|
||
} | ||
curVisId={curVisId} | ||
spanValue={spanValue} | ||
setSubType={setSubType} | ||
metricMeasure={metricMeasure} | ||
setMetricMeasure={setMetricMeasure} | ||
setMetricLabel={setMetricLabel} | ||
metricChecked={metricChecked} | ||
isSaveAsMetricEnabled={ | ||
isEqual(curVisId, 'line') && tempQuery.match(PPL_SPAN_REGEX) !== null | ||
} | ||
Comment on lines
+223
to
+225
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. Can you explain what is this doing/why this change was made here? Any issue linking the bug here? 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.
|
||
/> | ||
<EuiPopoverFooter> | ||
<EuiFlexGroup justifyContent="flexEnd"> | ||
|
@@ -262,17 +255,19 @@ export const Search = (props: any) => { | |
</> | ||
)} | ||
</EuiFlexGroup> | ||
{ searchError && searchError.error && ( | ||
{searchError && searchError.error && ( | ||
<EuiFlexGroup gutterSize="s" justifyContent="flexStart" alignItems="flexStart"> | ||
<EuiFlexItem> | ||
<EuiCallOut title={JSON.parse(searchError.message).error.reason} color="danger" iconType="alert"> | ||
<p> | ||
{JSON.parse(searchError.message).error.details} | ||
</p> | ||
<EuiCallOut | ||
title={JSON.parse(searchError.message).error.reason} | ||
color="danger" | ||
iconType="alert" | ||
> | ||
<p>{JSON.parse(searchError.message).error.details}</p> | ||
</EuiCallOut> | ||
</EuiFlexItem> | ||
</EuiFlexGroup>) | ||
} | ||
</EuiFlexGroup> | ||
)} | ||
{flyout} | ||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,10 +187,8 @@ export const Explorer = ({ | |
value: string; | ||
}>(); | ||
const [viewLogPatterns, setViewLogPatterns] = useState(false); | ||
const [spanValue, setSpanValue] = useState(false); | ||
const [subType, setSubType] = useState('visualization'); | ||
const [metricMeasure, setMetricMeasure] = useState(''); | ||
const [metricLabel, setMetricLabel] = useState([]); | ||
const [metricChecked, setMetricChecked] = useState(false); | ||
const queryRef = useRef(); | ||
const appBasedRef = useRef(''); | ||
|
@@ -570,7 +568,10 @@ export const Explorer = ({ | |
await updateQueryInStore(patternSelectQuery); | ||
// Passing in empty string will remove pattern query | ||
const patternErrorHandler = getErrorHandler('Error fetching patterns'); | ||
getPatterns(selectedIntervalRef.current?.value.replace(/^auto_/, '') || 'y', patternErrorHandler); | ||
getPatterns( | ||
selectedIntervalRef.current?.value.replace(/^auto_/, '') || 'y', | ||
patternErrorHandler | ||
); | ||
} | ||
}; | ||
|
||
|
@@ -645,7 +646,10 @@ export const Explorer = ({ | |
getErrorHandler('Error overriding default pattern') | ||
); | ||
setIsOverridingPattern(false); | ||
await getPatterns(selectedIntervalRef.current?.value.replace(/^auto_/, '') || 'y', getErrorHandler('Error fetching patterns')); | ||
await getPatterns( | ||
selectedIntervalRef.current?.value.replace(/^auto_/, '') || 'y', | ||
getErrorHandler('Error fetching patterns') | ||
); | ||
}; | ||
|
||
const totalHits: number = useMemo(() => { | ||
|
@@ -850,7 +854,10 @@ export const Explorer = ({ | |
}) | ||
); | ||
await getPatterns( | ||
selectedIntervalRef.current?.value.replace(/^auto_/, '') || 'y', | ||
selectedIntervalRef.current?.value.replace( | ||
/^auto_/, | ||
'' | ||
) || 'y', | ||
getErrorHandler('Error fetching patterns') | ||
); | ||
}} | ||
|
@@ -1253,7 +1260,7 @@ export const Explorer = ({ | |
? JSON.stringify(userVizConfigs[curVisId]) | ||
: JSON.stringify({}), | ||
description: vizDescription, | ||
subType: subType, | ||
subType, | ||
}) | ||
.then((res: any) => { | ||
setToast( | ||
|
@@ -1288,7 +1295,7 @@ export const Explorer = ({ | |
? JSON.stringify(userVizConfigs[curVisId]) | ||
: JSON.stringify({}), | ||
description: vizDescription, | ||
subType: subType, | ||
subType, | ||
}) | ||
.then((res: any) => { | ||
batch(() => { | ||
|
@@ -1430,25 +1437,17 @@ export const Explorer = ({ | |
[tempQuery] | ||
); | ||
|
||
const generateViewQuery = (query: string) => { | ||
if (query.includes(appBaseQuery)) { | ||
if (query.includes('|')) { | ||
const generateViewQuery = (queryString: string) => { | ||
if (queryString.includes(appBaseQuery)) { | ||
if (queryString.includes('|')) { | ||
// Some scenarios have ' | ' after base query and some have '| ' | ||
return query.replace(' | ', '| ').replace(appBaseQuery + '| ', ''); | ||
return queryString.replace(' | ', '| ').replace(appBaseQuery + '| ', ''); | ||
} | ||
return ''; | ||
} | ||
return query; | ||
return queryString; | ||
}; | ||
|
||
useEffect(() => { | ||
if (isEqual(selectedContentTabId, TAB_CHART_ID)) { | ||
const statsTokens = queryManager.queryParser().parse(tempQuery).getStats(); | ||
const updatedDataConfig = getDefaultVisConfig(statsTokens); | ||
setSpanValue(!isEqual(typeof updatedDataConfig.span, 'undefined')); | ||
} | ||
}, [tempQuery, selectedContentTabId, curVisId]); | ||
|
||
Comment on lines
-1444
to
-1451
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. why removed? 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. The way metric uses to determine disabled/enabled saving-as-metric switch, as far as I can see, only cares about if the query contains timespan on saving-panel open. This code piece does the work to record timespan but it triggers query manager parsing and setSpanValue on every query typing/changing which causes performance degradation. |
||
return ( | ||
<TabContext.Provider | ||
value={{ | ||
|
@@ -1469,7 +1468,9 @@ export const Explorer = ({ | |
query, | ||
}} | ||
> | ||
<div className={`dscAppContainer${uiSettingsService.get('theme:darkMode') && ' explorer-dark'}`}> | ||
<div | ||
className={`dscAppContainer${uiSettingsService.get('theme:darkMode') && ' explorer-dark'}`} | ||
> | ||
<Search | ||
key="search-component" | ||
query={appLogEvents ? generateViewQuery(tempQuery) : query[RAW_QUERY]} | ||
|
@@ -1504,12 +1505,7 @@ export const Explorer = ({ | |
liveTailName={liveTailNameRef.current} | ||
searchError={explorerVisualizations} | ||
curVisId={curVisId} | ||
spanValue={spanValue} | ||
setSubType={setSubType} | ||
metricMeasure={metricMeasure} | ||
setMetricMeasure={setMetricMeasure} | ||
setMetricLabel={setMetricLabel} | ||
metricChecked={metricChecked} | ||
/> | ||
<EuiTabbedContent | ||
className="mainContentTabs" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -738,7 +738,7 @@ exports[`Saved query table component Renders saved query table 1`] = ` | |
onMouseOver={[Function]} | ||
> | ||
<EuiSwitch | ||
checked={true} | ||
checked={false} | ||
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. was this behavior not tested properly - this seems like a pretty big snapshot change? |
||
compressed={true} | ||
disabled={true} | ||
label="Save as Metric" | ||
|
@@ -751,7 +751,7 @@ exports[`Saved query table component Renders saved query table 1`] = ` | |
className="euiSwitch euiSwitch--compressed" | ||
> | ||
<button | ||
aria-checked={true} | ||
aria-checked={false} | ||
aria-labelledby="random_html_id" | ||
className="euiSwitch__button" | ||
disabled={true} | ||
|
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.
Question: how is this index timestamp determined - is it when you add the data? Will this break next year?
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.
timestamp is determined automatically (if users don't override) in event explorer by looking for the first encountered date type in an index mappings. It will not break as long as the sample data is not changed.