Przeglądaj źródła

Merge branch 'master' into minor

Michael Bromley 1 rok temu
rodzic
commit
ae88849f8c

+ 7 - 0
CHANGELOG.md

@@ -1,3 +1,10 @@
+## <small>3.0.3 (2024-09-11)</small>
+
+
+#### Fixes
+
+* **admin-ui** Display up to 3 decimal places in OrderSummary tax rate ([13a1b21](https://github.com/vendure-ecommerce/vendure/commit/13a1b21)), closes [#3051](https://github.com/vendure-ecommerce/vendure/issues/3051)
+* **core** Fix regression in correctly setting OrderLine.featuredAsset ([7d070f2](https://github.com/vendure-ecommerce/vendure/commit/7d070f2))
 
 ## <small>3.0.2 (2024-09-10)</small>
 

BIN
docs/docs/guides/deployment/deploy-to-digital-ocean-app-platform/05-open-server-settings.webp


BIN
docs/docs/guides/deployment/deploy-to-digital-ocean-app-platform/06-admin-app-route.webp


+ 0 - 0
docs/docs/guides/deployment/deploy-to-digital-ocean-app-platform/05-open-app.webp → docs/docs/guides/deployment/deploy-to-digital-ocean-app-platform/07-open-app.webp


+ 31 - 1
docs/docs/guides/deployment/deploy-to-digital-ocean-app-platform/index.md

@@ -187,6 +187,10 @@ The values starting with `${db...}` are automatically populated by App Platform
 to name your database something other than `db`.
 :::
 
+:::note
+When using the App Platform with a Dev Database, DigitalOcean only provides a self-signed SSL certificate. This may prevent the Vendure app from starting. As a workaround, you can add the environment variable `NODE_TLS_REJECT_UNAUTHORIZED` and set it to `0`.
+:::
+
 After saving your environment variables you can click through the confirmation screens to create the app.
 
 ## Create the worker resource
@@ -205,11 +209,37 @@ Again you can edit the plan, and the smallest Basic plan is fine for testing pur
 
 No new environment variables are needed since we'll be sharing the Global variables with the worker.
 
+## Enable access to the required routes
+
+To be able to access the UI and other routes, we need to declare them first.
+
+1. In the app dashboard, click on the **Settings** tab.
+2. Click on the **vendure-server** component.
+
+   ![Open server settings](./05-open-server-settings.webp)
+
+3. Scroll down to **HTTP Request Routes**.
+4. Click on **Edit**.
+5. Click on **+ Add new route** and fill in the form like this:
+
+   ![Admin app route](./06-admin-app-route.webp)
+
+6. Make sure to check the **Preserve Path Prefix** option.
+
+You need to do this for the following routes:
+- `/admin`
+- `/assets`
+- `/health`
+- `/admin-api`
+- `/shop-api`
+
+7. Click on **Save**.
+
 ## Test your Vendure server
 
 Once everything has finished deploying, you can click the app URL to open your Vendure server in a new tab. 
 
-![Open app](./05-open-app.webp)
+![Open app](./07-open-app.webp)
 
 :::info
 Append `/admin` to the URL to access the admin UI, and log in with the superadmin credentials you set in the environment variables.

+ 8 - 0
license/signatures/version1/cla.json

@@ -135,6 +135,14 @@
       "created_at": "2024-09-10T06:26:52Z",
       "repoId": 136938012,
       "pullRequestNo": 3052
+    },
+    {
+      "name": "lgoebkes",
+      "id": 63648932,
+      "comment_id": 2343353535,
+      "created_at": "2024-09-11T11:18:34Z",
+      "repoId": 136938012,
+      "pullRequestNo": 3060
     }
   ]
 }

+ 1 - 1
packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html

@@ -173,7 +173,7 @@
                 <tbody>
                     <tr *ngFor="let row of order.taxSummary">
                         <td>{{ row.description }}</td>
-                        <td>{{ row.taxRate / 100 | percent : '0.0-2' }}</td>
+                        <td>{{ row.taxRate / 100 | percent : '0.0-3' }}</td>
                         <td>{{ row.taxBase | localeCurrency : order.currencyCode }}</td>
                         <td>{{ row.taxTotal | localeCurrency : order.currencyCode }}</td>
                     </tr>

+ 1 - 1
packages/core/e2e/fixtures/e2e-products-full.csv

@@ -9,7 +9,7 @@ Gaming PC         ,gaming-pc         ,"This pc is optimised for gaming, and is a
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,R7-2700|240GB SSD,CGS480VR1064,1099.95,standard   ,100        ,false         ,             ,
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,i7-8700|120GB SSD,CGS480VR1065,931.20 ,standard   ,100        ,false         ,             ,
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,R7-2700|120GB SSD,CGS480VR1066,949.20 ,standard   ,100        ,false         ,             ,
-Hard Drive        ,hard-drive        ,"Boost your PC storage with this internal hard drive, designed just for desktop and all-in-one PCs."                                                                                                                                                                                                                                                                                                                                                                                         ,vincent-botta-736919-unsplash.jpg ,category:electronics|category:computers,HDD capacity   ,1TB              ,IHD455T1    ,37.99  ,standard   ,100        ,false         ,             ,
+Hard Drive        ,hard-drive        ,"Boost your PC storage with this internal hard drive, designed just for desktop and all-in-one PCs."                                                                                                                                                                                                                                                                                                                                                                                         ,vincent-botta-736919-unsplash.jpg ,category:electronics|category:computers,HDD capacity   ,1TB              ,IHD455T1    ,37.99  ,standard   ,100        ,false         ,florian-olivo-1166419-unsplash.jpg,
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,2TB              ,IHD455T2    ,53.74  ,standard   ,100        ,false         ,             ,
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,3TB              ,IHD455T3    ,78.96  ,standard   ,100        ,false         ,             ,
                   ,                  ,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ,                                  ,                                       ,               ,4TB              ,IHD455T4    ,92.99  ,standard   ,100        ,false         ,             ,

+ 19 - 0
packages/core/e2e/graphql/generated-e2e-shop-types.ts

@@ -3351,6 +3351,7 @@ export type UpdatedOrderFragment = {
         linePrice: number;
         linePriceWithTax: number;
         productVariant: { id: string };
+        featuredAsset?: { id: string } | null;
         discounts: Array<{
             adjustmentSource: string;
             amount: number;
@@ -3395,6 +3396,7 @@ export type AddItemToOrderMutation = {
                       linePrice: number;
                       linePriceWithTax: number;
                       productVariant: { id: string };
+                      featuredAsset?: { id: string } | null;
                       discounts: Array<{
                           adjustmentSource: string;
                           amount: number;
@@ -3429,6 +3431,7 @@ export type AddItemToOrderMutation = {
                   linePrice: number;
                   linePriceWithTax: number;
                   productVariant: { id: string };
+                  featuredAsset?: { id: string } | null;
                   discounts: Array<{
                       adjustmentSource: string;
                       amount: number;
@@ -4731,6 +4734,14 @@ export const UpdatedOrderFragmentDoc = {
                                 { kind: 'Field', name: { kind: 'Name', value: 'unitPriceWithTax' } },
                                 { kind: 'Field', name: { kind: 'Name', value: 'linePrice' } },
                                 { kind: 'Field', name: { kind: 'Name', value: 'linePriceWithTax' } },
+                                {
+                                    kind: 'Field',
+                                    name: { kind: 'Name', value: 'featuredAsset' },
+                                    selectionSet: {
+                                        kind: 'SelectionSet',
+                                        selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
+                                    },
+                                },
                                 {
                                     kind: 'Field',
                                     name: { kind: 'Name', value: 'discounts' },
@@ -5305,6 +5316,14 @@ export const AddItemToOrderDocument = {
                                 { kind: 'Field', name: { kind: 'Name', value: 'unitPriceWithTax' } },
                                 { kind: 'Field', name: { kind: 'Name', value: 'linePrice' } },
                                 { kind: 'Field', name: { kind: 'Name', value: 'linePriceWithTax' } },
+                                {
+                                    kind: 'Field',
+                                    name: { kind: 'Name', value: 'featuredAsset' },
+                                    selectionSet: {
+                                        kind: 'SelectionSet',
+                                        selections: [{ kind: 'Field', name: { kind: 'Name', value: 'id' } }],
+                                    },
+                                },
                                 {
                                     kind: 'Field',
                                     name: { kind: 'Name', value: 'discounts' },

+ 3 - 0
packages/core/e2e/graphql/shop-definitions.ts

@@ -87,6 +87,9 @@ export const UPDATED_ORDER_FRAGMENT = gql`
             unitPriceWithTax
             linePrice
             linePriceWithTax
+            featuredAsset {
+                id
+            }
             discounts {
                 adjustmentSource
                 amount

+ 54 - 0
packages/core/e2e/shop-order.e2e-spec.ts

@@ -8,6 +8,7 @@ import {
     mergeConfig,
 } from '@vendure/core';
 import { createErrorResultGuard, createTestEnvironment, ErrorResultGuard } from '@vendure/testing';
+import { fail } from 'assert';
 import gql from 'graphql-tag';
 import path from 'path';
 import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
@@ -44,6 +45,7 @@ import {
     GET_COUNTRY_LIST,
     GET_CUSTOMER,
     GET_CUSTOMER_LIST,
+    GET_PRODUCT_WITH_VARIANTS,
     GET_SHIPPING_METHOD_LIST,
     UPDATE_COUNTRY,
     UPDATE_PRODUCT,
@@ -1283,6 +1285,58 @@ describe('Shop orders', () => {
             expect(billingAddress.defaultBillingAddress).toBe(true);
             expect(billingAddress.defaultShippingAddress).toBe(false);
         });
+
+        it('sets OrderLine.featuredAsset to that of ProductVariant if defined', async () => {
+            const { product } = await adminClient.query<
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
+            >(GET_PRODUCT_WITH_VARIANTS, {
+                id: 'T_4',
+            });
+            const variantWithFeaturedAsset = product?.variants.find(v => !!v.featuredAsset);
+            if (!variantWithFeaturedAsset) {
+                fail(`Could not find expected variant with a featuredAsset`);
+                return;
+            }
+            const { addItemToOrder } = await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
+                productVariantId: variantWithFeaturedAsset.id,
+                quantity: 1,
+            });
+            orderResultGuard.assertSuccess(addItemToOrder);
+            expect(addItemToOrder.lines.length).toBe(1);
+            expect(addItemToOrder.lines[0].productVariant.id).toBe(variantWithFeaturedAsset?.id);
+            expect(addItemToOrder.lines[0].featuredAsset?.id).toBe(
+                variantWithFeaturedAsset.featuredAsset?.id,
+            );
+        });
+
+        it('sets OrderLine.featuredAsset to that of Product if ProductVariant has no featuredAsset', async () => {
+            const { product } = await adminClient.query<
+                Codegen.GetProductWithVariantsQuery,
+                Codegen.GetProductWithVariantsQueryVariables
+            >(GET_PRODUCT_WITH_VARIANTS, {
+                id: 'T_4',
+            });
+            const variantWithoutFeaturedAsset = product?.variants.find(v => !v.featuredAsset);
+            if (!variantWithoutFeaturedAsset) {
+                fail(`Could not find expected variant without a featuredAsset`);
+                return;
+            }
+            const { addItemToOrder } = await shopClient.query<
+                CodegenShop.AddItemToOrderMutation,
+                CodegenShop.AddItemToOrderMutationVariables
+            >(ADD_ITEM_TO_ORDER, {
+                productVariantId: variantWithoutFeaturedAsset.id,
+                quantity: 1,
+            });
+            orderResultGuard.assertSuccess(addItemToOrder);
+            expect(addItemToOrder.lines.length).toBe(2);
+            expect(addItemToOrder.lines[1].productVariant.id).toBe(variantWithoutFeaturedAsset?.id);
+            expect(addItemToOrder.lines[1].featuredAsset?.id).toBe(product?.featuredAsset?.id);
+        });
     });
 
     describe('ordering as authenticated user', () => {

+ 1 - 1
packages/core/src/service/helpers/order-modifier/order-modifier.ts

@@ -166,7 +166,7 @@ export class OrderModifier {
         }
 
         const productVariant = await this.getProductVariantOrThrow(ctx, productVariantId, order);
-        const featuredAssetId = productVariant.featuredAssetId ?? productVariant.featuredAssetId;
+        const featuredAssetId = productVariant.featuredAssetId ?? productVariant.product.featuredAssetId;
         const orderLine = await this.connection.getRepository(ctx, OrderLine).save(
             new OrderLine({
                 productVariant,