-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Show peer configuration on clicking peer (#1168)
Shows the peer's config object when clicking on the peer buttons. Sensitive keys not exposed. ![Screenshot 2024-01-29 at 9 12 33 PM](https://github.com/PeerDB-io/peerdb/assets/65964360/f43ce1af-fb00-4331-9199-6328f7627b35)
- Loading branch information
1 parent
af121d3
commit 75cdc2c
Showing
6 changed files
with
82 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// sensitive keys | ||
const omitKeys = [ | ||
'privateKey', // snowflake and bigquery | ||
'password', // postgres, metadatadb for non-dwh peers, snowflake | ||
'secretAccessKey', // s3/gcs | ||
'subscriptionId', // eventhub | ||
'privateKeyId', // bigquery | ||
'type', // peer type | ||
]; | ||
|
||
export default omitKeys; |
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,58 @@ | ||
import { ConfigJSONView } from '@/app/alert-config/page'; | ||
import { getTruePeer } from '@/app/api/peers/getTruePeer'; | ||
import prisma from '@/app/utils/prisma'; | ||
import { Label } from '@/lib/Label'; | ||
import omitKeys from './omitKeys'; | ||
|
||
interface PeerDetailsProps { | ||
peerName: string; | ||
} | ||
|
||
const PeerDetails = async ({ peerName }: PeerDetailsProps) => { | ||
const peer = await prisma.peers.findFirst({ | ||
where: { | ||
name: peerName, | ||
}, | ||
}); | ||
const peerConfig = getTruePeer(peer!); | ||
|
||
return ( | ||
<div> | ||
<div | ||
style={{ | ||
padding: '0.5rem', | ||
minWidth: '30%', | ||
marginTop: '1rem', | ||
marginBottom: '1rem', | ||
}} | ||
> | ||
<div> | ||
<div> | ||
<Label variant='subheadline'>Configuration:</Label> | ||
</div> | ||
<div | ||
style={{ | ||
height: peerConfig.postgresConfig ? '14em' : '20em', | ||
whiteSpace: 'pre-wrap', | ||
marginTop: '1rem', | ||
}} | ||
> | ||
<ConfigJSONView | ||
config={JSON.stringify( | ||
peerConfig, | ||
(key, value) => { | ||
if (omitKeys.includes(key)) { | ||
return undefined; | ||
} | ||
return value; | ||
}, | ||
2 | ||
)} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default PeerDetails; |
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