diff --git a/README.md b/README.md index fa27628a76..7ed1e6ad4a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Magento PWA Studio is a collection of tools that lets developers build complex P ## Useful links -[PWA Studio documentation site][documentation site] - +[PWA Studio documentation site][documentation site] - The best place to start learning about the tools and the technologies that PWA Studio provides. Here, you can learn PWA Studio concepts, find API reference docs, and read tutorials on how to use PWA Studio to create your own PWA storefront. diff --git a/packages/graphql-cli-validate-magento-pwa-queries/lib/__tests__/index.spec.js b/packages/graphql-cli-validate-magento-pwa-queries/lib/__tests__/index.spec.js index 6b7c7b0f3d..42d6d51524 100644 --- a/packages/graphql-cli-validate-magento-pwa-queries/lib/__tests__/index.spec.js +++ b/packages/graphql-cli-validate-magento-pwa-queries/lib/__tests__/index.spec.js @@ -51,21 +51,23 @@ describe('handler', () => { const mockArgs = { project: 'myApp' }; - const mockContext = { - getProjectConfig: jest.fn(() => { - return Promise.resolve({ - config: { - extensions: { - 'validate-magento-pwa-queries': { - clients: ['apollo', 'literal'], - filesGlob: '*.graphql', - ignore: ['*.js'] - } - }, - schemaPath: 'unit test' + const getProjectConfig = jest.fn().mockResolvedValue({ + config: { + extensions: { + 'validate-magento-pwa-queries': { + clients: ['apollo', 'literal'], + filesGlob: '*.graphql', + ignore: ['*.js'], + magentoBackendEdition: 'CE', + ceFilesGlob: 'ceFilesGlob', + eeFilesGlob: 'eeFilesGlob' } - }); - }), + }, + schemaPath: 'unit test' + } + }); + const mockContext = { + getProjectConfig, spinner: { fail: jest.fn(), start: jest.fn(), @@ -227,4 +229,32 @@ describe('handler', () => { expect(mockConsoleWarn).toHaveBeenCalled(); expect(mockProcessExit).toHaveBeenCalledWith(1); }); + + test('it ignores EE files if magentoBackendEdition is CE', async () => { + await plugin.handler(mockContext, mockArgs); + + expect(globSyncSpy.mock.calls[0][1].ignore).toContain('eeFilesGlob'); + }); + + test('it ignores CE files if magentoBackendEdition is EE', async () => { + getProjectConfig.mockResolvedValueOnce({ + config: { + extensions: { + 'validate-magento-pwa-queries': { + clients: ['apollo', 'literal'], + filesGlob: '*.graphql', + ignore: ['*.js'], + magentoBackendEdition: 'EE', + ceFilesGlob: 'ceFilesGlob', + eeFilesGlob: 'eeFilesGlob' + } + }, + schemaPath: 'unit test' + } + }); + + await plugin.handler(mockContext, mockArgs); + + expect(globSyncSpy.mock.calls[0][1].ignore).toContain('ceFilesGlob'); + }); }); diff --git a/packages/graphql-cli-validate-magento-pwa-queries/lib/index.js b/packages/graphql-cli-validate-magento-pwa-queries/lib/index.js index dc53b8b6ec..68763b883e 100644 --- a/packages/graphql-cli-validate-magento-pwa-queries/lib/index.js +++ b/packages/graphql-cli-validate-magento-pwa-queries/lib/index.js @@ -52,7 +52,20 @@ async function validateQueries(context, argv) { // Get the clients and filesGlob arguments from the .graphqlconfig. const configArgs = extensions[plugin.COMMAND]; - const { clients, filesGlob, ignore } = configArgs; + const { + magentoBackendEdition, + clients, + filesGlob, + ceFilesGlob, + eeFilesGlob, + ignore + } = configArgs; + + if (magentoBackendEdition === 'CE') { + ignore.push(eeFilesGlob); + } else { + ignore.push(ceFilesGlob); + } /** * List of files to run query validation on ignoring diff --git a/packages/peregrine/lib/talons/CartPage/GiftCards/useGiftCards.js b/packages/peregrine/lib/talons/CartPage/GiftCards/useGiftCards.js index 67fd26a883..ea6f6c3745 100644 --- a/packages/peregrine/lib/talons/CartPage/GiftCards/useGiftCards.js +++ b/packages/peregrine/lib/talons/CartPage/GiftCards/useGiftCards.js @@ -180,7 +180,7 @@ export const useGiftCards = props => { * @property {GraphQLAST} applyCardMutation The mutation used to apply a gift card to the cart. * @property {GraphQLAST} removeCardMutation The mutation used to remove a gift card from the cart. * - * @see [`giftCardQueries.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js} + * @see [`giftCardQueries.ee.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js} * for queries used in Venia */ @@ -192,7 +192,7 @@ export const useGiftCards = props => { * @property {GraphQLAST} appliedCardsQuery The query used to get the gift cards currently applied to the cart. * @property {GraphQLAST} cardBalanceQuery The query used to get the gift cards currently applied to the cart. * - * @see [`giftCardQueries.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js} + * @see [`giftCardQueries.ee.js`]{@link https://github.com/magento/pwa-studio/blob/develop/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js} * for queries used in Venia */ diff --git a/packages/peregrine/lib/talons/Gallery/__tests__/useGalleryItem.spec.js b/packages/peregrine/lib/talons/Gallery/__tests__/useGalleryItem.spec.js new file mode 100644 index 0000000000..fe2f2686ff --- /dev/null +++ b/packages/peregrine/lib/talons/Gallery/__tests__/useGalleryItem.spec.js @@ -0,0 +1,5 @@ +import { useGalleryItem } from '../useGalleryItem'; +test('returns empty object', () => { + const props = useGalleryItem({}); + expect(props).toEqual({}); +}); diff --git a/packages/peregrine/lib/talons/Gallery/useGalleryItem.js b/packages/peregrine/lib/talons/Gallery/useGalleryItem.js new file mode 100644 index 0000000000..4c45e89d27 --- /dev/null +++ b/packages/peregrine/lib/talons/Gallery/useGalleryItem.js @@ -0,0 +1,3 @@ +export const useGalleryItem = props => { + return { ...props }; +}; diff --git a/packages/peregrine/lib/targets/__tests__/peregrine-targets.spec.js b/packages/peregrine/lib/targets/__tests__/peregrine-targets.spec.js index 980fe9b7b8..9fb87bf058 100644 --- a/packages/peregrine/lib/targets/__tests__/peregrine-targets.spec.js +++ b/packages/peregrine/lib/targets/__tests__/peregrine-targets.spec.js @@ -147,6 +147,7 @@ test('exposes all hooks and targets', async () => { talons.Footer.useFooter.wrapWith() wraps export "useFooter" from "Footer/useFooter.js" talons.ForgotPassword.useForgotPassword.wrapWith() wraps export "useForgotPassword" from "ForgotPassword/useForgotPassword.js" talons.FormError.useFormError.wrapWith() wraps export "useFormError" from "FormError/useFormError.js" + talons.Gallery.useGalleryItem.wrapWith() wraps export "useGalleryItem" from "Gallery/useGalleryItem.js" talons.Header.useAccountMenu.wrapWith() wraps export "useAccountMenu" from "Header/useAccountMenu.js" talons.Header.useAccountTrigger.wrapWith() wraps export "useAccountTrigger" from "Header/useAccountTrigger.js" talons.Header.useCartTrigger.wrapWith() wraps export "useCartTrigger" from "Header/useCartTrigger.js" diff --git a/packages/venia-concept/.graphqlconfig b/packages/venia-concept/.graphqlconfig index 70f3c3b494..ae33c06d18 100644 --- a/packages/venia-concept/.graphqlconfig +++ b/packages/venia-concept/.graphqlconfig @@ -11,7 +11,10 @@ "apollo", "literal" ], + "magentoBackendEdition": "${env:MAGENTO_BACKEND_EDITION}", "filesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.{js,graphql,gql}", + "ceFilesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.ce.js", + "eeFilesGlob": "../{peregrine,venia-ui,venia-concept}/{lib,src}/**/*.ee.js", "ignore": [ "../venia-ui/lib/**/giftOptions.js", "../venia-ui/lib/**/wishlistPage.gql.js", diff --git a/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js b/packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.ee.js similarity index 100% rename from packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.js rename to packages/venia-ui/lib/components/CartPage/GiftCards/giftCardQueries.ee.js diff --git a/packages/venia-ui/lib/components/Gallery/item.js b/packages/venia-ui/lib/components/Gallery/item.js index 8758911d66..3b11e3fa09 100644 --- a/packages/venia-ui/lib/components/Gallery/item.js +++ b/packages/venia-ui/lib/components/Gallery/item.js @@ -4,6 +4,7 @@ import { Link, resourceUrl } from '@magento/venia-drivers'; import Price from '@magento/venia-ui/lib/components/Price'; import { transparentPlaceholder } from '@magento/peregrine/lib/util/images'; import { UNCONSTRAINED_SIZE_KEY } from '@magento/peregrine/lib/talons/Image/useImage'; +import { useGalleryItem } from '@magento/peregrine/lib/talons/Gallery/useGalleryItem'; import { mergeClasses } from '../../classify'; import Image from '../Image'; @@ -37,7 +38,7 @@ const ItemPlaceholder = ({ classes }) => ( ); const GalleryItem = props => { - const { item } = props; + const { handleLinkClick, item } = useGalleryItem(props); const classes = mergeClasses(defaultClasses, props.classes); @@ -50,7 +51,11 @@ const GalleryItem = props => { return (