Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update ColumnEditor layout + add a new section for encryption

Joshen Lim1c6495add16b
diff --git a/packages/ui/src/components/SidePanel/SidePanel.tsx b/packages/ui/src/components/SidePanel/SidePanel.tsx
index 72da477eb79..e105fe85d91 100644
--- a/packages/ui/src/components/SidePanel/SidePanel.tsx
+++ b/packages/ui/src/components/SidePanel/SidePanel.tsx
@@ -22,7 +22,7 @@ interface CustomProps {
children?: React.ReactNode
header?: string | React.ReactNode
visible: boolean
- size?: 'medium' | 'large'
+ size?: 'medium' | 'large' | 'xlarge'
loading?: boolean
align?: 'right' | 'left'
hideFooter?: boolean
diff --git a/packages/ui/src/lib/theme/defaultTheme.ts b/packages/ui/src/lib/theme/defaultTheme.ts
index de5dc6a4984..642450cb31d 100644
--- a/packages/ui/src/lib/theme/defaultTheme.ts
+++ b/packages/ui/src/lib/theme/defaultTheme.ts
@@ -969,6 +969,7 @@ export default {
size: {
medium: `w-screen max-w-md h-full`,
large: `w-screen max-w-2xl h-full`,
+ xlarge: `w-screen max-w-3xl h-full`,
},
align: {
left: `
diff --git a/studio/components/interfaces/Settings/Vault/SecretRow.tsx b/studio/components/interfaces/Settings/Vault/SecretRow.tsx
index 4dd76d06d38..793d92c5241 100644
--- a/studio/components/interfaces/Settings/Vault/SecretRow.tsx
+++ b/studio/components/interfaces/Settings/Vault/SecretRow.tsx
@@ -53,7 +53,7 @@ const SecretRow: FC<Props> = ({ secret, onSelectRemove }) => {
</div>
<div className="flex items-center justify-end w-[25%] space-x-4">
<p className="text-sm text-scale-1100">
- Added on {dayjs(secret.created_at).format('MMM D, YYYY')}.
+ Added on {dayjs(secret.created_at).format('MMM D, YYYY')}
</p>
<Button
type="default"
diff --git a/studio/components/interfaces/Settings/Vault/SecretsManagement.tsx b/studio/components/interfaces/Settings/Vault/SecretsManagement.tsx
index dff9f404152..5930c73b241 100644
--- a/studio/components/interfaces/Settings/Vault/SecretsManagement.tsx
+++ b/studio/components/interfaces/Settings/Vault/SecretsManagement.tsx
@@ -3,6 +3,7 @@ import Divider from 'components/ui/Divider'
import { IconSearch, Input, Button, Listbox, Modal, Form, IconHelpCircle } from 'ui'
import SecretRow from './SecretRow'
import InformationBox from 'components/ui/InformationBox'
+import EncryptionKeySelector from 'components/interfaces/Vault/EncryptionKeySelector'
interface Props {}
@@ -147,13 +148,14 @@ const SecretsManagement: FC<Props> = ({}) => {
<Modal
closable
hideFooter
+ size="medium"
visible={showAddSecretModal}
onCancel={() => setShowAddSecretModal(false)}
header={<h5 className="text-sm text-scale-1200">Add new secret</h5>}
>
<Form
id="add-new-secret-form"
- initialValues={{ secret: '', description: '', keyId: '' }}
+ initialValues={{ secret: '', description: '', keyId: '', newKeyName: '' }}
validate={validate}
onSubmit={onAddNewSecret}
>
@@ -168,8 +170,12 @@ const SecretsManagement: FC<Props> = ({}) => {
</Modal.Content>
<Modal.Separator />
<Modal.Content>
- <div className="py-4 space-y-2">
- <Input id="keyId" label="Key ID" labelOptional="Optional" />
+ <div className="py-4 space-y-4">
+ <EncryptionKeySelector
+ id="keyId"
+ labelOptional="Optional"
+ onSelectKey={(key) => console.log(key)}
+ />
<InformationBox
icon={<IconHelpCircle size={18} strokeWidth={2} />}
url="asd"
diff --git a/studio/components/interfaces/Settings/Vault/VaultToggle.tsx b/studio/components/interfaces/Settings/Vault/VaultToggle.tsx
index 5f0c2b3529d..c27d6ff6123 100644
--- a/studio/components/interfaces/Settings/Vault/VaultToggle.tsx
+++ b/studio/components/interfaces/Settings/Vault/VaultToggle.tsx
@@ -1,3 +1,4 @@
+import Link from 'next/link'
import { FC } from 'react'
import { Form, Button, Toggle, IconExternalLink, Alert, IconHelpCircle, IconAlertCircle } from 'ui'
@@ -19,7 +20,9 @@ const VaultToggle: FC<Props> = () => {
const initialValues = { enabled: true }
- const onSubmit = async (values: any, { setSubmitting, resetForm }: any) => {}
+ const onSubmit = async (values: any, { setSubmitting, resetForm }: any) => {
+ console.log('onSubmit', values)
+ }
return (
<Form id={formId} initialValues={initialValues} onSubmit={onSubmit}>
@@ -36,9 +39,13 @@ const VaultToggle: FC<Props> = () => {
disabled={!canToggleVault}
footer={
<div className="flex py-4 px-8">
- <Button type="default" icon={<IconExternalLink />}>
- What is Supabase Vault?
- </Button>
+ <Link href="https://supabase.com/docs">
+ <a target="_blank">
+ <Button type="default" icon={<IconExternalLink />}>
+ What is Supabase Vault?
+ </Button>
+ </a>
+ </Link>
<FormActions
form={formId}
isSubmitting={isSubmitting}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
index 03f8b01dc8d..fd0cbe367be 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ActionBar.tsx
@@ -33,8 +33,8 @@ const ActionBar: FC<ActionBarProps> = ({
}
return (
- <div className="flex w-full justify-between space-x-3 border-t border-scale-500 px-3 py-4">
- <Button size="small" onClick={closePanel} type="default" htmlType="button">
+ <div className="flex w-full justify-end space-x-3 border-t border-scale-500 px-3 py-4">
+ <Button size="small" type="default" htmlType="button" onClick={closePanel}>
{backButtonLabel}
</Button>
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx
index e8f039ce254..ca2f6095a86 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnDefaultValue.tsx
@@ -51,7 +51,7 @@ const ColumnDefaultValue: FC<Props> = ({
return (
<InputWithSuggestions
label="Default Value"
- layout="horizontal"
+ layout="vertical"
description="Can either be a literal or an expression (e.g uuid_generate_v4())"
placeholder={
typeof columnFields.defaultValue === 'string' && columnFields.defaultValue.length === 0
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
index 60a7a7c2a16..fd289ea5e56 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx
@@ -1,7 +1,8 @@
+import Link from 'next/link'
import { FC, useEffect, useState } from 'react'
import { isUndefined, isEmpty } from 'lodash'
import { Dictionary } from 'components/grid'
-import { Checkbox, SidePanel, Input, Button, IconExternalLink } from 'ui'
+import { Checkbox, SidePanel, Input, Button, IconExternalLink, Toggle } from 'ui'
import {
PostgresColumn,
PostgresRelationship,
@@ -25,7 +26,8 @@ import {
} from './ColumnEditor.utils'
import { TEXT_TYPES } from '../SidePanelEditor.constants'
import { ColumnField, CreateColumnPayload, UpdateColumnPayload } from '../SidePanelEditor.types'
-import Link from 'next/link'
+import { FormSection, FormSectionContent, FormSectionLabel } from 'components/ui/Forms'
+import EncryptionKeySelector from 'components/interfaces/Vault/EncryptionKeySelector'
interface Props {
column?: PostgresColumn
@@ -136,7 +138,7 @@ const ColumnEditor: FC<Props> = ({
return (
<SidePanel
- size="large"
+ size="xlarge"
key="ColumnEditor"
visible={visible}
// @ts-ignore
@@ -159,11 +161,10 @@ const ColumnEditor: FC<Props> = ({
}
}}
>
- <SidePanel.Content>
- <div className="space-y-10 py-6">
+ <FormSection header={<FormSectionLabel>General</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
<Input
label="Name"
- layout="horizontal"
type="text"
error={errors.name}
value={columnFields?.name ?? ''}
@@ -171,42 +172,32 @@ const ColumnEditor: FC<Props> = ({
/>
<Input
label="Description"
- placeholder="Optional"
- layout="horizontal"
+ labelOptional="Optional"
type="text"
value={columnFields?.comment ?? ''}
onChange={(event: any) => onUpdateField({ comment: event.target.value })}
/>
- <div className="grid grid-cols-12 gap-4">
- <div className="col-span-12 md:col-span-8 md:col-start-5">
- <Checkbox
- label="Is Primary Key"
- description="A primary key indicates that a column or group of columns can be used as a unique identifier for rows in the table."
- checked={columnFields?.isPrimaryKey ?? false}
- onChange={() => onUpdateField({ isPrimaryKey: !columnFields?.isPrimaryKey })}
- />
- </div>
- </div>
- </div>
- </SidePanel.Content>
-
+ </FormSectionContent>
+ </FormSection>
<SidePanel.Separator />
-
- <SidePanel.Content>
- <div className="space-y-10 py-6">
- <ColumnForeignKey
- column={columnFields}
- originalForeignKey={originalForeignKey}
- onSelectEditRelation={() => setIsEditingRelation(true)}
- onSelectRemoveRelation={() => onUpdateField({ foreignKey: undefined })}
- />
- </div>
- </SidePanel.Content>
+ <FormSection header={<FormSectionLabel>Foreign Key Relation</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
+ <div>
+ <ColumnForeignKey
+ column={columnFields}
+ originalForeignKey={originalForeignKey}
+ onSelectEditRelation={() => setIsEditingRelation(true)}
+ onSelectRemoveRelation={() => onUpdateField({ foreignKey: undefined })}
+ />
+ </div>
+ </FormSectionContent>
+ </FormSection>
<SidePanel.Separator />
- <SidePanel.Content>
- <div className="space-y-10 py-6">
+ <FormSection header={<FormSectionLabel>Data Type</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
<ColumnType
value={columnFields?.format ?? ''}
+ layout="vertical"
enumTypes={enumTypes}
error={errors.format}
disabled={!isUndefined(columnFields?.foreignKey)}
@@ -227,11 +218,10 @@ const ColumnEditor: FC<Props> = ({
}
onOptionSelect={(format: string) => onUpdateField({ format, defaultValue: null })}
/>
-
{isUndefined(columnFields.foreignKey) && (
- <div className="grid grid-cols-12 gap-4">
+ <div className="space-y-4">
{columnFields.format.includes('int') && (
- <div className="col-span-12 md:col-span-8 md:col-start-5">
+ <div className="w-full">
<Checkbox
label="Is Identity"
description="Automatically assign a sequential unique number to the column"
@@ -245,7 +235,7 @@ const ColumnEditor: FC<Props> = ({
</div>
)}
{!columnFields.isPrimaryKey && (
- <div className="col-span-12 md:col-span-8 md:col-start-5">
+ <div className="w-full">
<Checkbox
label="Define as Array"
description="Allow column to be defined as variable-length multidimensional arrays"
@@ -265,38 +255,51 @@ const ColumnEditor: FC<Props> = ({
enumTypes={enumTypes}
onUpdateField={onUpdateField}
/>
- {!columnFields.isPrimaryKey && (
- <>
- <div className="grid grid-cols-12 gap-4">
- <div className="col-span-12 md:col-span-8 md:col-start-5">
- <Checkbox
- label="Allow Nullable"
- description="Allow the column to assume a NULL value if no value is provided"
- checked={columnFields.isNullable}
- onChange={() => onUpdateField({ isNullable: !columnFields.isNullable })}
- />
- </div>
- <div className="col-span-12 md:col-span-8 md:col-start-5">
- <Checkbox
- label="Is Unique"
- description="Enforce values in the column to be unique across rows"
- checked={columnFields.isUnique}
- onChange={() => onUpdateField({ isUnique: !columnFields.isUnique })}
- />
- </div>
- </div>
- </>
- )}
-
- <ForeignKeySelector
- tables={tables}
- column={columnFields}
- visible={isEditingRelation}
- closePanel={() => setIsEditingRelation(false)}
- saveChanges={saveColumnForeignKey}
+ </FormSectionContent>
+ </FormSection>
+ <SidePanel.Separator />
+ <FormSection header={<FormSectionLabel>Configuration</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
+ <Toggle
+ label="Is Primary Key"
+ descriptionText="A primary key indicates that a column or group of columns can be used as a unique identifier for rows in the table"
+ checked={columnFields?.isPrimaryKey ?? false}
+ onChange={() => onUpdateField({ isPrimaryKey: !columnFields?.isPrimaryKey })}
/>
- </div>
- </SidePanel.Content>
+ <Toggle
+ label="Allow Nullable"
+ descriptionText="Allow the column to assume a NULL value if no value is provided"
+ checked={columnFields.isNullable}
+ onChange={() => onUpdateField({ isNullable: !columnFields.isNullable })}
+ />
+ <Toggle
+ label="Is Unique"
+ descriptionText="Enforce values in the column to be unique across rows"
+ checked={columnFields.isUnique}
+ onChange={() => onUpdateField({ isUnique: !columnFields.isUnique })}
+ />
+ </FormSectionContent>
+ </FormSection>
+ <SidePanel.Separator />
+ <FormSection header={<FormSectionLabel>Security</FormSectionLabel>}>
+ <FormSectionContent loading={false}>
+ <Toggle
+ label="Encrypt Column"
+ descriptionText="Encrypt the column's data with pgsodium's Transparent Column Encryption (TCE)"
+ checked={columnFields.isEncrypted}
+ onChange={() => onUpdateField({ isEncrypted: !columnFields.isEncrypted })}
+ />
+ {columnFields.isEncrypted && <EncryptionKeySelector />}
+ </FormSectionContent>
+ </FormSection>
+
+ <ForeignKeySelector
+ tables={tables}
+ column={columnFields}
+ visible={isEditingRelation}
+ closePanel={() => setIsEditingRelation(false)}
+ saveChanges={saveColumnForeignKey}
+ />
</SidePanel>
)
}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
index 299dbfad1d8..be7e62bafd3 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.utils.ts
@@ -43,6 +43,7 @@ export const generateColumnField = (field: any = {}): ColumnField => {
isPrimaryKey: false,
isIdentity: false,
isNewColumn: true,
+ isEncrypted: false,
}
}
@@ -69,6 +70,7 @@ export const generateColumnFieldFromPostgresColumn = (
isUnique: column.is_unique,
isNewColumn: false,
+ isEncrypted: false,
isPrimaryKey: primaryKeyColumns.includes(column.name),
}
}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnForeignKey.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnForeignKey.tsx
index cd3a32e6ca0..45a09d5a3cd 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnForeignKey.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnForeignKey.tsx
@@ -1,6 +1,6 @@
import { FC } from 'react'
import { isUndefined } from 'lodash'
-import { Button, IconArrowRight, IconLink } from 'ui'
+import { Button, IconArrowRight } from 'ui'
import { ColumnField } from '../SidePanelEditor.types'
import InformationBox from 'components/ui/InformationBox'
@@ -86,9 +86,8 @@ const ColumnForeignKeyInformation: FC<{
return (
<InformationBox
block
- icon={<IconLink />}
title={
- <div className="flex items-center justify-between text-scale-900">
+ <div className="flex flex-col space-y-4 text-scale-900">
<div className="space-y-2">
<span>This column has the following foreign key relation:</span>
<div className="flex items-center space-x-2">
@@ -123,20 +122,23 @@ const ColumnForeignKeyAdded: FC<{
return (
<InformationBox
block
- icon={<IconLink />}
title={
- <div className="flex items-center justify-between text-scale-1100">
+ <div className="flex flex-col space-y-4 text-scale-1100">
<div className="space-y-2">
<span>
The following foreign key relation will be{' '}
<span className="text-brand-900">added</span>:
</span>
<div className="flex items-center space-x-2 text-scale-1200">
- <span className={`${columnName.length > 0 ? 'text-code' : ''} max-w-xs truncate`}>
+ <span
+ className={`${
+ columnName.length > 0 ? 'text-code font-mono text-xs' : ''
+ } max-w-xs truncate`}
+ >
{columnName || 'This column'}
</span>
<IconArrowRight size={14} strokeWidth={2} />
- <span className="max-w-xs truncate text-code">
+ <span className="max-w-xs text-xs truncate text-code font-mono">
{foreignKey?.target_table_schema}.{foreignKey?.target_table_name}.
{foreignKey?.target_column_name}
</span>
@@ -164,9 +166,8 @@ const ColumnForeignKeyRemoved: FC<{
return (
<InformationBox
block
- icon={<IconLink />}
title={
- <div className="flex items-center justify-between">
+ <div className="flex flex-col space-y-4">
<div className="space-y-2">
<p>
The following foreign key relation will be{' '}
@@ -208,9 +209,8 @@ const ColumnForeignKeyUpdated: FC<{
return (
<InformationBox
block
- icon={<IconLink />}
title={
- <div className="flex items-center justify-between">
+ <div className="flex flex-col space-y-4">
<div className="space-y-2">
<p>
The foreign key relation will be <span className="text-brand-900">updated</span> as
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
index 33ba1198cc3..cd7494171ef 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnType.tsx
@@ -8,6 +8,7 @@ interface Props {
value: string
enumTypes: PostgresType[]
size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
+ layout?: 'vertical' | 'horizontal'
className?: string
error?: any
disabled?: boolean
@@ -21,6 +22,7 @@ const ColumnType: FC<Props> = ({
enumTypes = [],
className,
size = 'medium',
+ layout,
error,
disabled = false,
showLabel = true,
@@ -72,7 +74,7 @@ const ColumnType: FC<Props> = ({
return (
<Listbox
label={showLabel ? 'Type' : ''}
- layout={showLabel ? 'horizontal' : 'vertical'}
+ layout={layout || (showLabel ? 'horizontal' : 'vertical')}
value={value}
size={size}
error={error}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
index 65718745a15..5def89a726c 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ForeignKeySelector/ForeignKeySelector.tsx
@@ -111,8 +111,12 @@ const ForeignKeySelector: FC<Props> = ({
// @ts-ignore
header={
<span>
- Edit foreign key relation for{' '}
- <span className="text-code">{get(column, ['name'], '')}</span>
+ Edit foreign key relation{' '}
+ {column?.name && (
+ <>
+ for <span className="text-code">{get(column, ['name'], '')}</span>
+ </>
+ )}
</span>
}
customFooter={
@@ -125,7 +129,7 @@ const ForeignKeySelector: FC<Props> = ({
}
>
<SidePanel.Content>
- <div className="space-y-6">
+ <div className="py-6 space-y-6">
<InformationBox
icon={<IconHelpCircle size="large" strokeWidth={1.5} />}
title="What are foreign keys?"
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
index 8a0d3ee57d3..f02e85c7eef 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
@@ -280,6 +280,13 @@ const SidePanelEditor: FC<Props> = ({
saveChanges={saveColumn}
updateEditorDirty={() => setIsEdited(true)}
/>
+ // <ColumnEditorV2
+ // visible={sidePanelKey === 'column'}
+ // column={selectedColumnToEdit}
+ // selectedTable={selectedTable}
+ // enumTypes={enumTypes}
+ // closePanel={onClosePanel}
+ // />
)}
<TableEditor
table={selectedTableToEdit}
diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.types.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.types.ts
index b4d0338e14f..81be676ee29 100644
--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.types.ts
+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.types.ts
@@ -69,6 +69,7 @@ export interface ColumnField {
isIdentity: boolean
isPrimaryKey: boolean
isNewColumn: boolean
+ isEncrypted: boolean
}
// export interface ForeignKey {
diff --git a/studio/components/interfaces/Vault/EncryptionKeySelector.tsx b/studio/components/interfaces/Vault/EncryptionKeySelector.tsx
new file mode 100644
index 00000000000..bfc5fc70642
--- /dev/null
+++ b/studio/components/interfaces/Vault/EncryptionKeySelector.tsx
@@ -0,0 +1,76 @@
+import { FC, useState, useEffect } from 'react'
+import { Input, Listbox, Modal, IconPlus } from 'ui'
+
+interface Props {
+ id?: string
+ labelOptional?: string
+ onSelectKey?: (key: any) => void
+ onChangeKeyName?: (key: string) => void
+}
+
+const EncryptionKeySelector: FC<Props> = ({
+ id,
+ labelOptional,
+ onSelectKey = () => {},
+ onChangeKeyName = () => {},
+}) => {
+ const [showNewKeyField, setShowNewKeyField] = useState(false)
+
+ useEffect(() => {
+ console.log('Fetch all avaiable encryption keys from vault')
+ }, [])
+
+ const mockKeys = [
+ { id: 1, name: 'profile_full_name_key' },
+ { id: 2, name: 'user_email_key' },
+ { id: 3, name: 'customer_address_key' },
+ ]
+
+ const onChange = (id: any) => {
+ if (id === 'create-new') {
+ setShowNewKeyField(true)
+ } else {
+ setShowNewKeyField(false)
+ const key = mockKeys.find((key) => key.id === id)
+ onSelectKey(key)
+ }
+ }
+
+ return (
+ <>
+ <Listbox
+ id={id}
+ label="Encryption Key"
+ size="small"
+ defaultValue={mockKeys[0].id}
+ labelOptional={labelOptional}
+ onChange={onChange}
+ >
+ <Listbox.Option
+ key="create-new"
+ id="create-new"
+ value="create-new"
+ label="Create a new Encryption Key"
+ addOnBefore={() => <IconPlus size={16} strokeWidth={1.5} />}
+ >
+ Create a new Encryption Key
+ </Listbox.Option>
+ <Modal.Separator />
+ {mockKeys.map((key) => (
+ <Listbox.Option key={key.id} label={key.name} value={key.id}>
+ {key.name}
+ </Listbox.Option>
+ ))}
+ </Listbox>
+ {showNewKeyField && (
+ <Input
+ id="newKeyName"
+ label="Encryption Key Name"
+ onChange={(e) => onChangeKeyName(e.target.value)}
+ />
+ )}
+ </>
+ )
+}
+
+export default EncryptionKeySelector
diff --git a/studio/pages/project/[ref]/settings/general.tsx b/studio/pages/project/[ref]/settings/general.tsx
index 697f85f6575..63f43cd3ca1 100644
--- a/studio/pages/project/[ref]/settings/general.tsx
+++ b/studio/pages/project/[ref]/settings/general.tsx
@@ -1,19 +1,13 @@
import { observer } from 'mobx-react-lite'
import { NextPageWithLayout } from 'types'
import { SettingsLayout } from 'components/layouts'
-import {
- General,
- Infrastructure,
- Vault,
- DeleteProjectPanel,
-} from 'components/interfaces/Settings/General'
+import { General, Infrastructure, DeleteProjectPanel } from 'components/interfaces/Settings/General'
const ProjectSettings: NextPageWithLayout = () => {
return (
<div className="1xl:px-28 mx-auto flex flex-col gap-8 px-5 py-6 lg:px-16 xl:px-24 2xl:px-32 ">
<General />
<Infrastructure />
- <Vault />
<DeleteProjectPanel />
</div>
)