@@ -42,7 +42,11 @@ type Props = {
4242 setOpen : ( open : boolean ) => void ;
4343} ;
4444const copyMessage = "Setup-Key was copied to your clipboard!" ;
45- export default function SetupKeyModal ( { children, open, setOpen } : Props ) {
45+ export default function SetupKeyModal ( {
46+ children,
47+ open,
48+ setOpen,
49+ } : Readonly < Props > ) {
4650 const [ successModal , setSuccessModal ] = useState ( false ) ;
4751 const [ setupKey , setSetupKey ] = useState < SetupKey > ( ) ;
4852 const [ , copy ] = useCopyToClipboard ( setupKey ?. key ) ;
@@ -131,7 +135,7 @@ type ModalProps = {
131135 onSuccess ?: ( setupKey : SetupKey ) => void ;
132136} ;
133137
134- export function SetupKeyModalContent ( { onSuccess } : ModalProps ) {
138+ export function SetupKeyModalContent ( { onSuccess } : Readonly < ModalProps > ) {
135139 const setupKeyRequest = useApiCall < SetupKey > ( "/setup-keys" , true ) ;
136140 const { mutate } = useSWRConfig ( ) ;
137141
@@ -149,18 +153,10 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
149153 return reusable ? "Unlimited" : "1" ;
150154 } , [ reusable ] ) ;
151155
152- const expiresInError = useMemo ( ( ) => {
153- const expires = parseInt ( expiresIn ) ;
154- if ( expires < 1 || expires > 365 ) {
155- return "Days should be between 1 and 365" ;
156- }
157- return "" ;
158- } , [ expiresIn ] ) ;
159-
160156 const isDisabled = useMemo ( ( ) => {
161157 const trimmedName = trim ( name ) ;
162- return trimmedName . length === 0 || expiresInError . length > 0 ;
163- } , [ name , expiresInError ] ) ;
158+ return trimmedName . length === 0 ;
159+ } , [ name ] ) ;
164160
165161 const submit = ( ) => {
166162 if ( ! selectedGroups ) return ;
@@ -174,7 +170,7 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
174170 . post ( {
175171 name,
176172 type : reusable ? "reusable" : "one-off" ,
177- expires_in : parseInt ( expiresIn ? expiresIn : "7 ") * 24 * 60 * 60 , // Days to seconds, defaults to 7 days
173+ expires_in : parseInt ( expiresIn || "0 ") * 24 * 60 * 60 , // Days to seconds, defaults to 7 days
178174 revoked : false ,
179175 auto_groups : groups . map ( ( group ) => group . id ) ,
180176 usage_limit : reusable ? parseInt ( usageLimit ) : 1 ,
@@ -253,15 +249,16 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
253249 < div className = { "flex justify-between" } >
254250 < div >
255251 < Label > Expires in</ Label >
256- < HelpText > Should be between 1 and 365 days.</ HelpText >
252+ < HelpText >
253+ Days until the key expires. < br />
254+ Leave empty for no expiration.
255+ </ HelpText >
257256 </ div >
258257 < Input
259- maxWidthClass = { "max-w-[200px ]" }
260- placeholder = { "7 " }
258+ maxWidthClass = { "max-w-[202px ]" }
259+ placeholder = { "Unlimited " }
261260 min = { 1 }
262- max = { 365 }
263261 value = { expiresIn }
264- error = { expiresInError }
265262 errorTooltip = { true }
266263 type = { "number" }
267264 data-cy = { "setup-key-expire-in-days" }
0 commit comments