Skip to content

Commit

Permalink
allow setting new-override parameter to auto-launch correct override …
Browse files Browse the repository at this point in the history
…dialog (#4242)
  • Loading branch information
mastercactapus authored Feb 17, 2025
1 parent c450aef commit c3aac61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion web/src/app/schedules/ScheduleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useIsWidthDown } from '../util/useWidth'
import { TempSchedValue, defaultTempSchedValue } from './temp-sched/sharedUtils'
import { Redirect } from 'wouter'
import { useScheduleTZ } from './useScheduleTZ'
import { useURLParam } from '../actions'

const query = gql`
fragment ScheduleTitleQuery on Schedule {
Expand Down Expand Up @@ -68,6 +69,10 @@ export type ScheduleDetailsProps = {
export default function ScheduleDetails({
scheduleID,
}: ScheduleDetailsProps): React.JSX.Element {
const [newOverride] = useURLParam('new-override', '')
const newValidOverride = ['add', 'remove', 'replace'].includes(newOverride)
? newOverride
: ''
const [showEdit, setShowEdit] = useState(false)
const [showDelete, setShowDelete] = useState(false)

Expand All @@ -91,7 +96,9 @@ export default function ScheduleDetails({
useState<TempSchedValue | null>(null)
const onDeleteTempSched = useCallback(setDeleteTempSchedule, [])
const [overrideDialog, setOverrideDialog] = useState<OverrideDialog | null>(
null,
newValidOverride
? { variantOptions: [newValidOverride], removeUserReadOnly: false }
: null,
)

const [{ data: _data, error }] = useQuery({
Expand Down
2 changes: 1 addition & 1 deletion web/src/app/schedules/ScheduleOverrideDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function ScheduleOverrideDialog(props) {
...(props?.defaultValue ?? {}),
}

const [step, setStep] = useState(0)
const [step, setStep] = useState(variantOptions.length === 1 ? 1 : 0)
const [value, setValue] = useState(initialValue)
const [fieldErrors, setFieldErrors] = useState([])
const [activeVariant, setActiveVariant] = useState(variantOptions[0])
Expand Down

0 comments on commit c3aac61

Please sign in to comment.