Skip to content

Commit

Permalink
Add missing variables to AssetCatalogTable.requery
Browse files Browse the repository at this point in the history
[DAGSTER_BRANCH=bengotow-2024-07/partition-wipe]
  • Loading branch information
bengotow committed Jul 24, 2024
1 parent ba433d5 commit 671f26c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ export const TagSelectorContainer = styled.div`
align-items: center;
${TextInputStyles}
min-height: 32px;
padding: 4px 8px;
`;

const Placeholder = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ export function useCachedAssets({

return {cacheManager};
}
const requery = () => [{query: ASSET_CATALOG_TABLE_QUERY, fetchPolicy: 'no-cache' as const}];
const requery = () => [
{
query: ASSET_CATALOG_TABLE_QUERY,
variables: {limit: DEFAULT_BATCH_LIMIT},
fetchPolicy: 'no-cache' as const,
},
];

export function useAllAssets({
batchLimit = DEFAULT_BATCH_LIMIT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {CSSProperties, useRef} from 'react';
import {displayNameForAssetKey} from '../asset-graph/Utils';
import {AssetKeyInput} from '../graphql/types';
import {Inner, Row} from '../ui/VirtualizedTable';
import {CaptionMono, Mono} from '@dagster-io/ui-components';

export const VirtualizedSimpleAssetKeyList = ({
assetKeys,
Expand All @@ -18,7 +19,7 @@ export const VirtualizedSimpleAssetKeyList = ({
const rowVirtualizer = useVirtualizer({
count: assetKeys.length,
getScrollElement: () => parentRef.current,
estimateSize: () => 24,
estimateSize: () => 18,
overscan: 10,
});

Expand All @@ -32,7 +33,7 @@ export const VirtualizedSimpleAssetKeyList = ({
const assetKey = assetKeys[index]!;
return (
<Row key={key} $height={size} $start={start}>
{displayNameForAssetKey(assetKey)}
<CaptionMono>{displayNameForAssetKey(assetKey)}</CaptionMono>
</Row>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {mockViewportClientRect, restoreViewportClientRect} from '../../testing/m
import {WorkspaceProvider} from '../../workspace/WorkspaceContext';
import {buildWorkspaceMocks} from '../../workspace/__fixtures__/Workspace.fixtures';
import {AssetPageHeader} from '../AssetPageHeader.oss';
import {AssetWipeDialog} from '../AssetWipeDialog.oss';
import {AssetsCatalogTable} from '../AssetsCatalogTable';
import {AssetsGraphHeader} from '../AssetsGraphHeader.oss';
import AssetsOverviewRoot from '../AssetsOverviewRoot.oss';
Expand Down Expand Up @@ -60,6 +61,7 @@ describe('AssetTable', () => {
value={{
components: {
AssetPageHeader,
AssetWipeDialog,
AppTopNavRightOfLogo,
UserPreferences,
AssetsOverview: AssetsOverviewRoot,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {RefetchQueriesFunction, gql, useMutation} from '@apollo/client';
import {useLayoutEffect, useRef, useState} from 'react';

import {AssetWipeMutation, AssetWipeMutationVariables} from './types/AssetWipeDialog.types';
import {AssetWipeMutation, AssetWipeMutationVariables} from './types/useWipeAssets.types';
import {showCustomAlert} from '../app/CustomAlertProvider';
import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment';
import {PartitionsByAssetSelector} from '../graphql/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,26 @@ import {
PartitionDimensionSelection,
PartitionHealthDimension,
} from '../assets/usePartitionHealthData';
import {PartitionDefinitionType} from '../graphql/types';

const NONE = {key: '', idx: -1};

export function isPartitionDimensionSelectionValid(s: PartitionDimensionSelection) {
return (
s.selectedKeys.length > 0 ||
(s.selectedRanges.length === 1 &&
s.selectedRanges[0]?.start.key &&
s.selectedRanges[0]?.end.key)
);
}

/**
* This component allows the selection of a single range or list of keys in the dimension.
* The `selection` can be null (all keys), a valid PartitionDimensionSelection, or an
* or an invalid (incomplete) PartitionDimensionSelection.
*
* This component does not yet support creating new partitions of dynamic dimensions.
*/
export const OrdinalOrSingleRangePartitionSelector = ({
dimension,
selection,
Expand All @@ -19,35 +36,40 @@ export const OrdinalOrSingleRangePartitionSelector = ({
}: {
dimension: PartitionHealthDimension;
selection?: PartitionDimensionSelection;
setSelection: (selected: PartitionDimensionSelection) => void;
setSelection: (selected: PartitionDimensionSelection | null) => void;
health: PartitionStatusHealthSource;
}) => {
const [mode, setMode] = useState<'ordinal' | 'range'>('ordinal');
const [mode, setMode] = useState<'all' | 'ordinal' | 'range'>('all');
const keys = selection?.selectedKeys || [];
const range = selection?.selectedRanges[0] || {start: NONE, end: NONE};
const rangeAllowed = dimension.type === PartitionDefinitionType.TIME_WINDOW;
const partitionKeys = dimension.partitionKeys;

return (
<Box style={{width: '100%', display: 'grid', gap: 8, gridTemplateColumns: 'auto 1fr'}}>
<ButtonGroup
activeItems={new Set([mode])}
buttons={[
{id: 'all', label: 'All'},
{id: 'ordinal', label: 'Single'},
{id: 'range', label: 'Range'},
...(rangeAllowed ? [{id: 'range' as const, label: 'Range'}] : []),
]}
onClick={(id) => {
setSelection({dimension, selectedKeys: [], selectedRanges: []});
setSelection(id === 'all' ? null : {dimension, selectedKeys: [], selectedRanges: []});
setMode(id);
}}
/>
{mode === 'ordinal' ? (
{mode === 'ordinal' || (mode === 'all' && !rangeAllowed) ? (
<OrdinalPartitionSelector
allPartitions={dimension.partitionKeys}
placeholder={mode === 'all' ? `${partitionKeys.length} partitions` : `Select a partition`}
allPartitions={partitionKeys}
selectedPartitions={keys}
health={health}
isDynamic={false}
setSelectedPartitions={(selectedKeys) =>
setSelection({dimension, selectedKeys, selectedRanges: []})
}
setSelectedPartitions={(selectedKeys) => {
setSelection({dimension, selectedKeys, selectedRanges: []});
setMode('ordinal');
}}
/>
) : (
<Box
Expand All @@ -60,48 +82,54 @@ export const OrdinalOrSingleRangePartitionSelector = ({
>
<OrdinalPartitionSelector
mode="single"
placeholder="Select a starting partition"
allPartitions={dimension.partitionKeys}
placeholder={mode === 'all' ? partitionKeys[0] : 'Select a starting partition'}
allPartitions={partitionKeys}
selectedPartitions={range.start.key ? [range.start.key] : []}
health={health}
isDynamic={false}
setSelectedPartitions={([selectedKey]) =>
setSelectedPartitions={([selectedKey]) => {
setMode('range');
setSelection({
dimension,
selectedKeys: [],
selectedRanges: [
{
start: selectedKey
? {key: selectedKey, idx: dimension.partitionKeys.indexOf(selectedKey)}
? {key: selectedKey, idx: partitionKeys.indexOf(selectedKey)}
: NONE,
end: range.end,
},
],
})
}
});
}}
/>
<Icon name="arrow_forward" />
<OrdinalPartitionSelector
mode="single"
placeholder="Select an ending partition"
allPartitions={dimension.partitionKeys}
placeholder={
mode === 'all'
? partitionKeys[partitionKeys.length - 1]
: 'Select an ending partition'
}
allPartitions={partitionKeys}
selectedPartitions={range.end.key ? [range.end.key] : []}
health={health}
isDynamic={false}
setSelectedPartitions={([selectedKey]) =>
setSelectedPartitions={([selectedKey]) => {
setMode('range');
setSelection({
dimension,
selectedKeys: [],
selectedRanges: [
{
start: range.start,
end: selectedKey
? {key: selectedKey, idx: dimension.partitionKeys.indexOf(selectedKey)}
? {key: selectedKey, idx: partitionKeys.indexOf(selectedKey)}
: NONE,
},
],
})
}
});
}}
/>
</Box>
)}
Expand Down

0 comments on commit 671f26c

Please sign in to comment.