Skip to content

Commit

Permalink
fix(log explorer): show PPL errors in toasts correctly (#2154)
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Li <[email protected]>
  • Loading branch information
joshuali925 authored Sep 10, 2024
1 parent eee686e commit 7aa554a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 58 deletions.
5 changes: 3 additions & 2 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,9 @@ export const Explorer = ({
if (availability !== true) {
await updateQueryInStore(searchedQuery);
}
await fetchData(undefined, undefined, setSummaryStatus);
setEventsLoading(false);
await fetchData(undefined, undefined, setSummaryStatus).finally(() => {
setEventsLoading(false);
});
};

const handleQueryChange = async (newQuery: string) => setTempQuery(newQuery);
Expand Down
104 changes: 49 additions & 55 deletions public/components/event_analytics/explorer/query_assist/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
EuiSmallButton,
EuiComboBoxOptionOption,
EuiCompressedFieldText,
EuiFlexGroup,
EuiFlexItem,
EuiIcon,
EuiInputPopover,
EuiListGroup,
Expand Down Expand Up @@ -325,62 +323,58 @@ export const QueryAssistInput: React.FC<React.PropsWithChildren<Props>> = (props

return (
<>
<EuiFlexGroup gutterSize="none" alignItems="center" justifyContent="center">
<EuiFlexItem grow={false}>
<EuiIcon
className="euiFieldText"
style={{ padding: 8 }}
size="original"
type={chatLogo}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiInputPopover
input={
<EuiCompressedFieldText
inputRef={inputRef}
placeholder="Ask me a question"
disabled={loading}
value={props.nlqInput}
onChange={(e) => {
props.setNlqInput(e.target.value);
dismissCallOut();
}}
onKeyDown={(e) => {
// listen to enter key manually. the cursor jumps to CodeEditor with EuiForm's onSubmit
if (e.key === 'Enter') runAndSummarize();
}}
fullWidth
onFocus={() => {
props.setNeedsUpdate(false);
props.setLastFocusedInput('nlq_input');
if (props.nlqInput.length === 0) setIsPopoverOpen(true);
}}
<EuiInputPopover
input={
<EuiCompressedFieldText
inputRef={inputRef}
placeholder="Ask me a question"
disabled={loading}
value={props.nlqInput}
onChange={(e) => {
props.setNlqInput(e.target.value);
dismissCallOut();
}}
prepend={
<EuiIcon
className="euiFieldText"
style={{ padding: 8 }}
size="original"
type={chatLogo}
/>
}
disableFocusTrap
fullWidth={true}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
onKeyDown={(e) => {
// listen to enter key manually. the cursor jumps to CodeEditor with EuiForm's onSubmit
if (e.key === 'Enter') runAndSummarize();
}}
>
<EuiListGroup flush={true} bordered={false} wrapText={true} maxWidth={false}>
{HARDCODED_SUGGESTIONS[selectedIndex]?.map((question, i) => (
<EuiListGroupItem
key={i}
onClick={() => {
props.setNlqInput(question);
inputRef.current?.focus();
setIsPopoverOpen(false);
}}
label={question}
/>
))}
</EuiListGroup>
</EuiInputPopover>
</EuiFlexItem>
</EuiFlexGroup>
fullWidth
onFocus={() => {
props.setNeedsUpdate(false);
props.setLastFocusedInput('nlq_input');
if (props.nlqInput.length === 0) setIsPopoverOpen(true);
}}
/>
}
disableFocusTrap
fullWidth={true}
isOpen={isPopoverOpen}
closePopover={() => {
setIsPopoverOpen(false);
}}
>
<EuiListGroup flush={true} bordered={false} wrapText={true} maxWidth={false}>
{HARDCODED_SUGGESTIONS[selectedIndex]?.map((question, i) => (
<EuiListGroupItem
key={i}
onClick={() => {
props.setNlqInput(question);
inputRef.current?.focus();
setIsPopoverOpen(false);
}}
label={question}
/>
))}
</EuiListGroup>
</EuiInputPopover>
{props.callOut}
<EuiSpacer size="s" />
{props.children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useFetchEvents = ({ pplService, requestParams }: IFetchEventsParams
) => {
setIsEventsLoading(true);
return pplService
.fetch({ query, format }, errorHandler)
.fetch({ query, format }, undefined, errorHandler)
.then((res: any) => handler(res))
.catch((err: any) => {
console.error(err);
Expand Down

0 comments on commit 7aa554a

Please sign in to comment.