Skip to content

Commit

Permalink
Merge pull request #46 from vtex-apps/feat/pages
Browse files Browse the repository at this point in the history
Add extension point on filter, gallery and product summary
  • Loading branch information
Bruno Dias authored Oct 2, 2018
2 parents aa6d47f + e198085 commit a017bb9
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 34 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Moved the filter navigator, gallery and product summary to extension points.

## [1.6.0] - 2018-10-02
### Added
Expand Down
4 changes: 1 addition & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
],
"dependencies": {
"vtex.styleguide": "6.x",
"vtex.product-summary": "1.x",
"vtex.store-graphql": "2.x",
"vtex.breadcrumb": "0.x"
"vtex.product-summary": "1.x"
}
}
2 changes: 1 addition & 1 deletion pages/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"component": "index"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { flatten, path, identity, contains } from 'ramda'
import ContentLoader from 'react-content-loader'
import { withRuntimeContext } from 'render'

import SelectedFilters from './SelectedFilters'
import AvailableFilters from './AvailableFilters'
import AccordionFilterContainer from './AccordionFilterContainer'
import SelectedFilters from './components/SelectedFilters'
import AvailableFilters from './components/AvailableFilters'
import AccordionFilterContainer from './components/AccordionFilterContainer'
import {
formatCategoriesTree,
mountOptions,
getMapByType,
} from '../constants/SearchHelpers'
import { facetOptionShape, paramShape, hiddenFacetsSchema } from '../constants/propTypes'
} from './constants/SearchHelpers'
import { facetOptionShape, paramShape, hiddenFacetsSchema } from './constants/propTypes'

export const CATEGORIES_TYPE = 'Categories'
export const BRANDS_TYPE = 'Brands'
Expand All @@ -27,7 +27,7 @@ const PRICE_RANGES_TITLE = 'search.filter.title.price-ranges'
* Wrapper around the filters (selected and available) as well
* as the popup filters that appear on mobile devices
*/
class FiltersContainer extends Component {
class FilterNavigator extends Component {
static propTypes = {
/** Get the props to pass to render's Link */
getLinkProps: PropTypes.func.isRequired,
Expand Down Expand Up @@ -208,4 +208,4 @@ class FiltersContainer extends Component {
}
}

export default withRuntimeContext(FiltersContainer)
export default withRuntimeContext(FilterNavigator)
4 changes: 2 additions & 2 deletions react/components/Gallery.js → react/Gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import { PropTypes } from 'prop-types'
import classNames from 'classnames'

import { productShape } from '../constants/propTypes'
import GalleryItem from './GalleryItem'
import { productShape } from './constants/propTypes'
import GalleryItem from './components/GalleryItem'

/**
* Canonical gallery that displays a list of given products.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import React from 'react'
import { shallow } from 'enzyme'

import FiltersContainer from '../../components/FiltersContainer'
import FilterNavigator from '../FilterNavigator'

describe('<FiltersContainer />', () => {
describe('<FilterNavigator />', () => {
beforeEach(() => {
global.__RUNTIME__ = {
hints: { mobile: false },
Expand All @@ -13,7 +13,7 @@ describe('<FiltersContainer />', () => {

it('should match snapshot', () => {
const wrapper = shallow(
<FiltersContainer
<FilterNavigator
getLinkProps={jest.fn()}
map="c"
rest=""
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('<FiltersContainer />', () => {
]

const wrapper = shallow(
<FiltersContainer
<FilterNavigator
getLinkProps={jest.fn()}
map="c"
rest=""
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('<FiltersContainer />', () => {
]

const wrapper = shallow(
<FiltersContainer
<FilterNavigator
getLinkProps={jest.fn()}
map="c"
rest=""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<FiltersContainer /> should match snapshot 1`] = `
exports[`<FilterNavigator /> should match snapshot 1`] = `
<React.Fragment>
<InjectIntl(SelectedFilters)
filters={Array []}
Expand Down
2 changes: 1 addition & 1 deletion react/__tests__/constants/SearchHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BRANDS_TYPE,
PRICE_RANGES_TYPE,
SPECIFICATION_FILTERS_TYPE,
} from '../../components/FiltersContainer'
} from '../../FilterNavigator'

describe('getSpecificationFilterFromLink', () => {
it('should return the only specification in link', () => {
Expand Down
2 changes: 1 addition & 1 deletion react/components/AvailableFilters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'

import { PRICE_RANGES_TYPE } from './FiltersContainer'
import { PRICE_RANGES_TYPE } from '../FilterNavigator'
import { mountOptions } from '../constants/SearchHelpers'
import SearchFilter from './SearchFilter'
import PriceRange from './PriceRange'
Expand Down
5 changes: 3 additions & 2 deletions react/components/GalleryItem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { ExtensionPoint } from 'render'

import ProductSummary from 'vtex.product-summary/index'
import { productShape } from '../constants/propTypes'
import { PropTypes } from 'prop-types'

Expand Down Expand Up @@ -38,7 +38,8 @@ export default class GalleryItem extends Component {

render() {
return (
<ProductSummary
<ExtensionPoint
id="product-summary"
{...this.props.summary}
product={this.normalizeProductSummary(this.props.item)}
displayMode={this.props.displayMode}
Expand Down
8 changes: 4 additions & 4 deletions react/components/SearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { ExtensionPoint } from 'render'
import { FormattedMessage } from 'react-intl'

import LayoutModeSwitcher from './LayoutModeSwitcher'
import FiltersContainer from './FiltersContainer'
import { searchResultPropTypes } from '../constants/propTypes'
import OrderBy from './OrderBy'
import Gallery from './Gallery'

/**
* Search Result Component.
Expand Down Expand Up @@ -63,7 +61,8 @@ export default class SearchResult extends Component {
</FormattedMessage>
</div>
<div className="vtex-search-result__filters">
<FiltersContainer
<ExtensionPoint
id="filter-navigator"
brands={brands}
getLinkProps={getLinkProps}
map={map}
Expand Down Expand Up @@ -98,7 +97,8 @@ export default class SearchResult extends Component {
</div>
</div>
) : (
<Gallery
<ExtensionPoint
id="gallery"
products={products}
summary={summary}
layoutMode={this.state.galleryLayoutMode}
Expand Down
2 changes: 1 addition & 1 deletion react/constants/SearchHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
BRANDS_TYPE,
PRICE_RANGES_TYPE,
SPECIFICATION_FILTERS_TYPE,
} from '../components/FiltersContainer'
} from '../FilterNavigator'

/**
* Returns the parameter name to be used in the map
Expand Down
12 changes: 6 additions & 6 deletions react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class SearchResultContainer extends Component {
params,
priceRange,
pagination,
hiddenFacets
hiddenFacets,
} = this.props

const breadcrumbsProps = this.breadcrumbsProps
Expand Down Expand Up @@ -176,17 +176,17 @@ export default class SearchResultContainer extends Component {
priceRanges: PriceRanges,
priceRange: priceRange,
hiddenFacets,
tree: CategoriesTrees
tree: CategoriesTrees,
}

return (
<PopupProvider>
{pagination === PAGINATION_TYPES[0] ? (
<ShowMoreLoaderResult {...props} />
) : (
<InfiniteScrollLoaderResult {...props} />
)}
</PopupProvider >
<InfiniteScrollLoaderResult {...props} />
)}
</PopupProvider>
)
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ SearchResultContainer.getSchema = props => {
'editor.search-result.pagination.show-more',
'editor.search-result.pagination.infinite-scroll',
],
}
},
},
}
}

0 comments on commit a017bb9

Please sign in to comment.