From d407e2346f96e0cedaf16e834e285a188c1da3db Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Sun, 29 Dec 2024 03:19:35 -0500 Subject: [PATCH 1/6] minor api change for internal pr --- .../asset-selection/useAssetSelectionInput.tsx | 15 ++++++++++----- .../src/selection/SelectionAutoCompleteInput.tsx | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionInput.tsx b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionInput.tsx index 70bfc494821a5..669f97f0622ac 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionInput.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionInput.tsx @@ -13,11 +13,16 @@ export const useAssetSelectionInput = < key: {path: Array}; definition?: FilterableAssetDefinition | null; }, ->( - assets: T[], - assetsLoading?: boolean, -) => { - const [assetSelection, setAssetSelection] = useAssetSelectionState(); +>({ + assets, + assetsLoading, + syncCatalogView = true, +}: { + assets: T[]; + assetsLoading?: boolean; + syncCatalogView?: boolean; +}) => { + const [assetSelection, setAssetSelection] = useAssetSelectionState({syncCatalogView}); const {graphQueryItems, loading, filtered} = useAssetSelectionFiltering({ assetSelection, diff --git a/js_modules/dagster-ui/packages/ui-core/src/selection/SelectionAutoCompleteInput.tsx b/js_modules/dagster-ui/packages/ui-core/src/selection/SelectionAutoCompleteInput.tsx index e021299a40ee4..8dee76b07deaa 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/selection/SelectionAutoCompleteInput.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/selection/SelectionAutoCompleteInput.tsx @@ -102,6 +102,10 @@ export const SelectionAutoCompleteInput = , N showHint(instance, hintRef.current); }); + cmInstance.current.on('focus', (instance: Editor) => { + showHint(instance, hintRef.current); + }); + cmInstance.current.on('cursorActivity', (instance: Editor) => { applyStaticSyntaxHighlighting(instance); showHint(instance, hintRef.current); From 6d8f2b390a56d404a798f42def21a65efdb1d76e Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Sun, 29 Dec 2024 03:23:14 -0500 Subject: [PATCH 2/6] minor api change for internal pr --- .../ui-core/src/asset-selection/useAssetSelectionState.oss.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx index 080cc61ff0b20..d5e8574f50aba 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx @@ -1,6 +1,6 @@ import {useQueryPersistedState} from '../hooks/useQueryPersistedState'; -export function useAssetSelectionState() { +export function useAssetSelectionState(..._any: any[]) { return useQueryPersistedState({ queryKey: 'asset-selection', defaults: {['asset-selection']: ''}, From 91047e370e2de514d69bc6311b4cccae99fb34b3 Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Mon, 30 Dec 2024 02:53:26 -0500 Subject: [PATCH 3/6] changes --- .../src/asset-selection/input/AssetSelectionInput.oss.tsx | 6 ++---- .../ui-core/src/asset-selection/useAssetSelectionInput.tsx | 4 +--- .../src/asset-selection/useAssetSelectionState.oss.tsx | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/input/AssetSelectionInput.oss.tsx b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/input/AssetSelectionInput.oss.tsx index ef87451179f9b..bf32cb6d4f1d4 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/input/AssetSelectionInput.oss.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/input/AssetSelectionInput.oss.tsx @@ -27,6 +27,8 @@ interface AssetSelectionInputProps { const FUNCTIONS = ['sinks', 'roots']; +const linter = createSelectionLinter({Lexer: AssetSelectionLexer, Parser: AssetSelectionParser}); + export const AssetSelectionInput = ({value, onChange, assets}: AssetSelectionInputProps) => { const attributesMap = useMemo(() => { const assetNamesSet: Set = new Set(); @@ -87,10 +89,6 @@ export const AssetSelectionInput = ({value, onChange, assets}: AssetSelectionInp }; }, [assets]); - const linter = useMemo( - () => createSelectionLinter({Lexer: AssetSelectionLexer, Parser: AssetSelectionParser}), - [], - ); return ( ({ assets, assetsLoading, - syncCatalogView = true, }: { assets: T[]; assetsLoading?: boolean; - syncCatalogView?: boolean; }) => { - const [assetSelection, setAssetSelection] = useAssetSelectionState({syncCatalogView}); + const [assetSelection, setAssetSelection] = useAssetSelectionState(); const {graphQueryItems, loading, filtered} = useAssetSelectionFiltering({ assetSelection, diff --git a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx index d5e8574f50aba..080cc61ff0b20 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/asset-selection/useAssetSelectionState.oss.tsx @@ -1,6 +1,6 @@ import {useQueryPersistedState} from '../hooks/useQueryPersistedState'; -export function useAssetSelectionState(..._any: any[]) { +export function useAssetSelectionState() { return useQueryPersistedState({ queryKey: 'asset-selection', defaults: {['asset-selection']: ''}, From 3f0383fb50f601d723f509abe4b8fe5bfeee133f Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Thu, 2 Jan 2025 09:22:39 -0500 Subject: [PATCH 4/6] update callsite --- .../packages/ui-core/src/assets/AssetsCatalogTable.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetsCatalogTable.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetsCatalogTable.tsx index 5265eaae1d4d6..473becfa6a211 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetsCatalogTable.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetsCatalogTable.tsx @@ -211,7 +211,10 @@ export const AssetsCatalogTable = ({ kindFilter, } = useAssetCatalogFiltering({assets}); const {filterInput, filtered, loading, assetSelection, setAssetSelection} = - useAssetSelectionInput(partiallyFiltered, !assets); + useAssetSelectionInput({ + assets: partiallyFiltered, + assetsLoading: !assets || filteredAssetsLoading, + }); useBlockTraceUntilTrue('useAllAssets', !!assets?.length && !loading); From ee59f1f32bf1d0b4d04382df37b2fcdbd1a4a731 Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Thu, 2 Jan 2025 10:00:10 -0500 Subject: [PATCH 5/6] update mock --- .../ui-core/src/assets/__tests__/AssetTables.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx index 1c117cee6d3e8..174601d1a74f8 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx @@ -34,10 +34,10 @@ jest.mock('../../graph/asyncGraphLayout', () => ({})); jest.mock('shared/asset-selection/useAssetSelectionInput', () => { return { - useAssetSelectionInput: (assets: any) => { + useAssetSelectionInput: ({assets, assetsLoading}: {assets: any; assetsLoading?: boolean}) => { return { filterInput:
, - fetchResult: {loading: false}, + fetchResult: {loading: assetsLoading}, filtered: assets, assetSelection: '', setAssetSelection: () => {}, From a6d1d3d86b340dd4624aff3f5c8be3ac90af23a7 Mon Sep 17 00:00:00 2001 From: Marco Salazar Date: Thu, 2 Jan 2025 10:02:24 -0500 Subject: [PATCH 6/6] update mock --- .../src/assets/__tests__/AssetTables.test.tsx | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx index 174601d1a74f8..46be35ec8ac9d 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/__tests__/AssetTables.test.tsx @@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event'; import {MemoryRouter} from 'react-router'; import {RecoilRoot} from 'recoil'; +import {useAssetSelectionInput} from '../../asset-selection/useAssetSelectionInput'; import {mockViewportClientRect, restoreViewportClientRect} from '../../testing/mocking'; import {WorkspaceProvider} from '../../workspace/WorkspaceContext/WorkspaceContext'; import {buildWorkspaceMocks} from '../../workspace/WorkspaceContext/__fixtures__/Workspace.fixtures'; @@ -33,16 +34,24 @@ const MOCKS = [ jest.mock('../../graph/asyncGraphLayout', () => ({})); jest.mock('shared/asset-selection/useAssetSelectionInput', () => { + const mock: typeof useAssetSelectionInput = ({ + assets, + assetsLoading, + }: { + assets: any; + assetsLoading?: boolean; + }) => { + return { + filterInput:
, + fetchResult: {loading: false}, + loading: !!assetsLoading, + filtered: assets, + assetSelection: '', + setAssetSelection: () => {}, + }; + }; return { - useAssetSelectionInput: ({assets, assetsLoading}: {assets: any; assetsLoading?: boolean}) => { - return { - filterInput:
, - fetchResult: {loading: assetsLoading}, - filtered: assets, - assetSelection: '', - setAssetSelection: () => {}, - }; - }, + useAssetSelectionInput: mock, }; });