Skip to content

Commit 8fcb914

Browse files
authored
[Op Selection] Make submitting an invalid query with only a single value convert to a name substring filter. (#28437)
## Summary & Motivation Similar to #28435 ## How I Tested These Changes locally
1 parent 30c1e2b commit 8fcb914

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

js_modules/dagster-ui/packages/ui-core/src/gantt/GanttChartSelectionInput.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import {useCallback} from 'react';
12
import styled from 'styled-components';
23

34
import {RunGraphQueryItem} from './toGraphQueryItems';
45
import {
56
ganttChartSelectionSyntaxSupportedAttributes,
67
useGanttChartSelectionAutoCompleteProvider,
78
} from './useGanttChartSelectionAutoCompleteProvider';
9+
import {isUnmatchedValueQuery} from '../asset-selection/isUnmatchedValueQuery';
10+
import {parseRunSelectionQuery} from '../run-selection/AntlrRunSelection';
811
import {RunSelectionLexer} from '../run-selection/generated/RunSelectionLexer';
912
import {RunSelectionParser} from '../run-selection/generated/RunSelectionParser';
1013
import {InputDiv, SelectionAutoCompleteInput} from '../selection/SelectionInput';
@@ -14,12 +17,23 @@ import {weakMapMemoize} from '../util/weakMapMemoize';
1417
export const GanttChartSelectionInput = ({
1518
items,
1619
value,
17-
onChange,
20+
onChange: _onChange,
1821
}: {
1922
items: RunGraphQueryItem[];
2023
value: string;
2124
onChange: (value: string) => void;
2225
}) => {
26+
const onChange = useCallback(
27+
(value: string) => {
28+
if (parseRunSelectionQuery([], value) instanceof Error && isUnmatchedValueQuery(value)) {
29+
_onChange(`name:"*${value}*"`);
30+
} else {
31+
_onChange(value);
32+
}
33+
},
34+
[_onChange],
35+
);
36+
2337
return (
2438
<Wrapper>
2539
<SelectionAutoCompleteInput

js_modules/dagster-ui/packages/ui-core/src/pipelines/OpGraphSelectionInput.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1+
import {useCallback} from 'react';
12
import styled from 'styled-components';
23

34
import {
45
opGraphSelectionSyntaxSupportedAttributes,
56
useOpGraphSelectionAutoCompleteProvider,
67
} from './useOpGraphSelectionAutoCompleteProvider';
78
import {GraphQueryItem} from '../app/GraphQueryImpl';
9+
import {isUnmatchedValueQuery} from '../asset-selection/isUnmatchedValueQuery';
10+
import {parseOpSelectionQuery} from '../op-selection/AntlrOpSelection';
811
import {OpSelectionLexer} from '../op-selection/generated/OpSelectionLexer';
912
import {OpSelectionParser} from '../op-selection/generated/OpSelectionParser';
1013
import {InputDiv, SelectionAutoCompleteInput} from '../selection/SelectionInput';
1114
import {createSelectionLinter} from '../selection/createSelectionLinter';
1215
import {weakMapMemoize} from '../util/weakMapMemoize';
13-
1416
export const OpGraphSelectionInput = ({
1517
items,
1618
value,
17-
onChange,
19+
onChange: _onChange,
1820
}: {
1921
items: GraphQueryItem[];
2022
value: string;
2123
onChange: (value: string) => void;
2224
}) => {
25+
const onChange = useCallback(
26+
(value: string) => {
27+
if (parseOpSelectionQuery([], value) instanceof Error && isUnmatchedValueQuery(value)) {
28+
_onChange(`name:"*${value}*"`);
29+
} else {
30+
_onChange(value);
31+
}
32+
},
33+
[_onChange],
34+
);
2335
return (
2436
<Wrapper>
2537
<SelectionAutoCompleteInput

0 commit comments

Comments
 (0)