Changeset View
Changeset View
Standalone View
Standalone View
js_modules/dagit/packages/core/src/nav/JobMetadata.tsx
import {gql, useQuery} from '@apollo/client'; | import {gql, useQuery} from '@apollo/client'; | ||||
import {Button, Classes, Colors, Dialog, Icon} from '@blueprintjs/core'; | import {Button, Classes, Colors, Dialog, Icon} from '@blueprintjs/core'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import {Link} from 'react-router-dom'; | import {Link} from 'react-router-dom'; | ||||
import styled from 'styled-components/macro'; | import styled from 'styled-components/macro'; | ||||
import {useFeatureFlags} from '../app/Flags'; | |||||
import {RunStatus} from '../runs/RunStatusDots'; | import {RunStatus} from '../runs/RunStatusDots'; | ||||
import {TimeElapsed} from '../runs/TimeElapsed'; | import {TimeElapsed} from '../runs/TimeElapsed'; | ||||
import {ScheduleSwitch} from '../schedules/ScheduleSwitch'; | import {ScheduleSwitch} from '../schedules/ScheduleSwitch'; | ||||
import {SCHEDULE_FRAGMENT} from '../schedules/ScheduleUtils'; | import {SCHEDULE_FRAGMENT} from '../schedules/ScheduleUtils'; | ||||
import {SENSOR_FRAGMENT} from '../sensors/SensorFragment'; | import {SENSOR_FRAGMENT} from '../sensors/SensorFragment'; | ||||
import {SensorSwitch} from '../sensors/SensorSwitch'; | import {SensorSwitch} from '../sensors/SensorSwitch'; | ||||
import {ButtonLink} from '../ui/ButtonLink'; | import {ButtonLink} from '../ui/ButtonLink'; | ||||
import {Group} from '../ui/Group'; | import {Group} from '../ui/Group'; | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | export const JobMetadata: React.FC<Props> = (props) => { | ||||
); | ); | ||||
}; | }; | ||||
const ScheduleOrSensor: React.FC<{job: Job; mode: string; repoAddress: RepoAddress}> = ({ | const ScheduleOrSensor: React.FC<{job: Job; mode: string; repoAddress: RepoAddress}> = ({ | ||||
job, | job, | ||||
mode, | mode, | ||||
repoAddress, | repoAddress, | ||||
}) => { | }) => { | ||||
const {flagPipelineModeTuples} = useFeatureFlags(); | |||||
const [open, setOpen] = React.useState(false); | const [open, setOpen] = React.useState(false); | ||||
const matchingSchedules = React.useMemo(() => { | const matchingSchedules = React.useMemo(() => { | ||||
if (job?.__typename === 'Pipeline' && job.schedules.length) { | if (job?.__typename === 'Pipeline' && job.schedules.length) { | ||||
return job.schedules.filter((schedule) => schedule.mode === mode); | return flagPipelineModeTuples | ||||
? job.schedules.filter((schedule) => schedule.mode === mode) | |||||
: job.schedules; | |||||
} | } | ||||
return []; | return []; | ||||
}, [job, mode]); | }, [flagPipelineModeTuples, job, mode]); | ||||
const matchingSensors = React.useMemo(() => { | const matchingSensors = React.useMemo(() => { | ||||
if (job?.__typename === 'Pipeline' && job.sensors.length) { | if (job?.__typename === 'Pipeline' && job.sensors.length) { | ||||
return job.sensors.filter((sensor) => sensor.mode === mode); | return flagPipelineModeTuples | ||||
? job.sensors.filter((sensor) => sensor.mode === mode) | |||||
: job.sensors; | |||||
} | } | ||||
return []; | return []; | ||||
}, [job, mode]); | }, [flagPipelineModeTuples, job, mode]); | ||||
const scheduleCount = matchingSchedules.length; | const scheduleCount = matchingSchedules.length; | ||||
const sensorCount = matchingSensors.length; | const sensorCount = matchingSensors.length; | ||||
if (scheduleCount > 1 || sensorCount > 1 || (scheduleCount && sensorCount)) { | if (scheduleCount > 1 || sensorCount > 1 || (scheduleCount && sensorCount)) { | ||||
const buttonText = | const buttonText = | ||||
scheduleCount && sensorCount | scheduleCount && sensorCount | ||||
? `View ${scheduleCount + sensorCount} schedules/sensors` | ? `View ${scheduleCount + sensorCount} schedules/sensors` | ||||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |