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

[BUGFIX] [ISSUE-88] Added support for latest 2.3-develop branch by so… #653

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
909 changes: 909 additions & 0 deletions packages/venia-concept/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const categoryQuery = gql`
items {
id
name
small_image
small_image {
url,
label
}
url_key
price {
regularPrice {
Expand Down
10 changes: 8 additions & 2 deletions packages/venia-concept/src/RootComponents/Product/Product.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const query = gql`
}
}
}
description
description {
html
}
media_gallery_entries {
label
position
Expand Down Expand Up @@ -101,7 +103,11 @@ class Product extends Component {
file: string.isRequired
})
),
description: string,
description: arrayOf(
shape({
html: string
})
),
short_description: string,
canonical_url: string
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ test('displays category tiles', async () => {
productImagePreview: {
items: [
{
small_image: 'media/foo-product.jpg'
small_image: {
url: 'media/foo-product.jpg'
}
}
]
}
Expand All @@ -76,7 +78,9 @@ test('displays category tiles', async () => {
productImagePreview: {
items: [
{
small_image: 'media/bar-product.jpg'
small_image: {
url: 'media/bar-product.jpg'
}
}
]
}
Expand Down
34 changes: 24 additions & 10 deletions packages/venia-concept/src/components/CategoryList/categoryTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { arrayOf, string, shape } from 'prop-types';
import { Link } from 'react-router-dom';

import classify from 'src/classify';
import {
makeCategoryMediaPath,
makeProductMediaPath
} from 'src/util/makeMediaPath';
import defaultClasses from './categoryTile.css';

// TODO: get categoryUrlSuffix from graphql storeOptions when it is ready
Expand All @@ -15,12 +11,21 @@ const categoryUrlSuffix = '.html';
class CategoryTile extends Component {
static propTypes = {
item: shape({
image: string,
image: arrayOf(
shape({
url: string,
label: string
})
),
name: string.isRequired,
productImagePreview: shape({
items: arrayOf(
shape({
small_image: string
small_image: shape(
shape({
url: string
})
),
})
)
}),
Expand All @@ -38,16 +43,25 @@ class CategoryTile extends Component {
const { image, productImagePreview } = this.props.item;
const previewProduct = productImagePreview.items[0];
if (image) {
return makeCategoryMediaPath(image);
return image.url;
} else if (previewProduct) {
return makeProductMediaPath(previewProduct.small_image);
return previewProduct.small_image.url;
} else {
return null;
}
}

get imageLabel() {
const { image, name } = this.props.item;
if (image && image.label) {
return image.label;
} else {
return name;
}
}

render() {
const { imagePath, props } = this;
const { imagePath, imageLabel, props } = this;
const { classes, item } = props;

// interpolation doesn't work inside `url()` for legacy reasons
Expand All @@ -57,7 +71,7 @@ class CategoryTile extends Component {

// render an actual image element for accessibility
const imagePreview = imagePath ? (
<img className={classes.image} src={imagePath} alt={item.name} />
<img className={classes.image} src={imagePath} alt={imageLabel} />
) : null;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const items = [
{
id: 1,
name: 'Test Product 1',
small_image: '/test/product/1.png',
small_image: {
url: '/test/product/1.png'
},
price: {
regularPrice: {
amount: {
Expand All @@ -24,7 +26,9 @@ const items = [
{
id: 2,
name: 'Test Product 2',
small_image: '/test/product/2.png',
small_image: {
url: '/test/product/2.png'
},
price: {
regularPrice: {
amount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const classes = {
const validItem = {
id: 1,
name: 'Test Product',
small_image: '/foo/bar/pic.png',
url_key: 'strive-shoulder-pack',
small_image: {
url: '/foo/bar/pic.png'
},
price: {
regularPrice: {
amount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const items = [
{
id: 1,
name: 'Test Product 1',
small_image: '/test/product/1.png',
small_image: {
url: '/test/product/1.png'
},
price: {
regularPrice: {
amount: {
Expand All @@ -22,7 +24,9 @@ const items = [
{
id: 2,
name: 'Test Product 2',
small_image: '/test/product/2.png',
small_image: {
url: '/test/product/2.png'
},
price: {
regularPrice: {
amount: {
Expand Down
7 changes: 6 additions & 1 deletion packages/venia-concept/src/components/Gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ class Gallery extends Component {
shape({
id: number.isRequired,
name: string.isRequired,
small_image: string.isRequired,
small_image: shape(
shape({
url: string,
label: string
})
),
price: shape({
regularPrice: shape({
amount: shape({
Expand Down
31 changes: 20 additions & 11 deletions packages/venia-concept/src/components/Gallery/item.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Component } from 'react';
import { string, number, shape, func, bool } from 'prop-types';
import {string, number, shape, func, bool, arrayOf} from 'prop-types';
import { Price } from '@magento/peregrine';
import { Link } from 'react-router-dom';
import classify from 'src/classify';
import { transparentPlaceholder } from 'src/shared/images';
import { makeProductMediaPath } from 'src/util/makeMediaPath';
import defaultClasses from './item.css';

const imageWidth = '300';
Expand Down Expand Up @@ -40,7 +39,12 @@ class GalleryItem extends Component {
item: shape({
id: number.isRequired,
name: string.isRequired,
small_image: string.isRequired,
small_image: shape(
shape({
url: string,
label: string
})
),
url_key: string.isRequired,
price: shape({
regularPrice: shape({
Expand Down Expand Up @@ -116,25 +120,30 @@ class GalleryItem extends Component {
);
};

/**
* TODO: Product images are currently broken and pending a fix from the `graphql-ce` project
* https://github.com/magento/graphql-ce/issues/88
*/
get imageLabel() {
const { small_image, name } = this.props.item;
if (small_image && small_image.label) {
return small_image.label;
} else {
return name;
}
}

renderImage = () => {
const { classes, item, showImage } = this.props;
const { classes, item, showImage, imageLabel } = this.props;

if (!item) {
return null;
}

const { small_image, name } = item;
const { small_image } = item;
const className = showImage ? classes.image : classes.image_pending;

return (
<img
className={className}
src={makeProductMediaPath(small_image)}
alt={name}
src={small_image.url}
alt={imageLabel}
width={imageWidth}
height={imageHeight}
onLoad={this.handleLoad}
Expand Down
7 changes: 6 additions & 1 deletion packages/venia-concept/src/components/Gallery/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class GalleryItems extends Component {
shape({
id: number.isRequired,
name: string.isRequired,
small_image: string.isRequired,
small_image: shape(
shape({
url: string,
label: string
})
),
price: shape({
regularPrice: shape({
amount: shape({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const classes = {
const item = {
id: 1,
name: 'Test Product 1',
small_image: '/test/product/1.png',
small_image: {
url: '/test/product/1.png'
},
price: {
regularPrice: {
amount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class ProductFullDetail extends Component {
file: string.isRequired
})
),
description: string
description: arrayOf(
shape({
html: string
})
)
}).isRequired,
addToCart: func.isRequired
};
Expand Down Expand Up @@ -194,7 +198,7 @@ class ProductFullDetail extends Component {
<h2 className={classes.descriptionTitle}>
<span>Product Description</span>
</h2>
<RichText content={product.description} />
<RichText content={product.description.html} />
</section>
<section className={classes.details}>
<h2 className={classes.detailsTitle}>
Expand Down
5 changes: 4 additions & 1 deletion packages/venia-concept/src/queries/getCategoryList.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ query categoryList($id: Int!) {
image
productImagePreview: products(pageSize: 1) {
items {
small_image
small_image {
url,
label
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/venia-concept/src/queries/getProductDetail.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ query productDetail($urlKey: String, $onServer: Boolean!) {
}
}
}
description
description {
html
}
media_gallery_entries {
label
position
Expand Down