Skip to content

Commit

Permalink
Strip baseUri entries from JSON in 'About track' copy config (#4040)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 3, 2023
1 parent 62826c1 commit aad64cd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/product-core/src/ui/AboutDialogContents.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react'
import clone from 'clone'
import copy from 'copy-to-clipboard'
import { Button } from '@mui/material'
import { makeStyles } from 'tss-react/mui'
Expand All @@ -20,6 +21,17 @@ const useStyles = makeStyles()({
},
})

function removeAttr(obj: Record<string, unknown>, attr: string) {
for (const prop in obj) {
if (prop === attr) {
delete obj[prop]
} else if (typeof obj[prop] === 'object') {
removeAttr(obj[prop] as Record<string, unknown>, attr)
}
}
return obj
}

export default function AboutContents({
config,
}: {
Expand Down Expand Up @@ -63,7 +75,8 @@ export default function AboutContents({
variant="contained"
style={{ float: 'right' }}
onClick={() => {
copy(JSON.stringify(conf, null, 2))
const snap = removeAttr(clone(conf), 'baseUri')
copy(JSON.stringify(snap, null, 2))
setCopied(true)
setTimeout(() => setCopied(false), 1000)
}}
Expand Down

0 comments on commit aad64cd

Please sign in to comment.