From bb51173e7b46f76ca554238a5075891e1d5f69e7 Mon Sep 17 00:00:00 2001 From: Alaister Young Date: Wed, 27 Nov 2024 21:01:00 +0800 Subject: [PATCH 1/3] feat: cal.com wrapper (#30563) * feat: cal.com wrapper * add description for cal wrapper * Fix logo --------- Co-authored-by: Joshen Lim --- .../Wrappers/WrapperDynamicColumns.tsx | 2 +- .../Integrations/Wrappers/WrapperRow.tsx | 2 +- .../Wrappers/Wrappers.constants.ts | 208 ++++++++++++++++++ .../ColumnEditor/ColumnType.tsx | 3 +- apps/studio/public/img/icons/cal-com-icon.svg | 1 + .../integrations/cal_wrapper/overview.md | 3 + 6 files changed, 216 insertions(+), 3 deletions(-) create mode 100644 apps/studio/public/img/icons/cal-com-icon.svg create mode 100644 apps/studio/static-data/integrations/cal_wrapper/overview.md diff --git a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx index 6c9f5cdebc447..001e453513878 100644 --- a/apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx +++ b/apps/studio/components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx @@ -117,7 +117,7 @@ const WrapperDynamicColumns = ({
{columns.map((column, idx) => (
-
+
{ setisClosingEditWrapper(true)}> - + +
{showLabel && Type} diff --git a/apps/studio/public/img/icons/cal-com-icon.svg b/apps/studio/public/img/icons/cal-com-icon.svg new file mode 100644 index 0000000000000..dd74ef165d8f8 --- /dev/null +++ b/apps/studio/public/img/icons/cal-com-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/studio/static-data/integrations/cal_wrapper/overview.md b/apps/studio/static-data/integrations/cal_wrapper/overview.md new file mode 100644 index 0000000000000..92ec97f291944 --- /dev/null +++ b/apps/studio/static-data/integrations/cal_wrapper/overview.md @@ -0,0 +1,3 @@ +Cal.com is a calendar and scheduling service that allows you to create and share events with others. + +The Cal.com Wrapper allows you to read data from Cal.com within your Postgres database. From 3e7a0df1f8e40327fdbea1d2b003a7f2f69cd2db Mon Sep 17 00:00:00 2001 From: Feng Ruohang Date: Wed, 27 Nov 2024 21:49:48 +0800 Subject: [PATCH 2/3] Add new self-hosting option with ansible (#30689) Add a new self-hosting option with link https://pigsty.io/blog/db/supabase/. --- apps/docs/content/guides/self-hosting.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/docs/content/guides/self-hosting.mdx b/apps/docs/content/guides/self-hosting.mdx index 4c1da2e5519d1..1871402e39241 100644 --- a/apps/docs/content/guides/self-hosting.mdx +++ b/apps/docs/content/guides/self-hosting.mdx @@ -84,6 +84,11 @@ The following third-party providers have shown consistent support for the self-h description: 'Deploys using Kubernetes.', href: 'https://stackgres.io/blog/running-supabase-on-top-of-stackgres/', }, + { + name: 'Pigsty', + description: 'Deploys using Ansible.', + href: 'https://pigsty.io/blog/db/supabase/', + }, ].map((x) => (
From f2d9203ea22a52c6d64efa67fd994eab3784f621 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Wed, 27 Nov 2024 23:11:19 +0800 Subject: [PATCH 3/3] Prevent non owners from editing shared snippets (#30692) * Prevent non owners from editing shared snippets * Add guard against saving snippet which is shared + has folder id * FIX --- .../interfaces/SQLEditor/MonacoEditor.tsx | 120 ++++++++++-------- apps/studio/state/sql-editor-v2.ts | 47 ++++--- 2 files changed, 98 insertions(+), 69 deletions(-) diff --git a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx index b0571a93f6686..08c0dfd01ff4b 100644 --- a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx +++ b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx @@ -8,13 +8,14 @@ import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { useSelectedProject } from 'hooks/misc/useSelectedProject' import { LOCAL_STORAGE_KEYS } from 'lib/constants' import { useProfile } from 'lib/profile' +import { useAppStateSnapshot } from 'state/app-state' import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2' import { cn } from 'ui' +import { Admonition } from 'ui-patterns' +import { useIsAssistantV2Enabled } from '../App/FeaturePreview/FeaturePreviewContext' import { untitledSnippetTitle } from './SQLEditor.constants' import type { IStandaloneCodeEditor } from './SQLEditor.types' import { createSqlSnippetSkeletonV2 } from './SQLEditor.utils' -import { useIsAssistantV2Enabled } from '../App/FeaturePreview/FeaturePreviewContext' -import { useAppStateSnapshot } from 'state/app-state' export type MonacoEditorProps = { id: string @@ -50,6 +51,8 @@ const MonacoEditor = ({ ) const snippet = snapV2.snippets[id] + const disableEdit = + snippet?.snippet.visibility === 'project' && snippet?.snippet.owner_id !== profile?.id const executeQueryRef = useRef(executeQuery) executeQueryRef.current = executeQuery @@ -152,57 +155,68 @@ const MonacoEditor = ({ }, []) return ( - + <> + {disableEdit && ( + + )} + + ) } diff --git a/apps/studio/state/sql-editor-v2.ts b/apps/studio/state/sql-editor-v2.ts index 8e8cfad29fe70..6e6b7af792a6b 100644 --- a/apps/studio/state/sql-editor-v2.ts +++ b/apps/studio/state/sql-editor-v2.ts @@ -462,22 +462,37 @@ if (typeof window !== 'undefined') { const folder = state.folders[id] if (snippet) { - debouncedUpdateSnippet(id, snippet.projectRef, { - id, - type: 'sql', - name: snippet.snippet.name ?? 'Untitled', - description: snippet.snippet.description ?? '', - visibility: snippet.snippet.visibility ?? 'user', - project_id: snippet.snippet.project_id ?? 0, - owner_id: snippet.snippet.owner_id, - folder_id: snippet.snippet.folder_id, - content: { - ...snippet.snippet.content, - content_id: id, - favorite: snippet.snippet.favorite, - }, - }) - sqlEditorState.needsSaving.delete(id) + const { + name, + description, + visibility, + project_id, + owner_id, + folder_id, + content, + favorite, + } = snippet.snippet + + if (visibility === 'project' && !!folder_id) { + toast.error('Shared snippet cannot be within a folder') + } else { + debouncedUpdateSnippet(id, snippet.projectRef, { + id, + type: 'sql', + name: name ?? 'Untitled', + description: description ?? '', + visibility: visibility ?? 'user', + project_id: project_id ?? 0, + owner_id: owner_id, + folder_id: folder_id, + content: { + ...content, + content_id: id, + favorite: favorite, + }, + }) + sqlEditorState.needsSaving.delete(id) + } } else if (folder) { upsertFolder(id, folder.projectRef, folder.folder.name) sqlEditorState.needsSaving.delete(id)