-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(declarative-instigator-status): add button to reset instigator s…
…tatus (#19258) ## Summary & Motivation Building off of #19234 and #19242, add a button to reset the instigator status to track what's defined in code. To do this, we've taken the instigator switch and put it in a row in the instigator details table. We render a button in this row if the user can reset the instigator. This button should only show up if you've taken manual intervention to change the instigator status. In a follow-up PR, we can this reset behavior to the bulk actions menu. ## How I Tested These Changes https://github.com/dagster-io/dagster/assets/16431325/f0f880d7-a8ba-4733-84f2-cb26d617e92e
- Loading branch information
1 parent
42f17af
commit 2e20220
Showing
14 changed files
with
270 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
js_modules/dagster-ui/packages/ui-core/src/schedules/ScheduleResetButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {useMutation} from '@apollo/client'; | ||
import {Button, Tooltip} from '@dagster-io/ui-components'; | ||
import * as React from 'react'; | ||
|
||
import {RESET_SCHEDULE_MUTATION, displayScheduleMutationErrors} from './ScheduleMutations'; | ||
import { | ||
ResetScheduleMutation, | ||
ResetScheduleMutationVariables, | ||
} from './types/ScheduleMutations.types'; | ||
import {ScheduleFragment} from './types/ScheduleUtils.types'; | ||
import {DEFAULT_DISABLED_REASON, usePermissionsForLocation} from '../app/Permissions'; | ||
import {repoAddressToSelector} from '../workspace/repoAddressToSelector'; | ||
import {RepoAddress} from '../workspace/types'; | ||
|
||
interface Props { | ||
repoAddress: RepoAddress; | ||
schedule: ScheduleFragment; | ||
} | ||
|
||
export const ScheduleResetButton = ({repoAddress, schedule}: Props) => { | ||
const { | ||
permissions: {canStartSchedule, canStopRunningSchedule}, | ||
} = usePermissionsForLocation(repoAddress.location); | ||
|
||
const {name} = schedule; | ||
const scheduleSelector = { | ||
...repoAddressToSelector(repoAddress), | ||
scheduleName: name, | ||
}; | ||
|
||
const [resetSchedule, {loading: toggleOnInFlight}] = useMutation< | ||
ResetScheduleMutation, | ||
ResetScheduleMutationVariables | ||
>(RESET_SCHEDULE_MUTATION, { | ||
onCompleted: displayScheduleMutationErrors, | ||
}); | ||
const onClick = () => { | ||
resetSchedule({variables: {scheduleSelector}}); | ||
}; | ||
|
||
const hasPermission = canStartSchedule && canStopRunningSchedule; | ||
const disabled = toggleOnInFlight || !hasPermission; | ||
const tooltipContent = hasPermission | ||
? `In code, a default status for "${name}" has been set to "${schedule.defaultStatus}". Click here to reset the schedule status to track the status set in code.` | ||
: DEFAULT_DISABLED_REASON; | ||
|
||
return ( | ||
<Tooltip content={tooltipContent} display="flex"> | ||
<Button disabled={disabled} onClick={onClick}> | ||
Reset schedule status | ||
</Button> | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
js_modules/dagster-ui/packages/ui-core/src/schedules/types/ScheduleMutations.types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
js_modules/dagster-ui/packages/ui-core/src/schedules/types/ScheduleRoot.types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
js_modules/dagster-ui/packages/ui-core/src/schedules/types/ScheduleUtils.types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
js_modules/dagster-ui/packages/ui-core/src/sensors/SensorResetButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {useMutation} from '@apollo/client'; | ||
import {Button, Tooltip} from '@dagster-io/ui-components'; | ||
import * as React from 'react'; | ||
|
||
import {RESET_SENSOR_MUTATION, displaySensorMutationErrors} from './SensorMutations'; | ||
import {SensorFragment} from './types/SensorFragment.types'; | ||
import {ResetSensorMutation, ResetSensorMutationVariables} from './types/SensorMutations.types'; | ||
import {DEFAULT_DISABLED_REASON, usePermissionsForLocation} from '../app/Permissions'; | ||
import {repoAddressToSelector} from '../workspace/repoAddressToSelector'; | ||
import {RepoAddress} from '../workspace/types'; | ||
|
||
interface Props { | ||
repoAddress: RepoAddress; | ||
sensor: SensorFragment; | ||
} | ||
|
||
export const SensorResetButton = ({repoAddress, sensor}: Props) => { | ||
const { | ||
permissions: {canStartSensor, canStopSensor}, | ||
} = usePermissionsForLocation(repoAddress.location); | ||
|
||
const {name} = sensor; | ||
const sensorSelector = { | ||
...repoAddressToSelector(repoAddress), | ||
sensorName: name, | ||
}; | ||
|
||
const [resetSensor, {loading: toggleOnInFlight}] = useMutation< | ||
ResetSensorMutation, | ||
ResetSensorMutationVariables | ||
>(RESET_SENSOR_MUTATION, { | ||
onCompleted: displaySensorMutationErrors, | ||
}); | ||
const onClick = () => { | ||
resetSensor({variables: {sensorSelector}}); | ||
}; | ||
|
||
const hasPermission = canStartSensor && canStopSensor; | ||
const disabled = toggleOnInFlight || !hasPermission; | ||
const tooltipContent = hasPermission | ||
? `In code, a default status for "${name}" has been set to "${sensor.defaultStatus}". Click here to reset the sensor status to track the status set in code.` | ||
: DEFAULT_DISABLED_REASON; | ||
|
||
return ( | ||
<Tooltip content={tooltipContent} display="flex"> | ||
<Button disabled={disabled} onClick={onClick}> | ||
Reset sensor status | ||
</Button> | ||
</Tooltip> | ||
); | ||
}; |
2 changes: 2 additions & 0 deletions
2
js_modules/dagster-ui/packages/ui-core/src/sensors/types/SensorFragment.types.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
2e20220
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-8wl6ywysa-elementl.vercel.app
Built with commit 2e20220.
This pull request is being automatically deployed with vercel-action