@@ -42,7 +42,11 @@ type Props = {
42
42
setOpen : ( open : boolean ) => void ;
43
43
} ;
44
44
const 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 > ) {
46
50
const [ successModal , setSuccessModal ] = useState ( false ) ;
47
51
const [ setupKey , setSetupKey ] = useState < SetupKey > ( ) ;
48
52
const [ , copy ] = useCopyToClipboard ( setupKey ?. key ) ;
@@ -131,7 +135,7 @@ type ModalProps = {
131
135
onSuccess ?: ( setupKey : SetupKey ) => void ;
132
136
} ;
133
137
134
- export function SetupKeyModalContent ( { onSuccess } : ModalProps ) {
138
+ export function SetupKeyModalContent ( { onSuccess } : Readonly < ModalProps > ) {
135
139
const setupKeyRequest = useApiCall < SetupKey > ( "/setup-keys" , true ) ;
136
140
const { mutate } = useSWRConfig ( ) ;
137
141
@@ -149,18 +153,10 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
149
153
return reusable ? "Unlimited" : "1" ;
150
154
} , [ reusable ] ) ;
151
155
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
-
160
156
const isDisabled = useMemo ( ( ) => {
161
157
const trimmedName = trim ( name ) ;
162
- return trimmedName . length === 0 || expiresInError . length > 0 ;
163
- } , [ name , expiresInError ] ) ;
158
+ return trimmedName . length === 0 ;
159
+ } , [ name ] ) ;
164
160
165
161
const submit = ( ) => {
166
162
if ( ! selectedGroups ) return ;
@@ -174,7 +170,7 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
174
170
. post ( {
175
171
name,
176
172
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
178
174
revoked : false ,
179
175
auto_groups : groups . map ( ( group ) => group . id ) ,
180
176
usage_limit : reusable ? parseInt ( usageLimit ) : 1 ,
@@ -253,15 +249,16 @@ export function SetupKeyModalContent({ onSuccess }: ModalProps) {
253
249
< div className = { "flex justify-between" } >
254
250
< div >
255
251
< 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 >
257
256
</ div >
258
257
< Input
259
- maxWidthClass = { "max-w-[200px ]" }
260
- placeholder = { "7 " }
258
+ maxWidthClass = { "max-w-[202px ]" }
259
+ placeholder = { "Unlimited " }
261
260
min = { 1 }
262
- max = { 365 }
263
261
value = { expiresIn }
264
- error = { expiresInError }
265
262
errorTooltip = { true }
266
263
type = { "number" }
267
264
data-cy = { "setup-key-expire-in-days" }
0 commit comments