Skip to content

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

Update org v1 general settings to use RQ mutation, and deprecate cmdk and cmdk opt in flags

Joshen Lim73ae74bf0618
diff --git a/studio/components/interfaces/App/CommandMenuWrapper.tsx b/studio/components/interfaces/App/CommandMenuWrapper.tsx
index a1be2dc01dd..702bb053ae7 100644
--- a/studio/components/interfaces/App/CommandMenuWrapper.tsx
+++ b/studio/components/interfaces/App/CommandMenuWrapper.tsx
@@ -8,7 +8,7 @@ import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectConte
import { useProjectApiQuery } from 'data/config/project-api-query'
import { SqlSnippet } from 'data/content/sql-snippets-query'
import { useEntityDefinitionsQuery } from 'data/database/entity-definitions-query'
-import { useCheckPermissions, useFlag, useSelectedOrganization, useStore } from 'hooks'
+import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
import { uuidv4 } from 'lib/helpers'
import { useProfile } from 'lib/profile'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
@@ -22,7 +22,6 @@ const CommandMenuWrapper = ({ children }: PropsWithChildren<{}>) => {
const opt_in_tags = selectedOrganization?.opt_in_tags
const snap = useSqlEditorStateSnapshot()
- const allowCMDKDataOptIn = useFlag('dashboardCmdkDataOptIn')
const isOptedInToAI = opt_in_tags?.includes('AI_SQL_GENERATOR_OPT_IN') ?? false
const { profile } = useProfile()
@@ -48,9 +47,9 @@ const CommandMenuWrapper = ({ children }: PropsWithChildren<{}>) => {
const cmdkMetadata = useMemo(() => {
return {
definitions: (data ?? []).map((def) => def.sql.trim()).join('\n\n'),
- flags: { allowCMDKDataOptIn },
+ flags: {},
}
- }, [data, allowCMDKDataOptIn])
+ }, [data])
const onSaveGeneratedSQL = async (answer: string, title: string) => {
if (!ref) return console.error('Project ref is required')
@@ -101,7 +100,7 @@ const CommandMenuWrapper = ({ children }: PropsWithChildren<{}>) => {
projectRef={ref}
apiKeys={apiKeys}
metadata={cmdkMetadata}
- isOptedInToAI={allowCMDKDataOptIn && isOptedInToAI}
+ isOptedInToAI={isOptedInToAI}
saveGeneratedSQL={onSaveGeneratedSQL}
>
{children}
diff --git a/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx b/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
index d00e2624fb6..cd2854305cb 100644
--- a/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
+++ b/studio/components/interfaces/Organization/BillingSettings/BillingEmail.tsx
@@ -38,22 +38,14 @@ const BillingEmail = () => {
}
if (!slug) return console.error('Slug is required')
- if (!name) return console.error('Organization name is required')
updateOrganization(
- {
- slug,
- name,
- billing_email: values.billing_email,
- },
+ { slug, billing_email: values.billing_email },
{
onSuccess: ({ billing_email }) => {
resetForm({ values: { billing_email }, initialValues: { billing_email } })
invalidateOrganizationsQuery(queryClient)
- ui.setNotification({
- category: 'success',
- message: 'Successfully saved settings',
- })
+ ui.setNotification({ category: 'success', message: 'Successfully saved settings' })
},
}
)
diff --git a/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx b/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx
index d9c6c825ab8..16facd87e61 100644
--- a/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx
+++ b/studio/components/interfaces/Organization/GeneralSettings/GeneralSettings.tsx
@@ -1,12 +1,13 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
import clsx from 'clsx'
+import { useParams } from 'common'
import { observer } from 'mobx-react-lite'
import Link from 'next/link'
import { useEffect, useState } from 'react'
import { Collapsible, Form, IconChevronRight, Input, Toggle } from 'ui'
-import { useParams } from 'common/hooks'
+import NoProjectsOnPaidOrgInfo from 'components/interfaces/BillingV2/NoProjectsOnPaidOrgInfo'
import { ScaffoldContainerLegacy } from 'components/layouts/Scaffold'
import {
FormActions,
@@ -15,13 +16,10 @@ import {
FormSectionContent,
FormSectionLabel,
} from 'components/ui/Forms'
+import { useOrganizationUpdateMutation } from 'data/organizations/organization-update-mutation'
import { invalidateOrganizationsQuery } from 'data/organizations/organizations-query'
-import { useCheckPermissions, useFlag, useSelectedOrganization, useStore } from 'hooks'
-import { isResponseOk, patch } from 'lib/common/fetch'
-import { API_URL } from 'lib/constants'
-import { Organization } from 'types'
+import { useCheckPermissions, useSelectedOrganization, useStore } from 'hooks'
import OrganizationDeletePanel from './OrganizationDeletePanel'
-import NoProjectsOnPaidOrgInfo from 'components/interfaces/BillingV2/NoProjectsOnPaidOrgInfo'
const GeneralSettings = () => {
const queryClient = useQueryClient()
@@ -35,11 +33,10 @@ const GeneralSettings = () => {
const isOptedIntoAi = opt_in_tags?.includes('AI_SQL_GENERATOR_OPT_IN')
const initialValues = { name: name ?? '', isOptedIntoAi }
- const showCMDK = useFlag('dashboardCmdk')
- const allowCMDKDataOptIn = useFlag('dashboardCmdkDataOptIn')
-
const canUpdateOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
const canDeleteOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
+ const { mutate: updateOrganization, isLoading: isUpdating } = useOrganizationUpdateMutation()
+
const onUpdateOrganization = async (values: any, { setSubmitting, resetForm }: any) => {
if (!canUpdateOrganization) {
return ui.setNotification({
@@ -48,27 +45,23 @@ const GeneralSettings = () => {
})
}
- setSubmitting(true)
+ if (!slug) return console.error('Slug is required')
- // [Joshen] Need to update this logic once we support multiple opt in tags
- const optInTags = values.isOptedIntoAi ? ['AI_SQL_GENERATOR_OPT_IN'] : []
- const response = await patch<Organization>(`${API_URL}/organizations/${slug}`, {
- name: values.name,
- billing_email: selectedOrganization?.billing_email ?? '',
- ...(allowCMDKDataOptIn && { opt_in_tags: optInTags }),
- })
+ const existingOptInTags = selectedOrganization?.opt_in_tags ?? []
+ const updatedOptInTags = values.isOptedIntoAi
+ ? existingOptInTags.concat(['AI_SQL_GENERATOR_OPT_IN'])
+ : existingOptInTags.filter((x) => x !== 'AI_SQL_GENERATOR_OPT_IN')
- if (!isResponseOk(response)) {
- ui.setNotification({
- category: 'error',
- message: `Failed to update organization: ${response.error.message}`,
- })
- } else {
- resetForm({ values, initialValues: values })
- invalidateOrganizationsQuery(queryClient)
- ui.setNotification({ category: 'success', message: 'Successfully saved settings' })
- }
- setSubmitting(false)
+ updateOrganization(
+ { slug, name: values.name, opt_in_tags: updatedOptInTags },
+ {
+ onSuccess: () => {
+ resetForm({ values, initialValues: values })
+ invalidateOrganizationsQuery(queryClient)
+ ui.setNotification({ category: 'success', message: 'Successfully saved settings' })
+ },
+ }
+ )
}
return (
@@ -76,7 +69,7 @@ const GeneralSettings = () => {
<NoProjectsOnPaidOrgInfo organization={selectedOrganization} />
<Form id={formId} initialValues={initialValues} onSubmit={onUpdateOrganization}>
- {({ isSubmitting, handleReset, values, initialValues, resetForm }: any) => {
+ {({ handleReset, values, initialValues, resetForm }: any) => {
const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)
// [Alaister] although this "technically" is breaking the rules of React hooks
@@ -93,7 +86,7 @@ const GeneralSettings = () => {
<div className="flex py-4 px-8">
<FormActions
form={formId}
- isSubmitting={isSubmitting}
+ isSubmitting={isUpdating}
hasChanges={hasChanges}
handleReset={handleReset}
helper={
@@ -113,80 +106,78 @@ const GeneralSettings = () => {
label="Organization name"
disabled={!canUpdateOrganization}
/>
- {showCMDK && allowCMDKDataOptIn && (
- <div className="mt-4">
- <Toggle
- id="isOptedIntoAi"
- name="isOptedIntoAi"
- disabled={!canUpdateOrganization}
- size="small"
- label="Opt-in to sending anonymous data to OpenAI"
- descriptionText="By opting into sending anonymous data, Supabase AI can improve the answers it shows you"
- />
- <Collapsible open={open} onOpenChange={setOpen}>
- <Collapsible.Trigger asChild>
- <div className="flex items-center space-x-2 ml-16 cursor-pointer">
- <IconChevronRight
- strokeWidth={2}
- size={16}
- className={clsx('transition-all', open ? 'rotate-90' : '')}
- />
- <p className="text-sm text-scale-1000 underline">
- Important information regarding opting in
- </p>
- </div>
- </Collapsible.Trigger>
- <Collapsible.Content>
- <div className="space-y-2 py-4 ml-16 text-sm text-scale-1100">
- <p>
- Supabase AI is a chatbot support tool powered by OpenAI. Supabase will
- share the query you submit and information about the databases you
- manage through Supabase with OpenAI, L.L.C. and its affiliates in
- order to provide the Supabase AI tool.
- </p>
- <p>
- OpenAI will only access information about the structure of your
- databases, such as table names, column and row headings. OpenAI will
- not access the contents of the database itself.
- </p>
- <p>
- OpenAI uses this information to generate responses to your query, and
- does not retain or use the information to train its algorithms or
- otherwise improve its products and services.
- </p>
- <p>
- If you have your own individual account on Supabase, we will use any
- personal information collected through [Supabase AI] to provide you
- with the [Supabase AI] tool. If you are in the UK, EEA or Switzerland,
- the processing of this personal information is necessary for the
- performance of a contract between you and us.
- </p>
- <p>
- Supabase collects information about the queries you submit through
- Supabase AI and the responses you receive to assess the performance of
- the Supabase AI tool and improve our services. If you are in the UK,
- EEA or Switzerland, the processing is necessary for our legitimate
- interests, namely informing our product development and improvement.
- </p>
- <p>
- For more information about how we use personal information, please see
- our{' '}
- <Link href="https://supabase.com/privacy">
- <a
- target="_blank"
- rel="noreferrer"
- className="text-brand border-b border-brand"
- >
- privacy policy
- </a>
- </Link>
- .
- </p>
- </div>
- </Collapsible.Content>
- </Collapsible>
- </div>
- )}
+ <div className="mt-4">
+ <Toggle
+ id="isOptedIntoAi"
+ name="isOptedIntoAi"
+ disabled={!canUpdateOrganization}
+ size="small"
+ label="Opt-in to sending anonymous data to OpenAI"
+ descriptionText="By opting into sending anonymous data, Supabase AI can improve the answers it shows you"
+ />
+ <Collapsible open={open} onOpenChange={setOpen}>
+ <Collapsible.Trigger asChild>
+ <div className="flex items-center space-x-2 ml-16 cursor-pointer">
+ <IconChevronRight
+ strokeWidth={2}
+ size={16}
+ className={clsx('transition-all', open ? 'rotate-90' : '')}
+ />
+ <p className="text-sm text-scale-1000 underline">
+ Important information regarding opting in
+ </p>
+ </div>
+ </Collapsible.Trigger>
+ <Collapsible.Content>
+ <div className="space-y-2 py-4 ml-16 text-sm text-scale-1100">
+ <p>
+ Supabase AI is a chatbot support tool powered by OpenAI. Supabase will
+ share the query you submit and information about the databases you
+ manage through Supabase with OpenAI, L.L.C. and its affiliates in order
+ to provide the Supabase AI tool.
+ </p>
+ <p>
+ OpenAI will only access information about the structure of your
+ databases, such as table names, column and row headings. OpenAI will not
+ access the contents of the database itself.
+ </p>
+ <p>
+ OpenAI uses this information to generate responses to your query, and
+ does not retain or use the information to train its algorithms or
+ otherwise improve its products and services.
+ </p>
+ <p>
+ If you have your own individual account on Supabase, we will use any
+ personal information collected through [Supabase AI] to provide you with
+ the [Supabase AI] tool. If you are in the UK, EEA or Switzerland, the
+ processing of this personal information is necessary for the performance
+ of a contract between you and us.
+ </p>
+ <p>
+ Supabase collects information about the queries you submit through
+ Supabase AI and the responses you receive to assess the performance of
+ the Supabase AI tool and improve our services. If you are in the UK, EEA
+ or Switzerland, the processing is necessary for our legitimate
+ interests, namely informing our product development and improvement.
+ </p>
+ <p>
+ For more information about how we use personal information, please see
+ our{' '}
+ <Link href="https://supabase.com/privacy">
+ <a
+ target="_blank"
+ rel="noreferrer"
+ className="text-brand border-b border-brand"
+ >
+ privacy policy
+ </a>
+ </Link>
+ .
+ </p>
+ </div>
+ </Collapsible.Content>
+ </Collapsible>
+ </div>
</FormSectionContent>
</FormSection>
</FormPanel>
diff --git a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index ad43e9c951d..614154776f3 100644
--- a/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -1,10 +1,9 @@
import * as Tooltip from '@radix-ui/react-tooltip'
+import { useParams, useTheme } from 'common'
import { isUndefined } from 'lodash'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import { useTheme } from 'common'
-import { useParams } from 'common/hooks'
import { useFlag } from 'hooks'
import { IS_PLATFORM } from 'lib/constants'
import { detectOS } from 'lib/helpers'
@@ -36,7 +35,6 @@ const NavigationBar = () => {
const { project } = useProjectContext()
const navLayoutV2 = useFlag('navigationLayoutV2')
- const showCmdkHelper = useFlag('dashboardCmdk')
const supabaseAIEnabled = useFlag('sqlEditorSupabaseAI')
const activeRoute = router.pathname.split('/')[3]
@@ -99,7 +97,7 @@ const NavigationBar = () => {
</ul>
{!navLayoutV2 && (
<ul className="flex flex-col space-y-4 items-center">
- {IS_PLATFORM && showCmdkHelper && (
+ {IS_PLATFORM && (
<Tooltip.Root delayDuration={0}>
<Tooltip.Trigger asChild>
<Button
diff --git a/studio/data/organizations/organization-update-mutation.ts b/studio/data/organizations/organization-update-mutation.ts
index 39278eb3ea5..7550c0637da 100644
--- a/studio/data/organizations/organization-update-mutation.ts
+++ b/studio/data/organizations/organization-update-mutation.ts
@@ -56,7 +56,7 @@ export const useOrganizationUpdateMutation = ({
},
async onError(data, variables, context) {
if (onError === undefined) {
- toast.error(`Failed to update billing email: ${data.message}`)
+ toast.error(`Failed to update organization: ${data.message}`)
} else {
onError(data, variables, context)
}