@@ -9,21 +9,27 @@ import TableHead from '@mui/material/TableHead';
99import TableRow from '@mui/material/TableRow' ;
1010import Delete from '@mui/icons-material/Delete' ;
1111import Edit from '@mui/icons-material/Edit' ;
12+ import Security from '@mui/icons-material/Security' ;
1213import Button from '@mui/material/Button' ;
14+ import Tooltip from '@mui/material/Tooltip' ;
15+ import TimeAgo from 'react-timeago' ;
1316import ConfirmDialog from '../common/ConfirmDialog' ;
1417import DefaultPage from '../common/DefaultPage' ;
1518import AddClientDialog from './AddClientDialog' ;
1619import UpdateClientDialog from './UpdateClientDialog' ;
20+ import ElevateClientDialog from './ElevateClientDialog' ;
1721import { IClient } from '../types' ;
1822import CopyableSecret from '../common/CopyableSecret' ;
1923import { LastUsedCell } from '../common/LastUsedCell' ;
24+ import { TimeAgoFormatter } from '../common/TimeAgoFormatter' ;
2025import { observer } from 'mobx-react-lite' ;
2126import { useStores } from '../stores' ;
2227
2328const Clients = observer ( ( ) => {
2429 const { clientStore} = useStores ( ) ;
2530 const [ toDeleteClient , setToDeleteClient ] = useState < IClient > ( ) ;
2631 const [ toUpdateClient , setToUpdateClient ] = useState < IClient > ( ) ;
32+ const [ toElevateClient , setToElevateClient ] = useState < IClient > ( ) ;
2733 const [ createDialog , setCreateDialog ] = useState < boolean > ( false ) ;
2834 const clients = clientStore . getItems ( ) ;
2935
@@ -32,6 +38,7 @@ const Clients = observer(() => {
3238 return (
3339 < DefaultPage
3440 title = "Clients"
41+ maxWidth = { 1000 }
3542 rightControl = {
3643 < Button
3744 id = "create-client"
@@ -49,6 +56,8 @@ const Clients = observer(() => {
4956 < TableCell > Name</ TableCell >
5057 < TableCell style = { { width : 200 } } > Token</ TableCell >
5158 < TableCell > Last Used</ TableCell >
59+ < TableCell > Elevation ends</ TableCell >
60+ < TableCell />
5261 < TableCell />
5362 < TableCell />
5463 </ TableRow >
@@ -60,8 +69,10 @@ const Clients = observer(() => {
6069 name = { client . name }
6170 value = { client . token }
6271 lastUsed = { client . lastUsed }
72+ elevatedUntil = { client . elevatedUntil }
6373 fEdit = { ( ) => setToUpdateClient ( client ) }
6474 fDelete = { ( ) => setToDeleteClient ( client ) }
75+ fElevate = { ( ) => setToElevateClient ( client ) }
6576 />
6677 ) ) }
6778 </ TableBody >
@@ -90,6 +101,13 @@ const Clients = observer(() => {
90101 requireElevated
91102 />
92103 ) }
104+ { toElevateClient != null && (
105+ < ElevateClientDialog
106+ clientName = { toElevateClient . name }
107+ clientId = { toElevateClient . id }
108+ fClose = { ( ) => setToElevateClient ( undefined ) }
109+ />
110+ ) }
93111 </ DefaultPage >
94112 ) ;
95113} ) ;
@@ -98,11 +116,13 @@ interface IRowProps {
98116 name : string ;
99117 value : string ;
100118 lastUsed : string | null ;
119+ elevatedUntil ?: string ;
101120 fEdit : VoidFunction ;
102121 fDelete : VoidFunction ;
122+ fElevate : VoidFunction ;
103123}
104124
105- const Row = ( { name, value, lastUsed, fEdit, fDelete} : IRowProps ) => (
125+ const Row = ( { name, value, lastUsed, elevatedUntil , fEdit, fDelete, fElevate } : IRowProps ) => (
106126 < TableRow >
107127 < TableCell > { name } </ TableCell >
108128 < TableCell >
@@ -114,6 +134,20 @@ const Row = ({name, value, lastUsed, fEdit, fDelete}: IRowProps) => (
114134 < TableCell >
115135 < LastUsedCell lastUsed = { lastUsed } />
116136 </ TableCell >
137+ < TableCell >
138+ { elevatedUntil && Date . parse ( elevatedUntil ) > Date . now ( ) ? (
139+ < TimeAgo date = { elevatedUntil } formatter = { TimeAgoFormatter . long } />
140+ ) : (
141+ '-'
142+ ) }
143+ </ TableCell >
144+ < TableCell align = "right" padding = "none" >
145+ < Tooltip title = "Elevate" >
146+ < IconButton onClick = { fElevate } className = "elevate" >
147+ < Security />
148+ </ IconButton >
149+ </ Tooltip >
150+ </ TableCell >
117151 < TableCell align = "right" padding = "none" >
118152 < IconButton onClick = { fEdit } className = "edit" >
119153 < Edit />
0 commit comments