@@ -13,6 +13,7 @@ import {
13
13
} from "components/DeploySettingsLayout/Option"
14
14
import { FC } from "react"
15
15
import { DisabledBadge } from "./Badges"
16
+ import { intervalToDuration , formatDuration } from "date-fns"
16
17
17
18
const OptionsTable : FC < {
18
19
options : DeploymentOption [ ]
@@ -34,7 +35,11 @@ const OptionsTable: FC<{
34
35
</ TableHead >
35
36
< TableBody >
36
37
{ Object . values ( options ) . map ( ( option ) => {
37
- if ( option . value === null || option . value === "" ) {
38
+ if (
39
+ option . value === null ||
40
+ option . value === "" ||
41
+ option . value === undefined
42
+ ) {
38
43
return null
39
44
}
40
45
return (
@@ -45,7 +50,7 @@ const OptionsTable: FC<{
45
50
</ TableCell >
46
51
47
52
< TableCell >
48
- < OptionValue > { option . value } </ OptionValue >
53
+ < OptionValue > { optionValue ( option ) } </ OptionValue >
49
54
</ TableCell >
50
55
</ TableRow >
51
56
)
@@ -56,6 +61,31 @@ const OptionsTable: FC<{
56
61
)
57
62
}
58
63
64
+ // optionValue is a helper function to format the value of a specific deployment options
65
+ export function optionValue (
66
+ option : DeploymentOption ,
67
+ ) : string [ ] | string | unknown {
68
+ switch ( option . name ) {
69
+ case "Max Token Lifetime" :
70
+ case "Session Duration" :
71
+ // intervalToDuration takes ms, so convert nanoseconds to ms
72
+ return formatDuration (
73
+ intervalToDuration ( { start : 0 , end : ( option . value as number ) / 1e6 } ) ,
74
+ )
75
+ case "Strict-Transport-Security" :
76
+ if ( option . value === 0 ) {
77
+ return "Disabled"
78
+ }
79
+ return ( option . value as number ) . toString ( ) + "s"
80
+ case "OIDC Group Mapping" :
81
+ return Object . entries ( option . value as Record < string , string > ) . map (
82
+ ( [ key , value ] ) => `"${ key } "->"${ value } "` ,
83
+ )
84
+ default :
85
+ return option . value
86
+ }
87
+ }
88
+
59
89
const useStyles = makeStyles ( ( theme ) => ( {
60
90
table : {
61
91
"& td" : {
0 commit comments