Skip to content

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

chore: hide subscription in views

gitstartc480be7e791f
diff --git a/studio/components/interfaces/Docs/ResourceContent.tsx b/studio/components/interfaces/Docs/ResourceContent.tsx
index a37ed884081..6fc63ae6b95 100644
--- a/studio/components/interfaces/Docs/ResourceContent.tsx
+++ b/studio/components/interfaces/Docs/ResourceContent.tsx
@@ -12,6 +12,7 @@ const ResourceContent = ({
selectedLang,
showApiKey,
refreshDocs,
+ isView,
}: any) => {
if (!paths || !definitions) return null
@@ -221,49 +222,51 @@ const ResourceContent = ({
</div>
</>
)}
- <>
- <h3 className="text-scale-1200 mt-4 px-6">Subscribe to changes</h3>
- <div className="doc-section">
- <article className="text ">
- <p>
- Supabase provides realtime functionality and broadcasts database changes to authorized
- users depending on Row Level Security (RLS) policies.
- </p>
- <p>
- <a href="https://supabase.com/docs/client/subscribe" target="_blank">
- Learn more.
- </a>
- </p>
- </article>
- <article className="code">
- <CodeSnippet
- selectedLang={selectedLang}
- snippet={Snippets.subscribeAll(resourceMeta.camelCase, resourceId)}
- />
- <CodeSnippet
- selectedLang={selectedLang}
- snippet={Snippets.subscribeInserts(resourceMeta.camelCase, resourceId)}
- />
- <CodeSnippet
- selectedLang={selectedLang}
- snippet={Snippets.subscribeUpdates(resourceMeta.camelCase, resourceId)}
- />
- <CodeSnippet
- selectedLang={selectedLang}
- snippet={Snippets.subscribeDeletes(resourceMeta.camelCase, resourceId)}
- />
- <CodeSnippet
- selectedLang={selectedLang}
- snippet={Snippets.subscribeEq(
- resourceMeta.camelCase,
- resourceId,
- 'column_name',
- 'someValue'
- )}
- />
- </article>
- </div>
- </>
+ {!isView && (
+ <>
+ <h3 className="text-scale-1200 mt-4 px-6">Subscribe to changes</h3>
+ <div className="doc-section">
+ <article className="text ">
+ <p>
+ Supabase provides realtime functionality and broadcasts database changes to
+ authorized users depending on Row Level Security (RLS) policies.
+ </p>
+ <p>
+ <a href="https://supabase.com/docs/client/subscribe" target="_blank">
+ Learn more.
+ </a>
+ </p>
+ </article>
+ <article className="code">
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.subscribeAll(resourceMeta.camelCase, resourceId)}
+ />
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.subscribeInserts(resourceMeta.camelCase, resourceId)}
+ />
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.subscribeUpdates(resourceMeta.camelCase, resourceId)}
+ />
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.subscribeDeletes(resourceMeta.camelCase, resourceId)}
+ />
+ <CodeSnippet
+ selectedLang={selectedLang}
+ snippet={Snippets.subscribeEq(
+ resourceMeta.camelCase,
+ resourceId,
+ 'column_name',
+ 'someValue'
+ )}
+ />
+ </article>
+ </div>
+ </>
+ )}
<>
<h3 className="text-scale-1200 mt-4 px-6">Much more</h3>
<div className="doc-section py-4">
diff --git a/studio/pages/project/[ref]/api/index.tsx b/studio/pages/project/[ref]/api/index.tsx
index 482494908ff..a4ac6b6cc21 100644
--- a/studio/pages/project/[ref]/api/index.tsx
+++ b/studio/pages/project/[ref]/api/index.tsx
@@ -75,6 +75,7 @@ const DocView: FC<any> = observer(({}) => {
const API_KEY = data?.autoApiService?.defaultApiKey
const swaggerUrl = data?.autoApiService?.restUrl
const headers: any = { apikey: API_KEY }
+ const selectedSchema = data?.autoApiService?.app_config?.db_schema
const canReadServiceKey = checkPermissions(
PermissionAction.READ,
@@ -88,10 +89,19 @@ const DocView: FC<any> = observer(({}) => {
(url: string) => get(url, { headers, credentials: 'omit' }).then((res) => res)
)
+ const { meta } = useStore()
+
useEffect(() => {
PageState.setJsonSchema(jsonSchema)
}, [jsonSchema])
+ useEffect(() => {
+ const fetchViews = async (selectedSchema: string) => {
+ await meta.schemas.loadViews(selectedSchema)
+ }
+ if (selectedSchema) fetchViews(selectedSchema)
+ }, [selectedSchema])
+
const refreshDocs = async () => {
// A bit hacky calling coding this up twice - at some point we should move this function
// and the SWR into the store.
@@ -128,6 +138,8 @@ const DocView: FC<any> = observer(({}) => {
const PAGE_KEY: any = resource || rpc || page || 'index'
+ const resourceIsView = meta.schemas.views?.some((view) => view.name === resource)
+
return (
<div className="Docs h-full w-full overflow-y-auto" key={PAGE_KEY}>
<div className="Docs--inner-wrapper">
@@ -216,6 +228,7 @@ const DocView: FC<any> = observer(({}) => {
paths={paths}
showApiKey={showApiKey.key}
refreshDocs={refreshDocs}
+ isView={resourceIsView}
/>
) : rpc ? (
<RpcContent