From 3101f4053b40d5004ecfa0c554d85de6b5d7c0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20Emir=20=C5=9Een?= Date: Fri, 26 Jul 2024 09:25:26 +0300 Subject: [PATCH] chore: migrate to appwrite cloud (#408) * chore(appwrite): migrate to cloud * test(e2e): enable appwrite tests * fix(refine-nextjs): fix category id form field text * chore(mui-example): update header name for content * chore(appwrite): update created at value key * ci: skip appwrite tests --- refine-nextjs/plugins/_base/extend.js | 4 ++- .../src/app/blog-posts/edit/[id]/page.tsx | 16 +++++++++++ .../antd-example/src/app/blog-posts/page.tsx | 8 ++++-- .../src/app/blog-posts/show/[id]/page.tsx | 10 +++++-- .../src/providers/data-provider/index.ts | 4 +-- .../src/utils/constants.ts | 4 +-- .../src/app/blog-posts/create/page.tsx | 4 +++ .../src/app/blog-posts/edit/[id]/page.tsx | 26 +++++++++++++++++ .../src/app/blog-posts/page.tsx | 10 ++++--- .../src/app/blog-posts/show/[id]/page.tsx | 8 ++++-- .../src/app/blog-posts/create/page.tsx | 7 +++++ .../src/app/blog-posts/edit/[id]/page.tsx | 25 +++++++++++++++++ .../mui-example/src/app/blog-posts/page.tsx | 12 ++++---- .../src/app/blog-posts/show/[id]/page.tsx | 19 +++++++------ refine-remix/plugins/_base/extend.js | 4 ++- .../app/routes/_layout.blog-posts._index.tsx | 6 ++-- .../routes/_layout.blog-posts.edit.$id.tsx | 16 +++++++++++ .../routes/_layout.blog-posts.show.$id.tsx | 12 ++++++-- .../app/utility/appwriteClient.ts | 4 +-- .../plugins/data-provider-appwrite/extend.js | 4 +-- .../app/routes/_layout.blog-posts._index.tsx | 10 ++++--- .../app/routes/_layout.blog-posts.create.tsx | 4 +++ .../routes/_layout.blog-posts.edit.$id.tsx | 26 +++++++++++++++++ .../routes/_layout.blog-posts.show.$id.tsx | 8 ++++-- .../app/routes/_layout.blog-posts._index.tsx | 10 ++++--- .../app/routes/_layout.blog-posts.create.tsx | 7 +++++ .../routes/_layout.blog-posts.edit.$id.tsx | 25 +++++++++++++++++ .../routes/_layout.blog-posts.show.$id.tsx | 21 ++++++++------ refine-vite/plugins/_base/extend.js | 4 ++- .../src/pages/blog-posts/edit.tsx | 25 ++++++++++++++++- .../src/pages/blog-posts/list.tsx | 6 ++-- .../src/pages/blog-posts/show.tsx | 10 +++++-- .../plugins/data-provider-appwrite/extend.js | 4 +-- .../src/utility/appwriteClient.ts | 4 +-- .../src/pages/blog-posts/create.tsx | 4 +++ .../src/pages/blog-posts/edit.tsx | 28 ++++++++++++++++++- .../src/pages/blog-posts/list.tsx | 4 ++- .../src/pages/blog-posts/show.tsx | 8 ++++-- .../src/pages/blog-posts/create.tsx | 7 +++++ .../mui-example/src/pages/blog-posts/edit.tsx | 25 +++++++++++++++++ .../mui-example/src/pages/blog-posts/list.tsx | 12 ++++---- .../mui-example/src/pages/blog-posts/show.tsx | 6 ++-- 42 files changed, 382 insertions(+), 79 deletions(-) diff --git a/refine-nextjs/plugins/_base/extend.js b/refine-nextjs/plugins/_base/extend.js index 1c6282bda..19ceda266 100644 --- a/refine-nextjs/plugins/_base/extend.js +++ b/refine-nextjs/plugins/_base/extend.js @@ -182,6 +182,8 @@ module.exports = { base.blogPostCategoryIdFormField = `"categoryId"`; } else if (dataProvider === "data-provider-supabase") { base.blogPostCategoryIdFormField = `"categoryId"`; + } else if (dataProvider === "data-provider-appwrite") { + base.blogPostCategoryIdFormField = `"category"`; } else { if (uiFramework === "mui" || isHeadless) { base.blogPostCategoryIdFormField = `"category.id"`; @@ -191,7 +193,7 @@ module.exports = { } // ## blogPostCategoryTableField - if (base.isGraphQL) { + if (base.isGraphQL || dataProvider === "data-provider-appwrite") { if (isHeadless) { base.blogPostCategoryTableField = `"category.title"`; } diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx index 9e9ffbff1..7034cf2b7 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/edit/[id]/page.tsx @@ -31,6 +31,18 @@ export default function BlogPostEdit() { meta: { select: '*, categories(id,title)', }, +<%_ } _%> +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + queryOptions: { + select: ({ data }) => { + return { + data: { + ...data, + category: data.category.$id, + }, + }; + }, + }, <%_ } _%> }); @@ -38,7 +50,11 @@ export default function BlogPostEdit() { const { selectProps: categorySelectProps } = useSelect({ resource: "categories", +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + defaultValue: blogPostsData?.<%- blogPostCategoryFieldName %>, +<%_ } else { _%> defaultValue: blogPostsData?.<%- blogPostCategoryFieldName %>?.id, +<%_ } _%> <%_ if (answers["data-provider"] === "data-provider-hasura") { _%> meta: { fields: BLOG_POSTS_CATEGORIES_SELECT_QUERY, diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx index c0e1e35ef..a04124e6d 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/page.tsx @@ -45,7 +45,7 @@ export default function BlogPostList() { <%_ } _%> }); -<%_ if (!isGraphQL) { _%> +<%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> const { data: categoryData, isLoading: categoryIsLoading } = useMany({ resource: "categories", ids: tableProps?.dataSource?.map((item) => item?.<%- blogPostCategoryFieldName %>?.id).filter(Boolean) ?? [], @@ -71,7 +71,7 @@ export default function BlogPostList() { } title={"Category"} - <%_ if (!isGraphQL) { _%> + <%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> render={(value) => categoryIsLoading ? ( <>Loading... @@ -86,7 +86,9 @@ export default function BlogPostList() { - dataIndex={["created_at"]} + dataIndex={["created_at"]} +<%_ } else if (answers["data-provider"] === "data-provider-appwrite") { _%> + dataIndex={["$createdAt"]} <%_ } else { _%> dataIndex={["createdAt"]} <%_ } _%> diff --git a/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx b/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx index a26fdad80..cca792751 100644 --- a/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx +++ b/refine-nextjs/plugins/antd-example/src/app/blog-posts/show/[id]/page.tsx @@ -46,7 +46,7 @@ export default function BlogPostShow() { const record = data?.data; -<%_ if (!isGraphQL) { _%> +<%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%> const { data: categoryData, isLoading: categoryIsLoading } = useOne({ resource: "categories", id: record?.<%- blogPostCategoryFieldName %>?.id || "", @@ -65,7 +65,7 @@ export default function BlogPostShow() { {"Content"} {"Category"} -<%_ if (isGraphQL) { _%> +<%_ if (isGraphQL || answers["data-provider"] === "data-provider-appwrite") { _%> ?.title} /> <%_ } else { _%> {"Status"} {"CreatedAt"} +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + +<%_ } else if (answers["data-provider"] === "data-provider-hasura") { _%> + +<%_ } else { _%> +<%_ } _%> ); }; diff --git a/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts b/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts index 7d9aaf090..82a3bc4ee 100644 --- a/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts +++ b/refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts @@ -4,9 +4,9 @@ import { dataProvider, liveProvider } from "@refinedev/appwrite"; import { appwriteClient } from "@utils/appwrite/client"; export const appwriteDataProvider = dataProvider(appwriteClient, { - databaseId: "database", + databaseId: "default", }); export const appwriteLiveProvider = liveProvider(appwriteClient, { - databaseId: "database", + databaseId: "default", }); diff --git a/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts b/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts index 8be31586b..b376660d5 100644 --- a/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts +++ b/refine-nextjs/plugins/data-provider-appwrite/src/utils/constants.ts @@ -1,3 +1,3 @@ -export const APPWRITE_URL = "https://refine.appwrite.org/v1"; -export const APPWRITE_PROJECT = "61c4368b4e349"; +export const APPWRITE_URL = "https://cloud.appwrite.io/v1"; +export const APPWRITE_PROJECT = "6697687d002cbd31ba6b"; export const APPWRITE_JWT_KEY = "appwrite-jwt"; diff --git a/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx b/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx index 805ef3a1a..8356533fa 100644 --- a/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx +++ b/refine-nextjs/plugins/headless-example/src/app/blog-posts/create/page.tsx @@ -111,7 +111,11 @@ export default function BlogPostCreate() { ))} +<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%> + {(errors as any)?.<%- blogPostCategoryFieldName %>?.message as string} +<%_ } else { _%> {(errors as any)?.<%- blogPostCategoryFieldName %>?.id?.message as string} +<%_ } _%>