mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 13:49:09 +03:00
fix: now supplying projectRef to content store in setProjectRef() in rootStore
This commit is contained in:
1 parent
a099f2cff9
commit
25e9f48a09
2 files changed
+17
-4
No files matched your search
@@ -52,14 +52,12 @@ export class RootStore implements IRootStore {
|
||||
(selectedProject) => {
|
||||
if (selectedProject) {
|
||||
// @ts-ignore
|
||||
this.content = new ProjectContentStore(this, { projectRef: selectedProject.ref })
|
||||
this.meta = new MetaStore(this, {
|
||||
projectRef: selectedProject.ref,
|
||||
connectionString: selectedProject.connectionString ?? '',
|
||||
})
|
||||
} else {
|
||||
// @ts-ignore
|
||||
this.content = new ProjectContentStore(this, { projectRef: '' })
|
||||
this.meta = new MetaStore(this, {
|
||||
projectRef: '',
|
||||
connectionString: '',
|
||||
@@ -88,6 +86,7 @@ export class RootStore implements IRootStore {
|
||||
|
||||
this.ui.setProjectRef(value)
|
||||
this.functions.setProjectRef(value)
|
||||
this.content.setProjectRef(value)
|
||||
}
|
||||
|
||||
setOrganizationSlug(value?: string) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { makeAutoObservable } from 'mobx'
|
||||
import { makeAutoObservable, action } from 'mobx'
|
||||
import { keyBy } from 'lodash'
|
||||
|
||||
import { get, post, patch, delete_ } from 'lib/common/fetch'
|
||||
@@ -15,11 +15,15 @@ export interface IProjectContentStore {
|
||||
isLoaded: boolean
|
||||
error: any
|
||||
|
||||
baseUrl: string
|
||||
projectRef?: string
|
||||
|
||||
load: () => void
|
||||
create: (x: UserContent) => { data: UserContent; error: { error: { message: string } } }
|
||||
list: (filter?: any) => any[]
|
||||
reports: (filter?: any) => any[]
|
||||
sqlSnippets: (filter?: any) => any[]
|
||||
setProjectRef: (ref?: string) => void
|
||||
}
|
||||
|
||||
export default class ProjectContentStore implements IProjectContentStore {
|
||||
@@ -33,6 +37,8 @@ export default class ProjectContentStore implements IProjectContentStore {
|
||||
}
|
||||
|
||||
baseUrl: string
|
||||
projectRef: string
|
||||
|
||||
data: UserContentMap = {}
|
||||
|
||||
state = this.STATES.INITIAL
|
||||
@@ -40,8 +46,9 @@ export default class ProjectContentStore implements IProjectContentStore {
|
||||
|
||||
constructor(rootStore: IRootStore, options: { projectRef: string }) {
|
||||
const { projectRef } = options
|
||||
this.projectRef = projectRef
|
||||
this.rootStore = rootStore
|
||||
this.baseUrl = `${API_URL}/projects/${projectRef}/content`
|
||||
this.baseUrl = ``
|
||||
makeAutoObservable(this)
|
||||
}
|
||||
|
||||
@@ -190,4 +197,11 @@ export default class ProjectContentStore implements IProjectContentStore {
|
||||
return { data: false, error }
|
||||
}
|
||||
}
|
||||
|
||||
setProjectRef(ref?: string) {
|
||||
if (ref) {
|
||||
this.projectRef = ref
|
||||
this.baseUrl = `${API_URL}/projects/${ref}/content`
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user