diff --git a/assets/src/components/kubernetes/configuration/Secret.tsx b/assets/src/components/kubernetes/configuration/Secret.tsx index 4cca1746a9..5d9033105f 100644 --- a/assets/src/components/kubernetes/configuration/Secret.tsx +++ b/assets/src/components/kubernetes/configuration/Secret.tsx @@ -1,8 +1,18 @@ -import { ReactElement, useMemo } from 'react' -import { Card, Prop, useSetBreadcrumbs } from '@pluralsh/design-system' +import { ReactElement, useMemo, useState } from 'react' +import { + Card, + EyeClosedIcon, + EyeIcon, + IconFrame, + Prop, + Table, + useSetBreadcrumbs, +} from '@pluralsh/design-system' import { useParams } from 'react-router-dom' import { useTheme } from 'styled-components' +import { createColumnHelper } from '@tanstack/react-table' + import { SecretQueryVariables, useSecretQuery, @@ -21,6 +31,53 @@ import { import { getBreadcrumbs } from './Secrets' +type SecretDataEntry = { + key: string + value: any +} + +function SecretDataValue({ value }: { value: any }) { + const theme = useTheme() + const [reveal, setReveal] = useState(false) + + return ( +
+ : } + onClick={() => setReveal(() => !reveal)} + /> +
+ {reveal ? atob(value) : value} +
+
+ ) +} + +const columnHelper = createColumnHelper() + +const columns = [ + columnHelper.accessor((row) => row.key, { + id: 'key', + header: 'Key', + meta: { gridTemplate: `fit-content(200px)` }, + cell: ({ getValue }) => getValue(), + }), + columnHelper.accessor((row) => row.value, { + id: 'value', + header: 'Value', + cell: ({ getValue }) => , + }), +] + export default function Secret(): ReactElement { const theme = useTheme() const cluster = useKubernetesCluster() @@ -56,6 +113,15 @@ export default function Secret(): ReactElement { ) ) + const secretData: SecretDataEntry[] = useMemo( + () => + Object.entries(secret?.data ?? {}).map(([key, value]) => ({ + key, + value, + })), + [secret?.data] + ) + if (loading) return return ( @@ -84,15 +150,21 @@ export default function Secret(): ReactElement {
Data + {/* TODO: Reveal all button. */} - {Object.entries(secret?.data)?.map(([key, value]) => ( - {value} - ))} +