Skip to content

Commit

Permalink
Merge branch 'master' into chore/update-auth-login-method
Browse files Browse the repository at this point in the history
  • Loading branch information
aliemir committed Aug 6, 2024
2 parents 1ffc7d5 + 4b9b713 commit 30b21ea
Show file tree
Hide file tree
Showing 208 changed files with 255 additions and 7,592 deletions.
58 changes: 0 additions & 58 deletions .github/workflows/test-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,61 +119,3 @@ jobs:
CYPRESS_DATA_PROVIDER: ${{ matrix.data_provider }}
CYPRESS_UI_FRAMEWORK: ${{ matrix.ui_framework }}
CYPRESS_AUTH_PROVIDER: ${{ steps.build_step.outputs.auth_provider }}
remix:
runs-on: ubuntu-latest
name: remix
concurrency:
group: ${{ github.ref }}-e2e-local-remix-${{ matrix.data_provider }}-${{ matrix.ui_framework }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
data_provider:
[
custom-json-rest,
strapi-v4,
nestjsx-crud,
airtable,
supabase,
appwrite,
hasura,
]
ui_framework: [tailwindcss, antd, mui, no]
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install
run: npm install
- name: Build Examples
id: build_step
run: node ./.github/workflows/build-template.js
env:
FRAMEWORK: remix
DATA_PROVIDER: ${{ matrix.data_provider }}
UI_FRAMEWORK: ${{ matrix.ui_framework }}
- name: Install Deps
run: |
cd ${{ steps.build_step.outputs.project_path }}
npm install
npm run build
HOST=0.0.0.0 npm run start &
- name: Run Cypress on local
uses: cypress-io/github-action@v6
with:
install: false
record: true
start: "npm ls"
wait-on: "http://0.0.0.0:3000"
group: e2e-local-remix-${{ matrix.data_provider }}-${{ matrix.ui_framework }}-${{ steps.build_step.outputs.auth_provider }}
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_USER_AGENT: ${{ secrets.CI_USER_AGENT }}
CYPRESS_FRAMEWORK: remix
CYPRESS_DATA_PROVIDER: ${{ matrix.data_provider }}
CYPRESS_UI_FRAMEWORK: ${{ matrix.ui_framework }}
CYPRESS_AUTH_PROVIDER: ${{ steps.build_step.outputs.auth_provider }}
58 changes: 0 additions & 58 deletions .github/workflows/test-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,3 @@ jobs:
CYPRESS_DATA_PROVIDER: ${{ matrix.data_provider }}
CYPRESS_UI_FRAMEWORK: ${{ matrix.ui_framework }}
CYPRESS_AUTH_PROVIDER: ${{ steps.download_step.outputs.auth_provider }}
refine-remix:
runs-on: ubuntu-latest
name: Remix
concurrency:
group: ${{ github.ref }}-e2e-remote-remix-${{ matrix.data_provider }}-${{ matrix.ui_framework }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
data_provider:
[
custom-json-rest,
strapi-v4,
nestjsx-crud,
airtable,
supabase,
appwrite,
hasura,
]
ui_framework: [tailwindcss, antd, mui, no]
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install
run: npm install
- name: Download Example
id: download_step
run: node ./.github/workflows/build-remote.js
env:
FRAMEWORK: remix
CI_USER_AGENT: ${{ secrets.CI_USER_AGENT }}
DATA_PROVIDER: ${{ matrix.data_provider }}
UI_FRAMEWORK: ${{ matrix.ui_framework }}
- name: Install & Build Deps
run: |
cd ${{ steps.download_step.outputs.project_path }}
npm install
npm run build
HOST=0.0.0.0 npm run start &
- name: Run Cypress on local
uses: cypress-io/github-action@v6
with:
install: false
record: true
start: "npm ls"
wait-on: "http://localhost:3000"
group: e2e-remote-remix-${{ matrix.data_provider }}-${{ matrix.ui_framework }}-${{ steps.download_step.outputs.auth_provider }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_USER_AGENT: ${{ secrets.CI_USER_AGENT }}
CYPRESS_FRAMEWORK: remix
CYPRESS_DATA_PROVIDER: ${{ matrix.data_provider }}
CYPRESS_UI_FRAMEWORK: ${{ matrix.ui_framework }}
CYPRESS_AUTH_PROVIDER: ${{ steps.download_step.outputs.auth_provider }}
16 changes: 2 additions & 14 deletions cypress/e2e/build-test.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ const shouldSkip = () => {
return true;
}

if (
Cypress.env("FRAMEWORK") === "remix" &&
Cypress.env("UI_FRAMEWORK") === "antd"
) {
cy.log("Remix with Antd has known issues, skipping.");

return true;
}

return false;
};

Expand Down Expand Up @@ -120,11 +111,8 @@ describe("build test", () => {
cy.contains("Blog Posts", { matchCase: false }).should("exist");

// document title check
// ignore remix and nextjs
if (
Cypress.env("FRAMEWORK") !== "remix" &&
Cypress.env("FRAMEWORK") !== "nextjs"
) {
// ignore nextjs
if (Cypress.env("FRAMEWORK") !== "nextjs") {
cy.title().should("eq", "Blog posts | Refine");
}

Expand Down
24 changes: 0 additions & 24 deletions presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ module.exports = {
"headless-example": "no",
},
},
{
name: "refine-headless-remix",
type: "refine-remix",
answers: {
"ui-framework": "no",
"data-provider": "data-provider-custom-json-rest",
"auth-provider": "none",
"antd-example": "no",
"mui-example": "no",
"headless-example": "no",
},
},
{
name: "refine-antd-nextjs",
type: "refine-nextjs",
Expand Down Expand Up @@ -124,17 +112,5 @@ module.exports = {
"headless-example": "no",
},
},
{
name: "remix-tailwindcss",
type: "refine-remix",
answers: {
"ui-framework": "tailwindcss",
"data-provider": "data-provider-custom-json-rest",
"auth-provider": "none",
"antd-example": "no",
"mui-example": "no",
"headless-example": "no",
},
},
],
};
4 changes: 3 additions & 1 deletion refine-nextjs/plugins/_base/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;
Expand All @@ -191,7 +193,7 @@ module.exports = {
}

// ## blogPostCategoryTableField
if (base.isGraphQL) {
if (base.isGraphQL || dataProvider === "data-provider-appwrite") {
if (isHeadless) {
base.blogPostCategoryTableField = `"category.title"`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ 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,
},
};
},
},
<%_ } _%>
});

const blogPostsData = queryResult?.data?.data;

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?? [],
Expand All @@ -71,7 +71,7 @@ export default function BlogPostList() {
<Table.Column
dataIndex={<%- blogPostCategoryTableField %>}
title={"Category"}
<%_ if (!isGraphQL) { _%>
<%_ if (!isGraphQL && answers["data-provider"] !== "data-provider-appwrite") { _%>
render={(value) =>
categoryIsLoading ? (
<>Loading...</>
Expand All @@ -86,7 +86,9 @@ export default function BlogPostList() {
<Table.Column dataIndex="status" title={"Status"} />
<Table.Column
<%_ if (answers["data-provider"] === "data-provider-hasura") { _%>
dataIndex={["created_at"]}
dataIndex={["created_at"]}
<%_ } else if (answers["data-provider"] === "data-provider-appwrite") { _%>
dataIndex={["$createdAt"]}
<%_ } else { _%>
dataIndex={["createdAt"]}
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 || "",
Expand All @@ -65,7 +65,7 @@ export default function BlogPostShow() {
<Title level={5}>{"Content"}</Title>
<MarkdownField value={record?.content} />
<Title level={5}>{"Category"}</Title>
<%_ if (isGraphQL) { _%>
<%_ if (isGraphQL || answers["data-provider"] === "data-provider-appwrite") { _%>
<TextField value={record?.<%- blogPostCategoryFieldName %>?.title} />
<%_ } else { _%>
<TextField value={categoryIsLoading ? (
Expand All @@ -77,7 +77,13 @@ export default function BlogPostShow() {
<Title level={5}>{"Status"}</Title>
<TextField value={record?.status} />
<Title level={5}>{"CreatedAt"}</Title>
<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%>
<DateField value={record?.$createdAt} />
<%_ } else if (answers["data-provider"] === "data-provider-hasura") { _%>
<DateField value={record?.created_at} />
<%_ } else { _%>
<DateField value={record?.createdAt} />
<%_ } _%>
</Show>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export default function BlogPostCreate() {
))}
</select>
<span style={{ color: "red" }}>
<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%>
{(errors as any)?.<%- blogPostCategoryFieldName %>?.message as string}
<%_ } else { _%>
{(errors as any)?.<%- blogPostCategoryFieldName %>?.id?.message as string}
<%_ } _%>
</span>
</label>
<label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,32 @@ export default function BlogPostCreate() {
select: '*, categories(id,title)',
},
},
<%_ } _%>
<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%>
refineCoreProps: {
queryOptions: {
select: ({ data }) => {
return {
data: {
...data,
category: data.category.$id,
},
};
},
},
},
<%_ } _%>
});

const blogPostsData = queryResult?.data?.data;

const { options: categoryOptions } = 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,
Expand All @@ -69,7 +87,11 @@ export default function BlogPostCreate() {
});

React.useEffect(() => {
<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%>
setValue(<%- blogPostCategoryIdFormField %>, blogPostsData?.<%- blogPostCategoryFieldName %>);
<%_ } else { _%>
setValue(<%- blogPostCategoryIdFormField %>, blogPostsData?.<%- blogPostCategoryFieldName %>?.id);
<%_ } _%>
}, [categoryOptions]);

return (
Expand Down Expand Up @@ -134,7 +156,11 @@ export default function BlogPostCreate() {
))}
</select>
<span style={{ color: "red" }}>
<%_ if (answers["data-provider"] === "data-provider-appwrite") { _%>
{(errors as any)?.<%- blogPostCategoryFieldName %>?.message as string}
<%_ } else { _%>
{(errors as any)?.<%- blogPostCategoryFieldName %>?.id?.message as string}
<%_ } _%>
</span>
</label>
<label>
Expand Down
Loading

0 comments on commit 30b21ea

Please sign in to comment.