From 04abf4f5160af6637814b969a258eb419f7a9144 Mon Sep 17 00:00:00 2001 From: Steven Le Date: Mon, 6 May 2024 11:20:31 -0700 Subject: [PATCH] feat: add "preview" button to data sources (#316) --- .changeset/khaki-turkeys-laugh.md | 5 +++ examples/blog/root-cms.d.ts | 2 +- .../DataSourceForm/DataSourceForm.tsx | 10 +++++ .../pages/DataSourcePage/DataSourcePage.css | 6 +++ .../pages/DataSourcePage/DataSourcePage.tsx | 43 ++++++++++++------- packages/root-cms/ui/utils/data-source.ts | 1 + 6 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 .changeset/khaki-turkeys-laugh.md diff --git a/.changeset/khaki-turkeys-laugh.md b/.changeset/khaki-turkeys-laugh.md new file mode 100644 index 00000000..fcc1cb6f --- /dev/null +++ b/.changeset/khaki-turkeys-laugh.md @@ -0,0 +1,5 @@ +--- +'@blinkk/root-cms': patch +--- + +feat: add "preview" button to data sources diff --git a/examples/blog/root-cms.d.ts b/examples/blog/root-cms.d.ts index dd4c7d89..ea0a4371 100644 --- a/examples/blog/root-cms.d.ts +++ b/examples/blog/root-cms.d.ts @@ -9,7 +9,7 @@ export interface RootCMSImage { export type RootCMSOneOf = T & { _type: string; -} +}; export interface RootCMSRichTextBlock { type: string; diff --git a/packages/root-cms/ui/components/DataSourceForm/DataSourceForm.tsx b/packages/root-cms/ui/components/DataSourceForm/DataSourceForm.tsx index 47a71dbd..e63964e8 100644 --- a/packages/root-cms/ui/components/DataSourceForm/DataSourceForm.tsx +++ b/packages/root-cms/ui/components/DataSourceForm/DataSourceForm.tsx @@ -104,6 +104,7 @@ export function DataSourceForm(props: DataSourceFormProps) { description: getValue('description'), type: dataSourceType, url: url, + previewUrl: getValue('previewUrl'), }; if (dataSourceType === 'http') { @@ -297,6 +298,15 @@ export function DataSourceForm(props: DataSourceFormProps) { )} )} + + )} + {props.children} diff --git a/packages/root-cms/ui/utils/data-source.ts b/packages/root-cms/ui/utils/data-source.ts index ee055bc2..e7e9ee0c 100644 --- a/packages/root-cms/ui/utils/data-source.ts +++ b/packages/root-cms/ui/utils/data-source.ts @@ -36,6 +36,7 @@ export interface DataSource { headers?: Record; body?: string; }; + previewUrl?: string; createdAt: Timestamp; createdBy: string; syncedAt?: Timestamp;