Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new model for Merchant Center CustomView entity #384

Merged
merged 11 commits into from
Oct 19, 2023
Merged

Conversation

CarlosCortizasCT
Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT commented Oct 2, 2023

This PR adds a new model for the CustomView new entity we're developing for the Merchant Center.

Also, I included another one (LocalizedField) in the commons package as I believe it can be used from other upcoming models.

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2023

🦋 Changeset detected

Latest commit: 6055940

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@commercetools-test-data/custom-view Minor
@commercetools-test-data/commons Minor
@commercetools-test-data/business-unit Minor
@commercetools-test-data/cart-discount Minor
@commercetools-test-data/cart Minor
@commercetools-test-data/category Minor
@commercetools-test-data/channel Minor
@commercetools-test-data/customer-group Minor
@commercetools-test-data/customer Minor
@commercetools-test-data/discount-code Minor
@commercetools-test-data/inventory-entry Minor
@commercetools-test-data/order Minor
@commercetools-test-data/payment Minor
@commercetools-test-data/product-discount Minor
@commercetools-test-data/product-selection Minor
@commercetools-test-data/product-type Minor
@commercetools-test-data/product Minor
@commercetools-test-data/review Minor
@commercetools-test-data/shipping-method Minor
@commercetools-test-data/store Minor
@commercetools-test-data/tax-category Minor
@commercetools-test-data/zone Minor
@commercetools-test-data/core Minor
@commercetools-test-data/utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CarlosCortizasCT
Copy link
Contributor Author

Building is currently failing but I don't understand how I can fix it:

$ pp build

> preconstruct build

🎁 error @commercetools-test-data/custom-view packages must have at least one entrypoint, this package has no entrypoints
🎁 info If you want to learn more about the above error, check https://preconstruct.tools/errors
🎁 info If the error is not there and you want to learn more about it, open an issue at https://github.com/preconstruct/preconstruct/issues/new
 ELIFECYCLE  Command failed with exit code 1.

Comment on lines 17 to 20
labelAllLocales: [
LocalizedField.random().build(),
LocalizedField.random().build(),
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how should I implement these fields. I know we have the buildFields available in the transformers file, but I can't make it work.

Some help would be much appreciated.

@CarlosCortizasCT CarlosCortizasCT marked this pull request as ready for review October 13, 2023 11:28
@emmenko emmenko force-pushed the cm-custom-view-model branch from 80dff9c to 5fa3801 Compare October 18, 2023 10:21
@emmenko emmenko force-pushed the cm-custom-view-model branch from 5fa3801 to 7582606 Compare October 18, 2023 10:21
Comment on lines +10 to +13
const resourceAccesses = entryPointUriPathToResourceAccesses(
CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH,
[additionalPermission]
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ This requires the change in App Kit to be released: commercetools/merchant-center-application-kit#3272

Comment on lines +4 to +9
const generator = Generator<TCustomViewTypeSettingsForCustomPanel>({
fields: {
// Assumes that the type is `CustomPanel`.
size: fake((f) => f.helpers.arrayElement(['SMALL', 'LARGE'])),
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model is specific to CustomPanel type. When we support more types, we'll define separate models for each type settings.

This helps simplifying the setup and the usage (we already do this for other models as well).

@emmenko emmenko force-pushed the cm-custom-view-model branch from 795e06e to 39462a7 Compare October 18, 2023 10:35
ownerId: fake((f) => f.string.uuid()),
url: fake((f) => f.internet.url()),
defaultLabel: fake((f) => f.commerce.department()),
labelAllLocales: fake(() => [LocalizedField.random()]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrapping of fake() was missing, otherwise models cannot be built.

Copy link
Member

@emmenko emmenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@emmenko emmenko merged commit 677867c into main Oct 19, 2023
3 checks passed
@emmenko emmenko deleted the cm-custom-view-model branch October 19, 2023 07:49
@ct-changesets ct-changesets bot mentioned this pull request Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants