Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Draykee committed Nov 14, 2024
2 parents 2bdb21c + 7324bb3 commit 1fba181
Show file tree
Hide file tree
Showing 19 changed files with 337 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A component for selecting product variants via an autocomplete-style select inpu

```HTML
<vdr-product-variant-selector
(productSelected)="selectResult($event)"></vdr-product-selector>
(productSelected)="selectResult($event)"></vdr-product-variant-selector>
```

```ts title="Signature"
Expand Down
48 changes: 48 additions & 0 deletions license/signatures/version1/cla.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,54 @@
"created_at": "2024-10-20T22:01:36Z",
"repoId": 136938012,
"pullRequestNo": 3151
},
{
"name": "twlite",
"id": 46562212,
"comment_id": 2441869361,
"created_at": "2024-10-28T15:12:26Z",
"repoId": 136938012,
"pullRequestNo": 3171
},
{
"name": "alexisvigoureux",
"id": 6134849,
"comment_id": 2444508370,
"created_at": "2024-10-29T14:55:39Z",
"repoId": 136938012,
"pullRequestNo": 3172
},
{
"name": "HausTechTeam",
"id": 157805863,
"comment_id": 2449329824,
"created_at": "2024-10-31T08:42:52Z",
"repoId": 136938012,
"pullRequestNo": 3174
},
{
"name": "kkerti",
"id": 47832952,
"comment_id": 2458191015,
"created_at": "2024-11-05T21:33:05Z",
"repoId": 136938012,
"pullRequestNo": 3187
},
{
"name": "shingoaoyama1",
"id": 17615101,
"comment_id": 2459213307,
"created_at": "2024-11-06T10:15:37Z",
"repoId": 136938012,
"pullRequestNo": 3192
},
{
"name": "agoransson",
"id": 487002,
"comment_id": 2466157456,
"created_at": "2024-11-09T10:08:00Z",
"repoId": 136938012,
"pullRequestNo": 3205
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export class ProductVariantQuickJumpComponent implements OnInit {
@Input() productId: string;
selectedVariantId: string | undefined;
variants$: Observable<NonNullable<GetProductVariantsQuickJumpQuery['product']>['variants']>;
constructor(private dataService: DataService, private router: Router) {}
constructor(
private dataService: DataService,
private router: Router,
) {}

ngOnInit() {
this.variants$ = this.dataService
.query(GetProductVariantsQuickJumpDocument, {
id: this.productId,
})
.mapSingle(data => data.product?.variants ?? []);
.mapStream(data => data.product?.variants ?? []);
}

searchFn = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
margin: 0 3px;
font-size: 12px;
line-height: 0.8rem;
color: var(--color-text-100);
}

vdr-select-toggle {
Expand Down Expand Up @@ -63,6 +64,7 @@ vdr-select-toggle {
overflow-y: auto;
.item-row {
padding-inline-start: 3px;
color: var(--color-text-100);
&:hover {
background-color: var(--color-component-bg-200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DataService } from '../../../data/providers/data.service';
* @example
* ```HTML
* <vdr-product-variant-selector
* (productSelected)="selectResult($event)"></vdr-product-selector>
* (productSelected)="selectResult($event)"></vdr-product-variant-selector>
* ```
*
* @docsCategory components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ export class DynamicFormInputComponent
if (this.listItems) {
for (const item of this.listItems) {
if (item.componentRef) {
const { value } = item.control;
const { type } = item.componentRef.instance.config || {};
// fix a bug where the list item of string turns into number which lead to unexpected behavior
if (typeof value === 'number' && type === 'string') {
item.control.setValue(item.control.value.toString(), { emitEvent: false });
}
this.updateBindings(changes, item.componentRef);
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/admin-ui/src/lib/order/src/order.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const createRoutes = (pageService: PageService): Route[] => [
{
path: '',
component: PageComponent,
pathMatch: 'full',
data: {
locationId: 'order-list',
breadcrumb: _('breadcrumb.orders'),
Expand Down
24 changes: 12 additions & 12 deletions packages/admin-ui/src/lib/static/i18n-messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"administrators": "Administratörer",
"assets": "Filer",
"channels": "Kanaler",
"collections": "Kategorier",
"collections": "Samlingar",
"countries": "Länder",
"customer-groups": "Kundgrupper",
"customers": "Kunder",
Expand Down Expand Up @@ -76,9 +76,9 @@
"calculated-price-tooltip": "Det finns en anpassad prisberäkning konfigurerad som ändrar priset ovan:",
"cannot-create-variants-without-options": "Produktvarianter kan inte läggas till förrän en alternativgrupp med minst två produktalternativ har definierats",
"channel-price-preview": "Förhandsgranskning av kanalpris",
"collection": "Kategorier",
"collection-contents": "Innehåll i kategorin",
"collections": "Kategorier",
"collection": "Samling",
"collection-contents": "Innehåll i samlingen",
"collections": "Samlingar",
"confirm-bulk-delete-products": "Vill du radera {count} produkter?",
"confirm-cancel": "Avbryt?",
"confirm-delete-assets": "Radera {count} {count, plural, one {fil} other {filer}}?",
Expand All @@ -91,7 +91,7 @@
"confirm-deletion-of-unused-variants-body": "Följande produktvarianter har blivit överflödiga på grund av tillägg av nya alternativ. De kommer att raderas vid skapandet av nya produktvarianter.",
"confirm-deletion-of-unused-variants-title": "Radera överflödiga produktvarianter?",
"create-draft-order": "Lägg till utkast till order",
"create-new-collection": "Lägg till ny kategori",
"create-new-collection": "Lägg till ny samling",
"create-new-facet": "Lägg till ny etikett",
"create-new-product": "Lägg till ny produkt",
"create-new-stock-location": "Lägg till lagerplats",
Expand All @@ -117,8 +117,8 @@
"live-preview-contents": "Förhandsgranska innehåll",
"manage-variants": "Hantera varianter",
"move-collection-to": "Flytta till { name }",
"move-collections": "Flytta kategorier",
"move-collections-success": "Flyttade {count, plural, one {1 kategori} other {{count} kategorier}}",
"move-collections": "Flytta samlingar",
"move-collections-success": "Flyttade {count, plural, one {1 samling} other {{count} samlingar}}",
"move-down": "Flytta nedåt",
"move-to": "Flytta till",
"move-up": "Flytta uppåt",
Expand Down Expand Up @@ -163,7 +163,7 @@
"remove-option": "Ta bort alternativ",
"remove-product-from-channel": "Ta bort produkt från kanal",
"remove-product-variant-from-channel": "Ta bort produktvariant från kanal",
"reorder-collection": "Ordna om kategorier",
"reorder-collection": "Ordna om samlingar",
"root-collection": "Rotkatalog",
"run-pending-search-index-updates": "Sökindex: kör {count, plural, one {1 avvaktande uppdatering} other {{count} avvaktande uppdateringar}}",
"running-search-index-updates": "Kör {count, plural, one {1 uppdatering} other {{count} uppdateringar}} till sökindex",
Expand Down Expand Up @@ -282,10 +282,10 @@
"notify-assign-to-channel-success-with-count": "Lyckades tilldela {count, plural, one {1 objekt} other {{count} objekt}} till { channelCode }",
"notify-bulk-update-success": "Uppdaterade { count } { entity }",
"notify-create-error": "Ett fel uppstod, kunde inte lägga till { entity }",
"notify-create-success": "La till nytt { entity }",
"notify-create-success": "Ny { entity } tillagd",
"notify-delete-error": "Ett fel uppstod, kunde inte radera { entity }",
"notify-delete-error-with-count": "Kunde inte radera {count, plural, one {1 objekt} other {{count} objekt}}",
"notify-delete-success": "Raderade { entity }",
"notify-delete-success": "{ entity } borttagen",
"notify-delete-success-with-count": "Lyckades radera {count, plural, one {1 objekt} other {{count} objekt}}",
"notify-duplicate-error": "Kunde inte duplicera { name } på grund av ett fel: { error }",
"notify-duplicate-error-excess": "Ytterligare { count } {count, plural, one {objekt} other {objekt}} kunde inte dupliceras på grund av fel",
Expand Down Expand Up @@ -513,10 +513,10 @@
},
"nav": {
"administrators": "Administratörer",
"assets": "ar",
"assets": "Filer",
"catalog": "Katalog",
"channels": "Kanaler",
"collections": "Kategorier",
"collections": "Samlingar",
"countries": "Länder",
"customer-groups": "Kundgrupper",
"customers": "Kunder",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ scalar JSON
scalar DateTime"
`;

exports[`addGraphQLCustomFields() > uses JSON scalar in UpdateActiveAdministratorInput if only internal custom fields defined on Administrator 1`] = `
"scalar JSON
input UpdateActiveAdministratorInput {
placeholder: String
customFields: JSON
}"
`;

exports[`addOrderLineCustomFieldsInput() > Modifies the schema when the addItemToOrder & adjustOrderLine mutation is present 1`] = `
"type Mutation {
addItemToOrder(id: ID!, quantity: Int!, customFields: OrderLineCustomFieldsInput = null): Boolean
Expand Down
24 changes: 24 additions & 0 deletions packages/core/src/api/config/graphql-custom-fields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { describe, expect, it } from 'vitest';
import { CustomFieldConfig, CustomFields } from '../../config/custom-field/custom-field-types';

import {
addActiveAdministratorCustomFields,
addGraphQLCustomFields,
addOrderLineCustomFieldsInput,
addRegisterCustomerCustomFieldsInput,
Expand All @@ -23,6 +24,29 @@ describe('addGraphQLCustomFields()', () => {
expect(printSchema(result)).toMatchSnapshot();
});

// regression test for
// https://github.com/vendure-ecommerce/vendure/issues/3158
it('uses JSON scalar in UpdateActiveAdministratorInput if only internal custom fields defined on Administrator', () => {
// custom field that is internal but not readonly - should not cause
// `addActiveAdministratorCustomFields` to assume that
// `UpdateAdministratorCustomFieldsInput` exists
const customFieldConfig: Required<Pick<CustomFields, 'Administrator'>> = {
Administrator: [{ name: 'testField', type: 'string', internal: true }],
};
// `addActiveAdministratorCustomFields` should add customFields to
// UpdateActiveAdministratorInput as a JSON scalar. need to provide
// those types for that to work
const input = `
scalar JSON
input UpdateActiveAdministratorInput {
placeholder: String
}
`;
const schema = addActiveAdministratorCustomFields(input, customFieldConfig.Administrator);
expect(printSchema(schema)).toMatchSnapshot();
});

it('extends a type', () => {
const input = `
type Product {
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/api/config/graphql-custom-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export function addServerConfigCustomFields(
const customFieldTypeDefs = `
"""
This type is deprecated in v2.2 in favor of the EntityCustomFields type,
which allows custom fields to be defined on user-supplies entities.
which allows custom fields to be defined on user-supplied entities.
"""
type CustomFields {
${Object.keys(customFieldConfig).reduce(
Expand Down Expand Up @@ -288,7 +288,9 @@ export function addActiveAdministratorCustomFields(
administratorCustomFields: CustomFieldConfig[],
) {
const schema = typeof typeDefsOrSchema === 'string' ? buildSchema(typeDefsOrSchema) : typeDefsOrSchema;
const writableCustomFields = administratorCustomFields?.filter(field => field.readonly !== true);
const writableCustomFields = administratorCustomFields?.filter(
field => field.readonly !== true && field.internal !== true,
);
const extension = `
extend input UpdateActiveAdministratorInput {
customFields: ${
Expand Down
22 changes: 10 additions & 12 deletions packages/core/src/api/schema/admin-api/order.api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ input CancelOrderInput {
}

input RefundOrderInput {
lines: [OrderLineInput!]!
shipping: Money!
adjustment: Money!
lines: [OrderLineInput!] @deprecated(reason: "Use the `amount` field instead")
shipping: Money @deprecated(reason: "Use the `amount` field instead")
adjustment: Money @deprecated(reason: "Use the `amount` field instead")
"""
If an amount is specified, this value will be used to create a Refund rather than calculating the
amount automatically. This was added in v2.2 and will be the preferred way to specify the refund
amount in the future. The `lines`, `shipping` and `adjustment` fields will likely be removed in a future
version.
The amount to be refunded to this particular payment. This was introduced in v2.2.0 as the preferred way to specify the refund amount.
Can be as much as the total amount of the payment minus the sum of all previous refunds.
"""
amount: Money
paymentId: ID!
Expand Down Expand Up @@ -410,28 +408,28 @@ type ManualPaymentStateError implements ErrorResult {

union TransitionOrderToStateResult = Order | OrderStateTransitionError
union SettlePaymentResult =
Payment
| Payment
| SettlePaymentError
| PaymentStateTransitionError
| OrderStateTransitionError
union CancelPaymentResult = Payment | CancelPaymentError | PaymentStateTransitionError
union AddFulfillmentToOrderResult =
Fulfillment
| Fulfillment
| EmptyOrderLineSelectionError
| ItemsAlreadyFulfilledError
| InsufficientStockOnHandError
| InvalidFulfillmentHandlerError
| FulfillmentStateTransitionError
| CreateFulfillmentError
union CancelOrderResult =
Order
| Order
| EmptyOrderLineSelectionError
| QuantityTooGreatError
| MultipleOrderError
| CancelActiveOrderError
| OrderStateTransitionError
union RefundOrderResult =
Refund
| Refund
| QuantityTooGreatError
| NothingToRefundError
| OrderStateTransitionError
Expand All @@ -445,7 +443,7 @@ union SettleRefundResult = Refund | RefundStateTransitionError
union TransitionFulfillmentToStateResult = Fulfillment | FulfillmentStateTransitionError
union TransitionPaymentToStateResult = Payment | PaymentStateTransitionError
union ModifyOrderResult =
Order
| Order
| NoChangesSpecifiedError
| OrderModificationStateError
| PaymentMethodMissingError
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export function assertFound<T>(promise: Promise<T | undefined | null>): Promise<
* Compare ID values for equality, taking into account the fact that they may not be of matching types
* (string or number).
*/
export function idsAreEqual(id1?: ID, id2?: ID): boolean {
if (id1 === undefined || id2 === undefined) {
export function idsAreEqual(id1?: ID | null, id2?: ID | null): boolean {
if (id1 == null || id2 == null) {
return false;
}
return id1.toString() === id2.toString();
Expand Down
9 changes: 5 additions & 4 deletions packages/payments-plugin/src/mollie/mollie.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ export class MollieService {
`Unable to find order ${mollieOrder.orderNumber}, unable to process Mollie order ${mollieOrder.id}`,
);
}
if (mollieOrder.status === OrderStatus.expired) {
// Expired is fine, a customer can retry the payment later
return;
}
if (order.orderPlacedAt) {
// Verify if the Vendure order isn't already paid for, and log if so
const paymentWithSameTransactionId = order.payments.find(
p => p.transactionId === mollieOrder.id && p.state === 'Settled',
);
Expand Down Expand Up @@ -293,10 +298,6 @@ export class MollieService {
return;
}
const amount = amountToCents(mollieOrder.amount);
if (mollieOrder.status === OrderStatus.expired) {
// Expired is fine, a customer can retry the payment later
return;
}
if (mollieOrder.status === OrderStatus.paid) {
// Paid is only used by 1-step payments without Authorized state. This will settle immediately
await this.addPayment(ctx, order, amount, mollieOrder, paymentMethod.code, 'Settled');
Expand Down
3 changes: 2 additions & 1 deletion packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"build": "tsc -p ./tsconfig.build.json",
"watch": "tsc -p ./tsconfig.build.json -w",
"lint": "eslint --fix .",
"ci": "npm run build"
"ci": "npm run build",
"test": "vitest --config vitest.config.mts --run"
},
"bugs": {
"url": "https://github.com/vendure-ecommerce/vendure/issues"
Expand Down
Loading

0 comments on commit 1fba181

Please sign in to comment.