Skip to content

Commit

Permalink
Enable "Run query" for default query (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus authored Sep 14, 2022
1 parent b62757f commit 2a7ad47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
11 changes: 3 additions & 8 deletions catalog/app/containers/Bucket/Queries/ElasticSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,9 @@ const QUERY_PLACEHOLDER = {
}

const isButtonDisabled = (
queryContent: requests.ElasticSearchQuery,
resultsData: requests.AsyncData<requests.ElasticSearchResults>,
error: Error | null,
): boolean => !!error || !queryContent || !!resultsData.case({ Pending: R.T, _: R.F })
): boolean => !!error || !!resultsData.case({ Pending: R.T, _: R.F })

interface ElastiSearchProps extends RouteComponentProps<{ bucket: string }> {}

Expand Down Expand Up @@ -228,7 +227,7 @@ export default function ElastiSearch({
{queryData.case({
Init: () => (
<Form
disabled={isButtonDisabled(customQueryBody, resultsData, queryBodyError)}
disabled={isButtonDisabled(resultsData, queryBodyError)}
onChange={handleQueryBodyChange}
onError={handleError}
onSubmit={handleSubmit}
Expand All @@ -237,11 +236,7 @@ export default function ElastiSearch({
),
Ok: (queryBody: requests.ElasticSearchQuery) => (
<Form
disabled={isButtonDisabled(
customQueryBody || queryBody,
resultsData,
queryBodyError,
)}
disabled={isButtonDisabled(resultsData, queryBodyError)}
onChange={handleQueryBodyChange}
onError={handleError}
onSubmit={handleSubmit}
Expand Down
2 changes: 1 addition & 1 deletion catalog/app/containers/Bucket/Queries/QuerySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function QuerySelect<T>({
classes={{ root: classes.select }}
disabled={!queries.length}
onChange={handleChange}
value={value ? value.key : 'none'}
value={value?.key || 'none'}
>
<M.MenuItem disabled value="none">
<M.ListItemText>Custom</M.ListItemText>
Expand Down
6 changes: 1 addition & 5 deletions catalog/app/containers/Bucket/Queries/QueryViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export default function QueryViewer({
const [error, setError] = React.useState<Error | null>(null)

const handleChange = React.useCallback(
(value: object) => {
onChange(value as requests.ElasticSearchQuery)
},
(value: object) => onChange(value as requests.ElasticSearchQuery),
[onChange],
)

Expand All @@ -92,8 +90,6 @@ export default function QueryViewer({
[t],
)

if (!query) return null

return (
<div className={className}>
<M.Typography className={classes.header} variant="body1">
Expand Down

0 comments on commit 2a7ad47

Please sign in to comment.