-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upd whitelist and minor fixes of secrets and res list
- Loading branch information
ikethecoder
committed
May 27, 2021
1 parent
926d509
commit 1512f25
Showing
3 changed files
with
66 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,65 @@ | ||
import * as React from 'react'; | ||
import { | ||
Alert, | ||
AlertTitle, | ||
AlertDescription, | ||
AlertIcon, | ||
Box, | ||
CloseButton, | ||
Alert, | ||
AlertTitle, | ||
AlertDescription, | ||
AlertIcon, | ||
Box, | ||
CloseButton, | ||
} from '@chakra-ui/react'; | ||
|
||
import ReactMarkdownWithHtml from 'react-markdown/with-html'; | ||
import gfm from 'remark-gfm'; | ||
|
||
const { useEffect, useState } = React | ||
const { useEffect, useState } = React; | ||
|
||
function ViewSecret({cred, defaultShow, instruction, onClose}) { | ||
const [show, setShow] = React.useState(defaultShow) | ||
const handleClick = () => { setShow(!show); onClose() } | ||
|
||
useEffect (() => setShow(true), [cred]) | ||
function ViewSecret({ cred, defaultShow, instruction, onClose }) { | ||
const [show, setShow] = React.useState(defaultShow); | ||
const handleClick = () => { | ||
setShow(!show); | ||
onClose(); | ||
}; | ||
|
||
return show ? ( | ||
<Alert | ||
status="warning" p={4} | ||
> | ||
<AlertIcon/> | ||
<Box flex="1"> | ||
<AlertTitle> | ||
Your new credentials: | ||
</AlertTitle> | ||
<AlertDescription> | ||
Take note of these credentials, you will only see them once. | ||
{ instruction != null && ( | ||
<ReactMarkdownWithHtml allowDangerousHtml plugins={[gfm]}>{instruction}</ReactMarkdownWithHtml> | ||
)} | ||
{[ | ||
{name:'apiKey', label:'API Key'}, | ||
{name:'clientId', label:'Client ID'}, | ||
{name:'clientSecret', label:'Client Secret'}, | ||
{name:'clientPrivateKey', label:'Signing Private Key'}, | ||
{name:'clientPublicKey', label:'Signing Public Certificate'}, | ||
{name:'tokenEndpoint', label:'Token Endpoint'} | ||
].filter(c => c.name in cred).map(c => ( | ||
<Box><strong>{c.label} :</strong> {cred[c.name]}</Box> | ||
))} | ||
</AlertDescription> | ||
</Box> | ||
<CloseButton position="absolute" right="8px" top="8px" onClick={handleClick}/> | ||
</Alert> | ||
useEffect(() => setShow(true), [cred]); | ||
|
||
) : ( <></> ) | ||
return show ? ( | ||
<Alert status="warning" p={4}> | ||
<AlertIcon /> | ||
<Box flex="1"> | ||
<AlertTitle>Your new credentials:</AlertTitle> | ||
<AlertDescription> | ||
Take note of these credentials, you will only see them once. | ||
{instruction != null && ( | ||
<ReactMarkdownWithHtml allowDangerousHtml plugins={[gfm]}> | ||
{instruction} | ||
</ReactMarkdownWithHtml> | ||
)} | ||
{[ | ||
{ name: 'apiKey', label: 'API Key' }, | ||
{ name: 'clientId', label: 'Client ID' }, | ||
{ name: 'clientSecret', label: 'Client Secret' }, | ||
{ name: 'clientPrivateKey', label: 'Signing Private Key' }, | ||
{ name: 'clientPublicKey', label: 'Signing Public Certificate' }, | ||
{ name: 'tokenEndpoint', label: 'Token Endpoint' }, | ||
] | ||
.filter((c) => c.name in cred && cred[c.name] != null) | ||
.map((c) => ( | ||
<Box> | ||
<strong>{c.label} :</strong> {cred[c.name]} | ||
</Box> | ||
))} | ||
</AlertDescription> | ||
</Box> | ||
<CloseButton | ||
position="absolute" | ||
right="8px" | ||
top="8px" | ||
onClick={handleClick} | ||
/> | ||
</Alert> | ||
) : ( | ||
<></> | ||
); | ||
} | ||
|
||
export default ViewSecret | ||
export default ViewSecret; |