@@ -7,12 +7,19 @@ import { useState } from 'react'
77import { IconX , IconLoader2 } from '@tabler/icons-react'
88import type { ReviewRepoConfig } from '../lib/workflowApi'
99import {
10- WORKFLOW_KINDS , DAY_PRESETS , DAY_INDIVIDUAL ,
10+ WORKFLOW_KINDS , DAY_PRESETS , DAY_INDIVIDUAL , isBiweeklyDow ,
1111 buildCron , parseCron , describeCron , kindLabel ,
1212 toTimeValue , fromTimeValue ,
1313} from '../lib/workflowHelpers'
1414import { CategoryBadge } from './WorkflowBadges'
1515
16+ const btnClass = ( selected : boolean ) =>
17+ `rounded-md border px-3 py-1.5 text-[13px] font-medium transition-colors ${
18+ selected
19+ ? 'border-accent-6 bg-accent-9/40 text-accent-2'
20+ : 'border-neutral-7 bg-neutral-10 text-neutral-3 hover:border-neutral-6 hover:text-neutral-2'
21+ } `
22+
1623interface Props {
1724 repo : ReviewRepoConfig
1825 schedules ?: unknown [ ]
@@ -52,6 +59,9 @@ export function EditWorkflowModal({ repo, onClose, onSave }: Props) {
5259 }
5360
5461 const repoShortName = repo . repoPath . split ( '/' ) . pop ( ) || repo . name
62+ const biweekly = isBiweeklyDow ( form . cronDow )
63+ const baseDow = biweekly ? form . cronDow . split ( '-' ) . slice ( 1 ) . join ( '-' ) : form . cronDow
64+ const isDay = DAY_INDIVIDUAL . some ( d => d . dow === baseDow )
5565
5666 return (
5767 < div className = "fixed inset-0 z-50 flex items-center justify-center bg-black/60" onClick = { onClose } >
@@ -114,7 +124,7 @@ export function EditWorkflowModal({ repo, onClose, onSave }: Props) {
114124 const { hour, minute } = fromTimeValue ( e . target . value )
115125 setForm ( f => ( { ...f , cronHour : hour , cronMinute : minute } ) )
116126 } }
117- className = "rounded-md border border-neutral-7 bg-neutral-10 px-3 py-2 text-[15px] text-neutral-1 focus:border-accent-6 focus:outline-none w-full mb-3"
127+ className = "rounded-md border border-neutral-7 bg-neutral-10 px-3 py-2 text-[15px] text-neutral-1 focus:border-accent-6 focus:outline-none w-40 mb-3 themed-time-input "
118128 />
119129 < label className = "block text-[13px] font-medium text-neutral-3 mb-2" > Frequency</ label >
120130 < div className = "flex flex-wrap gap-1.5 mb-2" >
@@ -123,11 +133,7 @@ export function EditWorkflowModal({ repo, onClose, onSave }: Props) {
123133 key = { p . dow }
124134 type = "button"
125135 onClick = { ( ) => setForm ( f => ( { ...f , cronDow : p . dow } ) ) }
126- className = { `rounded-md border px-3 py-1.5 text-[13px] font-medium transition-colors ${
127- form . cronDow === p . dow
128- ? 'border-accent-6 bg-accent-9/40 text-accent-2'
129- : 'border-neutral-7 bg-neutral-10 text-neutral-3 hover:border-neutral-6 hover:text-neutral-2'
130- } `}
136+ className = { btnClass ( form . cronDow === p . dow ) }
131137 >
132138 { p . label }
133139 </ button >
@@ -138,17 +144,23 @@ export function EditWorkflowModal({ repo, onClose, onSave }: Props) {
138144 < button
139145 key = { p . dow }
140146 type = "button"
141- onClick = { ( ) => setForm ( f => ( { ...f , cronDow : p . dow } ) ) }
142- className = { `rounded-md border px-3 py-1.5 text-[13px] font-medium transition-colors ${
143- form . cronDow === p . dow
144- ? 'border-accent-6 bg-accent-9/40 text-accent-2'
145- : 'border-neutral-7 bg-neutral-10 text-neutral-3 hover:border-neutral-6 hover:text-neutral-2'
146- } `}
147+ onClick = { ( ) => setForm ( f => ( { ...f , cronDow : biweekly ? `biweekly-${ p . dow } ` : p . dow } ) ) }
148+ className = { btnClass ( baseDow === p . dow ) }
147149 >
148150 { p . label }
149151 </ button >
150152 ) ) }
151153 </ div >
154+ { isDay && (
155+ < div className = "flex gap-1.5 mt-2" >
156+ < button type = "button" onClick = { ( ) => setForm ( f => ( { ...f , cronDow : baseDow } ) ) } className = { btnClass ( ! biweekly ) } >
157+ Every week
158+ </ button >
159+ < button type = "button" onClick = { ( ) => setForm ( f => ( { ...f , cronDow : `biweekly-${ baseDow } ` } ) ) } className = { btnClass ( biweekly ) } >
160+ Every 2 weeks
161+ </ button >
162+ </ div >
163+ ) }
152164 < div className = "mt-2 text-[13px] text-neutral-5" >
153165 { describeCron ( buildCron ( form . cronHour , form . cronDow , form . cronMinute ) ) }
154166 </ div >
0 commit comments