Skip to content

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

Fix support form now initializing project when ref passed in new tab, and add support for pre-selecting category

Joshen Lim0dee42b28c8d
diff --git a/studio/pages/support/new.tsx b/studio/pages/support/new.tsx
index cb10cfb3a6f..4daa8b28301 100644
--- a/studio/pages/support/new.tsx
+++ b/studio/pages/support/new.tsx
@@ -20,6 +20,7 @@ import { useStore, withAuth } from 'hooks'
import { post, get } from 'lib/common/fetch'
import { Project } from 'types'
import { isUndefined } from 'lodash'
+import Connecting from 'components/ui/Loading/Loading'
const DEFAULT = {
category: {
@@ -117,6 +118,7 @@ const SupportNew = () => {
const { ui, app } = useStore()
const router = useRouter()
const projectRef = router.query.ref
+ const category = router.query.category
const [formState, formDispatch] = useReducer(formReducer, DEFAULT)
const [errors, setErrors] = useState<any>([])
@@ -136,22 +138,35 @@ const SupportNew = () => {
},
]
+ const isInitialized = app.projects.isInitialized
const projects = [...sortedProjects, ...projectDefaults]
useEffect(() => {
- // set project default
- if (sortedProjects.length > 1) {
- const selectedProject = sortedProjects.find((project: Project) => project.ref === projectRef)
- if (!isUndefined(selectedProject)) {
- handleOnChange({ name: 'project', value: selectedProject.ref })
+ if (isInitialized) {
+ // set project default
+ if (sortedProjects.length > 1) {
+ const selectedProject = sortedProjects.find(
+ (project: Project) => project.ref === projectRef
+ )
+ if (!isUndefined(selectedProject)) {
+ handleOnChange({ name: 'project', value: selectedProject.ref })
+ } else {
+ handleOnChange({ name: 'project', value: sortedProjects[0].ref })
+ }
} else {
- handleOnChange({ name: 'project', value: sortedProjects[0].ref })
+ // set as 'No specific project'
+ handleOnChange({ name: 'project', value: projectDefaults[0].ref })
+ }
+
+ // Set category based on query param
+ if (category) {
+ const selectedCategory = categoryOptions.find((option) => {
+ if (option.value.toLowerCase() === category) return option
+ })
+ if (selectedCategory) handleOnChange({ name: 'category', value: selectedCategory.value })
}
- } else {
- // set as 'No specific project'
- handleOnChange({ name: 'project', value: projectDefaults[0].ref })
}
- }, [])
+ }, [isInitialized])
function handleOnChange(x: any) {
formDispatch({
@@ -254,6 +269,8 @@ const SupportNew = () => {
)
}
+ if (!isInitialized) return <Connecting />
+
return (
<div className="flex h-screen relative overflow-y-auto overflow-x-hidden">
<div className="max-w-2xl mx-auto my-8 px-4 lg:px-6">