-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel
authored
Apr 5, 2024
1 parent
344b672
commit a0699dd
Showing
24 changed files
with
730 additions
and
361 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client' | ||
|
||
import { faCheckCircle } from '@fortawesome/pro-regular-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
|
||
const GreenCheckStatus = ({ isChecked, label }: { isChecked: boolean; label: string }) => { | ||
if (!isChecked) return null | ||
|
||
return ( | ||
<div className="flex items-center gap-4"> | ||
<FontAwesomeIcon icon={faCheckCircle} className="text-nv-green-500" /> | ||
<div className="text-nv-white">{label}</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default GreenCheckStatus |
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
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use client' | ||
|
||
import { faPlus, faSpinner } from '@fortawesome/pro-regular-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import axios from 'axios' | ||
import { useState } from 'react' | ||
import GreenCheckStatus from '../../_components/GreenCheckStatus' | ||
import NarButton from '../../_design-system/NarButton' | ||
import NarInput from '../../_design-system/NarInput' | ||
import useStore from '../../_hooks/useStore' | ||
|
||
const VaultConfig = () => { | ||
const { | ||
engineClientSigner, | ||
setEngineClientSigner, | ||
vaultUrl, | ||
setVaultUrl, | ||
vaultAdminApiKey, | ||
setVaultAdminApiKey, | ||
vaultClientId, | ||
setVaultClientId, | ||
vaultClientSecret, | ||
setVaultClientSecret | ||
} = useStore() | ||
|
||
const [isProcessing, setIsProcessing] = useState<boolean>(false) | ||
const [isOnboarded, setIsOnboarded] = useState<boolean>(false) | ||
|
||
const onboardClient = async () => { | ||
if (!vaultAdminApiKey) return | ||
|
||
setIsProcessing(true) | ||
|
||
try { | ||
const { data: client } = await axios.post( | ||
`${vaultUrl}/clients`, | ||
{ | ||
...(vaultClientId && { clientId: vaultClientId }), | ||
...(engineClientSigner && { engineJwk: engineClientSigner }) | ||
}, | ||
{ | ||
headers: { | ||
'x-api-key': vaultAdminApiKey | ||
} | ||
} | ||
) | ||
|
||
setVaultClientId(client.clientId) | ||
setVaultClientSecret(client.clientSecret) | ||
setEngineClientSigner(client.engineJwk) | ||
|
||
setIsOnboarded(true) | ||
|
||
setTimeout(() => setIsOnboarded(false), 5000) | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
|
||
setIsProcessing(false) | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-10"> | ||
<div className="flex items-center"> | ||
<div className="text-nv-2xl grow">Vault</div> | ||
<div className="flex items-center gap-4"> | ||
<GreenCheckStatus isChecked={isOnboarded} label={isOnboarded ? 'Client Onboarded!' : 'Onboarding...'} /> | ||
<NarButton | ||
label={isProcessing ? 'Processing...' : 'Add client'} | ||
leftIcon={ | ||
isProcessing ? ( | ||
<FontAwesomeIcon icon={faSpinner} spin /> | ||
) : ( | ||
<FontAwesomeIcon icon={faPlus} spin={isProcessing} /> | ||
) | ||
} | ||
onClick={onboardClient} | ||
disabled={isProcessing} | ||
/> | ||
</div> | ||
</div> | ||
<div className="flex gap-20"> | ||
<div className="flex flex-col gap-6 w-1/3"> | ||
<NarInput label="Vault URL" value={vaultUrl} onChange={setVaultUrl} /> | ||
<NarInput label="Admin API Key" value={vaultAdminApiKey} onChange={setVaultAdminApiKey} /> | ||
</div> | ||
<div className="flex flex-col gap-6 w-2/3"> | ||
<NarInput label="Client Signer" value={JSON.stringify(engineClientSigner)} onChange={() => null} disabled /> | ||
<NarInput label="Client ID" value={vaultClientId} onChange={() => null} disabled /> | ||
<NarInput label="Client Secret" value={vaultClientSecret} onChange={() => null} disabled /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default VaultConfig |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import PolicyEngineConfig from './_components/PolicyEngineConfig' | ||
import VaultConfig from './_components/VaultConfig' | ||
|
||
export default async function PolicyEngine() { | ||
return ( | ||
<div className="flex flex-col gap-20"> | ||
<PolicyEngineConfig /> | ||
<VaultConfig /> | ||
</div> | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
apps/devtool/src/app/data-store/_components/CodeEditor.tsx
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client' | ||
|
||
import { Editor } from '@monaco-editor/react' | ||
import { FC, useRef } from 'react' | ||
|
||
interface CodeEditorProps { | ||
value: string | undefined | ||
onChange: (value: string | undefined) => void | ||
} | ||
|
||
const CodeEditor: FC<CodeEditorProps> = ({ value, onChange }) => { | ||
const editorRef = useRef<any>(null) | ||
const monacoRef = useRef<any>(null) | ||
|
||
return ( | ||
<div className="border-2 border-white rounded-xl p-4 w-full"> | ||
<Editor | ||
height="70vh" | ||
language="json" | ||
value={value} | ||
onChange={(value) => onChange(value)} | ||
onMount={(editor, monaco) => { | ||
editorRef.current = editor | ||
monacoRef.current = monaco | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default CodeEditor |
Oops, something went wrong.