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

Fix metrics switch #1247

Merged
merged 5 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ export const Search = (props: any) => {
curVisId,
spanValue,
setSubType,
metricMeasure,
setMetricMeasure,
setMetricLabel,
metricChecked,
} = props;

const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX);
Expand Down Expand Up @@ -224,8 +226,10 @@ export const Search = (props: any) => {
curVisId={curVisId}
spanValue={spanValue}
setSubType={setSubType}
metricMeasure={metricMeasure}
setMetricMeasure={setMetricMeasure}
setMetricLabel={setMetricLabel}
metricChecked={metricChecked}
/>
<EuiPopoverFooter>
<EuiFlexGroup justifyContent="flexEnd">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const Explorer = ({
const [subType, setSubType] = useState('visualization');
const [metricMeasure, setMetricMeasure] = useState('');
const [metricLabel, setMetricLabel] = useState([]);
const [metricChecked, setMetricChecked] = useState(false);
const queryRef = useRef();
const appBasedRef = useRef('');
appBasedRef.current = appBaseQuery;
Expand Down Expand Up @@ -262,6 +263,7 @@ export const Explorer = ({
const isSavedQuery = has(savedData, SAVED_QUERY);
const savedType = isSavedQuery ? SAVED_QUERY : SAVED_VISUALIZATION;
const objectData = isSavedQuery ? savedData.savedQuery : savedData.savedVisualization;
const isSavedVisualization = savedData.savedVisualization;
const currQuery = appLogEvents
? objectData?.query.replace(appBaseQuery + '| ', '')
: objectData?.query || '';
Expand Down Expand Up @@ -329,6 +331,13 @@ export const Explorer = ({
setTempQuery((staleTempQuery: string) => {
return appLogEvents ? currQuery : objectData?.query || staleTempQuery;
});
if (isSavedVisualization?.sub_type) {
if (isSavedVisualization?.sub_type === 'metric') {
setMetricChecked(true);
setMetricMeasure(isSavedVisualization?.units_of_measure);
}
setSubType(isSavedVisualization?.sub_type);
}
const tabToBeFocused = isSavedQuery
? TYPE_TAB_MAPPING[SAVED_QUERY]
: TYPE_TAB_MAPPING[SAVED_VISUALIZATION];
Expand Down Expand Up @@ -1059,11 +1068,8 @@ export const Explorer = ({
isLiveTailOnRef.current,
patternsData,
viewLogPatterns,
isPatternConfigPopoverOpen,
patternRegexInput,
kavithacm marked this conversation as resolved.
Show resolved Hide resolved
userVizConfigs,
]);

const handleContentTabClick = (selectedTab: IQueryTab) => setSelectedContentTab(selectedTab.id);

const updateQueryInStore = async (updateQuery: string) => {
Expand Down Expand Up @@ -1270,7 +1276,6 @@ export const Explorer = ({
description: vizDescription,
subType: subType,
unitsOfMeasure: metricMeasure,
// selectedLabels: metricLabel
})
.then((res: any) => {
setToast(
Expand Down Expand Up @@ -1307,7 +1312,6 @@ export const Explorer = ({
description: vizDescription,
subType: subType,
unitsOfMeasure: metricMeasure,
// selectedLabels: metricLabel
})
.then((res: any) => {
batch(() => {
Expand Down Expand Up @@ -1512,8 +1516,10 @@ export const Explorer = ({
curVisId={curVisId}
spanValue={spanValue}
setSubType={setSubType}
metricMeasure={metricMeasure}
setMetricMeasure={setMetricMeasure}
setMetricLabel={setMetricLabel}
metricChecked={metricChecked}
/>
<EuiTabbedContent
className="mainContentTabs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ exports[`Saved query table component Renders saved query table 1`] = `
curVisId="line"
handleNameChange={[MockFunction]}
handleOptionChange={[MockFunction]}
metricChecked={true}
metricMeasure="hours (h)"
savePanelName="Count by depature"
savedObjects={
SavedObjects {
Expand Down Expand Up @@ -736,7 +738,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
onMouseOver={[Function]}
>
<EuiSwitch
checked={false}
checked={true}
compressed={true}
disabled={true}
label="Save as Metric"
Expand All @@ -749,7 +751,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
className="euiSwitch euiSwitch--compressed"
>
<button
aria-checked={false}
aria-checked={true}
aria-labelledby="random_html_id"
className="euiSwitch__button"
disabled={true}
Expand Down Expand Up @@ -785,5 +787,198 @@ exports[`Saved query table component Renders saved query table 1`] = `
</div>
</div>
</EuiFormRow>
<EuiSpacer
size="s"
>
<div
className="euiSpacer euiSpacer--s"
/>
</EuiSpacer>
<EuiTitle
size="xxs"
>
<h3
className="euiTitle euiTitle--xxsmall"
>
Units of Measure
</h3>
</EuiTitle>
<EuiFormRow
describedByIds={Array []}
display="row"
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
labelType="label"
>
<div
className="euiFormRow"
id="random_html_id-row"
>
<div
className="euiFormRow__fieldWrapper"
>
<EuiSelect
data-test-subj="eventExplorer__metricMeasureSaveSelectBox"
id="random_html_id"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
options={
Array [
Object {
"text": "seconds (s)",
"value": "seconds (s)",
},
Object {
"text": "hours (h)",
"value": "hours (h)",
},
Object {
"text": "celsius (C)",
"value": "celsius (C)",
},
Object {
"text": "farenheit (F)",
"value": "farenheit (F)",
},
Object {
"text": "meters (m)",
"value": "meters (m)",
},
Object {
"text": "kilometers (k)",
"value": "kilometers (k)",
},
]
}
placeholder="Select measure"
value="hours (h)"
>
<EuiFormControlLayout
compressed={false}
fullWidth={false}
icon={
Object {
"side": "right",
"type": "arrowDown",
}
}
inputId="random_html_id"
isLoading={false}
>
<div
className="euiFormControlLayout"
>
<div
className="euiFormControlLayout__childrenWrapper"
>
<EuiValidatableControl>
<select
className="euiSelect"
data-test-subj="eventExplorer__metricMeasureSaveSelectBox"
id="random_html_id"
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
onMouseUp={[Function]}
placeholder="Select measure"
value="hours (h)"
>
<option
key="0"
value="seconds (s)"
>
seconds (s)
</option>
<option
key="1"
value="hours (h)"
>
hours (h)
</option>
<option
key="2"
value="celsius (C)"
>
celsius (C)
</option>
<option
key="3"
value="farenheit (F)"
>
farenheit (F)
</option>
<option
key="4"
value="meters (m)"
>
meters (m)
</option>
<option
key="5"
value="kilometers (k)"
>
kilometers (k)
</option>
</select>
</EuiValidatableControl>
<EuiFormControlLayoutIcons
compressed={false}
icon={
Object {
"side": "right",
"type": "arrowDown",
}
}
isLoading={false}
>
<div
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<EuiFormControlLayoutCustomIcon
size="m"
type="arrowDown"
>
<span
className="euiFormControlLayoutCustomIcon"
>
<EuiIcon
aria-hidden="true"
className="euiFormControlLayoutCustomIcon__icon"
size="m"
type="arrowDown"
>
<EuiIconEmpty
aria-hidden={true}
className="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
className="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
</span>
</EuiFormControlLayoutCustomIcon>
</div>
</EuiFormControlLayoutIcons>
</div>
</div>
</EuiFormControlLayout>
</EuiSelect>
</div>
</div>
</EuiFormRow>
</SavePanel>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ describe('Saved query table component', () => {
savePanelName={'Count by depature'}
showOptionList={true}
curVisId={'line'}
spanValue={false}
setSubType={'metric'}
spanValue={false}
setSubType={'metric'}
setMetricMeasure={'hours (h)'}
setMetricLabel={setMetricLabel}
/>
setMetricLabel={setMetricLabel}
metricMeasure={'hours (h)'}
metricChecked={true}
/>
);

wrapper.update();
Expand Down
Loading