-
Notifications
You must be signed in to change notification settings - Fork 36
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
Adding error message in Search Comparison Tool #267
Conversation
Codecov Report
@@ Coverage Diff @@
## main #267 +/- ##
==========================================
+ Coverage 86.27% 89.95% +3.67%
==========================================
Files 15 16 +1
Lines 204 209 +5
Branches 40 43 +3
==========================================
+ Hits 176 188 +12
+ Misses 26 20 -6
+ Partials 2 1 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Let's include screenshots of 1. the original issue and 2. the result of the fix. |
@smacrakis @noCharger here's some screenshots of the before and after with a simple |
I'd want to see the style of error message be consistent with existing ones, using this issue as an example. |
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.
The UX should be consistent with existing OSD pages. For example, for malformed syntax, we utilize https://elastic.github.io/eui/#/editors-syntax/markdown-editor#error-handling-and-feedback. And we should use toast for additional OpenSearch errors: https://elastic.github.io/eui/#/display/toast#danger
public/components/query_compare/search_result/result_components/result_components.tsx
Show resolved
Hide resolved
public/components/query_compare/search_result/result_components/result_components.tsx
Outdated
Show resolved
Hide resolved
public/components/query_compare/search_result/result_components/result_panel.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Signed-off-by: Sean Li <[email protected]>
Although a full error message would be nice, I'm OK with not including a full error message for now and considering that a refinement for the future. Thanks for your work on this! |
Signed-off-by: Sean Li <[email protected]>
Updated UI with new error messages Query error (successfully sent request): Query error (syntax error in code editor, request not sent): Index not selected error (request not sent): Open to other ideas @noCharger @KrooshalUX @kgcreative @smacrakis |
This looks great! Nice incremental update here |
Can we make "enter a query in ..." msg also in red. I have no preference whether the "result 1" stay in black. |
@noCharger The error message This error message is tied to the Since the |
I wouldn't change the default component behavior. The |
No I am barely talking about the message "Enter a query using OpenSearch Query DSL. Use %Search Text to refer to the text in the search bar."
It does not sound to be a reason why the message cannot be in red. @kgcreative I agree that it was designed as a description/help text, however I'd like to discuss whether we can improve the user experience while interacting with errors. For example, if the user has already input the query but it has a syntax error, does the message |
Forms in general have different components and sections. (See the form layouts section here: https://oui.opensearch.org/1.3/#/forms/form-layouts) The text we are discussing, should not dissappear, because it is a hint to the user that 1) It's using Query DSL (in fact, we should link "Query DSL" to the Query DSL documentation), and it lets users know that %Search Text% is the replacement token for the search query. This should be present whether there is text in the input field or not, and it should not dissappear, since it's directly related to the constraints and syntax of the field above it. In general, we inject any |
Thanks, this is a greate example!
I agree to keep the helper text since it reminds to use Query DSL and replace specific token. Can we move the content from |
Signed-off-by: Sean Li <[email protected]>
Made the changes that @noCharger requested. Thanks for the input @kgcreative! |
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.
This looks awesome! Let's tweak on test converage and resolve all conversation.
@@ -47,7 +56,9 @@ export const ResultPanel = ({ resultNumber, queryResult }: ResultPanelProps) => | |||
</EuiTitle> | |||
</EuiFlexItem> | |||
</EuiFlexGroup> | |||
{queryResult?.hits?.hits?.length ? ( | |||
{queryError.errorResponse.statusCode !== 200 || queryError.queryString.length ? ( | |||
ErrorMessage |
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.
should it be <ErrorMessage />
?
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.
Also this only have the message, do we consider reveal the status code?
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.
Including the status code would be helpful too. Do you have any suggestions on where to include it? So far, I'm thinking:
Query Error: <status code>
<error message>
or
Query Error
<error message>
Status: <status code>
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.
How about <status code> <error type> - <error message>
, if the status code is 5xx, should it still a query error?
public/components/query_compare/search_result/result_components/result_panel.tsx
Show resolved
Hide resolved
Looks so good! |
Signed-off-by: Sean Li <[email protected]>
While writing tests to improve code coverage, I was having difficulty figuring out how to improve test coverage by simulating |
Signed-off-by: Sean Li <[email protected]>
Addressed comments, added the status code to the error message as well. I also noticed that there are many instances where Condensed these repeated if statements into a function and renamed other functions to match accordingly as well. There's definitely more refactoring that can be done in this file, will make note in an issue. |
The new error msg layout looks fine for me.
Can you provide some specific examples? Do you mean that onClickSearch must re-render query failures before returning?
Yes, please also link the new issue to #191 for better tracking |
public/contexts/index.tsx
Outdated
export const initialQueryErrorState: QueryError = { | ||
selectIndex: '', | ||
queryString: '', | ||
errorResponse: { | ||
body: '', | ||
statusCode: 200, | ||
}, | ||
}; |
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.
const validateQuery = ( | ||
selectedIndex: string, | ||
queryString: string, | ||
setQueryError: React.Dispatch<React.SetStateAction<QueryError>> | ||
) => { | ||
// Check if select an index | ||
if (!selectedIndex.length) { | ||
queryError.selectIndex = SelectIndexError.unselected; | ||
setQueryError((error: QueryError) => ({ | ||
...error, | ||
selectIndex: SelectIndexError.unselected, | ||
})); | ||
} | ||
|
||
// Check if query string is empty | ||
if (!queryString.length) { | ||
queryError.queryString = QueryStringError.empty; | ||
setQueryError((error: QueryError) => ({ | ||
...error, | ||
queryString: QueryStringError.empty, | ||
errorRepsonse: { | ||
body: '', | ||
statusCode: 400, | ||
}, | ||
})); | ||
} | ||
}; |
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.
Using functional forms of setState makes sense here to handle potential state consistency issue. For validateQuery
and rewriteQuery
, if it's being refactor to pass state setter instead of the queryError object, the states are updated instantly. Is it a concern since they are helper functions of onClickSearch
?
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.
typo: errorRepsonse -> errorResponse
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.
That's a good point. Had a discussion offline, and we concluded that the validateQuery
helper function does more than what it is supposed to do. Ideally, a validation function should only run validation logic, i.e. it should only return true
or false
and nothing else; the setting should be done in another function. Previously, a variable is passed into validateQuery
and then is set if it meets conditions. That variable is used later to set an error state. I believe that the validateQuery
should be used to return true
or false
in the function that sets states to avoid unnecessary stateful functions, and the error state should be set in a stateful function to maintain consistency. The code before my change seems to do this, will change it back to that.
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.
Overall looks great. Left some comments for quick fix. It's also a good start thinking about the refactoring.
Signed-off-by: Sean Li <[email protected]>
Integration tests pass on local, but are failing for an unknown reason on GitHub actions. We have created an issue here to track. |
Tracking the CI failure opensearch-project/opensearch-dashboards-functional-test#902 |
* adding error message in search comparison tool Signed-off-by: Sean Li <[email protected]> * updating test snapshots Signed-off-by: Sean Li <[email protected]> * adding tests for query error Signed-off-by: Sean Li <[email protected]> * updating tests Signed-off-by: Sean Li <[email protected]> * refactoring QueryError, adding error message to result panel Signed-off-by: Sean Li <[email protected]> * moving helper text to helpText prop Signed-off-by: Sean Li <[email protected]> * adding tests and addressing comments Signed-off-by: Sean Li <[email protected]> * adding more tests, fixing state management, addressing comments Signed-off-by: Sean Li <[email protected]> * reverting changes to validateQuery, addressing comments Signed-off-by: Sean Li <[email protected]> --------- Signed-off-by: Sean Li <[email protected]> (cherry picked from commit 6fb31c8) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* adding error message in search comparison tool * updating test snapshots * adding tests for query error * updating tests * refactoring QueryError, adding error message to result panel * moving helper text to helpText prop * adding tests and addressing comments * adding more tests, fixing state management, addressing comments * reverting changes to validateQuery, addressing comments --------- (cherry picked from commit 6fb31c8) Signed-off-by: Sean Li <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Displays an indicator in case of a query error upon searching in the Search Comparison Tool
Issues Resolved
#262
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.