From 0b218b55d04b2cb9d0bfb58b19cab7e8d0689ac6 Mon Sep 17 00:00:00 2001 From: bengotow Date: Wed, 16 Oct 2024 14:58:24 -0500 Subject: [PATCH] =?UTF-8?q?[ui]=20Disable=20runs=20feed=20=E2=80=9CShow=20?= =?UTF-8?q?runs=20within=20backfills=E2=80=9D=20when=20filtering=20by=20?= =?UTF-8?q?=E2=80=9DLaunched=20By=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pipelines/PipelineRunsFeedRoot.tsx | 2 +- .../ui-core/src/runs/RunsFeedRoot.tsx | 16 ++++++++++++--- .../ui-core/src/runs/RunsFilterInput.tsx | 20 ++++++------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/pipelines/PipelineRunsFeedRoot.tsx b/js_modules/dagster-ui/packages/ui-core/src/pipelines/PipelineRunsFeedRoot.tsx index 3599ebe5c5c4a..cbcfcd19a28bb 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/pipelines/PipelineRunsFeedRoot.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/pipelines/PipelineRunsFeedRoot.tsx @@ -59,7 +59,7 @@ export const PipelineRunsFeedRoot = (props: {repoAddress?: RepoAddress}) => { ].filter(Boolean) as TokenizingFieldValue[]; }, [isJob, pipelineName, snapshotId]); - const includeRunsFromBackfills = useIncludeRunsFromBackfillsOption(); + const includeRunsFromBackfills = useIncludeRunsFromBackfillsOption(filterTokens); const runsFilter: RunsFilter = useMemo(() => { const allTokens = [...filterTokens, ...permanentTokens]; diff --git a/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFeedRoot.tsx b/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFeedRoot.tsx index 8c7b283006dd3..f95506c582818 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFeedRoot.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFeedRoot.tsx @@ -1,6 +1,6 @@ import {Box, Checkbox, Colors, tokenToString} from '@dagster-io/ui-components'; import partition from 'lodash/partition'; -import {useCallback, useMemo} from 'react'; +import {useCallback, useEffect, useMemo} from 'react'; import {RunsQueryRefetchContext} from './RunUtils'; import {RunsFeedError} from './RunsFeedError'; @@ -9,6 +9,7 @@ import {useRunsFeedTabs, useSelectedRunsFeedTab} from './RunsFeedTabs'; import { RunFilterToken, RunFilterTokenType, + isCreatedByTag, runsFilterForSearchTokens, useQueryPersistedRunFilters, useRunsFilterInput, @@ -36,18 +37,26 @@ const filters: RunFilterTokenType[] = [ 'status', ]; -export function useIncludeRunsFromBackfillsOption() { +export function useIncludeRunsFromBackfillsOption(filterTokens: RunFilterToken[]) { const [value, setValue] = useQueryPersistedState({ queryKey: 'show_runs_within_backfills', defaults: {show_runs_within_backfills: false}, }); + const someCreatedByTag = filterTokens.some(isCreatedByTag) + useEffect(() => { + if (someCreatedByTag && value) { + setValue(false); + } + }, [someCreatedByTag, value]); + return { value, setValue, element: ( Show runs within backfills} + disabled={someCreatedByTag} checked={value} onChange={() => { setValue(!value); @@ -104,7 +113,7 @@ export const RunsFeedRoot = () => { enabledFilters: filters, }); - const includeRunsFromBackfills = useIncludeRunsFromBackfillsOption(); + const includeRunsFromBackfills = useIncludeRunsFromBackfillsOption(mutableTokens); const {tabs, queryResult: runQueryResult} = useRunsFeedTabs( filter, includeRunsFromBackfills.value, @@ -187,3 +196,4 @@ export const RunsFeedRoot = () => { // Imported via React.lazy, which requires a default export. // eslint-disable-next-line import/no-default-export export default RunsFeedRoot; +;;;;;;;;;; \ No newline at end of file diff --git a/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFilterInput.tsx b/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFilterInput.tsx index 1a4b3d3508034..0c59ecc44fe02 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFilterInput.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/runs/RunsFilterInput.tsx @@ -167,6 +167,7 @@ const StatusFilterValues = Object.keys(RunStatus).map((x) => ({ value: x, match: [x], })); + const CREATED_BY_TAGS = [ DagsterTag.Automaterialize, DagsterTag.SensorName, @@ -174,6 +175,9 @@ const CREATED_BY_TAGS = [ DagsterTag.User, ]; +export const isCreatedByTag = ({token, value}: RunFilterToken) => + token === 'tag' && CREATED_BY_TAGS.includes(value.split('=')[0] as DagsterTag); + // Exclude these tags from the "tag" filter because they're already being fetched by other filters. const tagsToExclude = [...CREATED_BY_TAGS, DagsterTag.Backfill, DagsterTag.Partition]; @@ -516,23 +520,11 @@ export const useRunsFilterInput = ({tokens, onChange, enabledFilters}: RunsFilte return x.value!; }, state: useMemo(() => { - return new Set( - tokens - .filter( - ({token, value}) => - token === 'tag' && CREATED_BY_TAGS.includes(value.split('=')[0] as DagsterTag), - ) - .map(({value}) => tagValueToFilterObject(value)), - ); + return new Set(tokens.filter(isCreatedByTag).map(({value}) => tagValueToFilterObject(value))); }, [tokens]), onStateChanged: (values) => { onChange([ - ...tokens.filter((token) => { - if (token.token !== 'tag') { - return true; - } - return !CREATED_BY_TAGS.includes(token.value.split('=')[0] as DagsterTag); - }), + ...tokens.filter((token) => !isCreatedByTag(token)), ...Array.from(values).map((value) => ({ token: 'tag' as const, value: `${value.type}=${value.value}`,