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

Gene page refactor! #413

Merged
merged 13 commits into from
Dec 14, 2017
294 changes: 280 additions & 14 deletions data/schema.graphql

Large diffs are not rendered by default.

2,739 changes: 2,448 additions & 291 deletions data/schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion externals/metaphysics
Submodule metaphysics updated 43 files
+1 −0 .env.test
+0 −14 changelog.md
+101 −59 docs/adding_a_new_microservice.md
+3 −4 index.js
+11 −0 lib/apis/diffusion.js
+8 −0 lib/loaders/api/index.js
+23 −6 lib/loaders/api/loader_without_authentication_factory.js
+1 −0 lib/loaders/loaders_with_authentication/gravity.js
+11 −0 lib/loaders/loaders_without_authentication/diffusion.js
+2 −1 lib/loaders/loaders_without_authentication/gravity.js
+2 −0 lib/loaders/loaders_without_authentication/index.js
+5 −27 lib/tracer.js
+99 −51 package-lock.json
+2 −2 package.json
+92 −0 schema/__tests__/auction_results.test.js
+46 −1 schema/__tests__/filter_artworks.test.js
+80 −0 schema/__tests__/gene.test.js
+4 −4 schema/__tests__/sale_artworks.test.js
+5 −3 schema/__tests__/suggested_genes.test.js
+33 −10 schema/artist/__tests__/highlights.test.js
+19 −0 schema/artist/__tests__/index.test.js
+8 −9 schema/artist/highlights.js
+44 −1 schema/artist/index.js
+4 −0 schema/artwork/__tests__/artwork.test.js
+114 −0 schema/auction_result.js
+1 −1 schema/edition_set.js
+51 −20 schema/filter_artworks.js
+141 −103 schema/gene.js
+2 −0 schema/index.js
+1 −1 schema/me/__tests__/consignments/submissions.test.js
+58 −0 schema/me/__tests__/followed_artists_artwork_groups.test.js
+84 −0 schema/me/followed_artists_artworks_group.js
+12 −6 schema/me/index.js
+9 −6 schema/me/notifications.js
+7 −2 schema/object_identification.js
+65 −14 schema/partner_artist.js
+90 −21 schema/sale/__tests__/index.test.js
+17 −5 schema/sale/index.js
+4 −5 schema/sale_artworks.js
+22 −0 schema/services/convection.js
+24 −0 schema/services/index.js
+11 −11 schema/suggested_genes.js
+94 −102 yarn.lock
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"storybook": "node verify-node-version.js && concurrently --kill-others 'yarn relay --watch' 'env GRAPHQL_NO_NAME_WARNING=true start-storybook -p 9001'",
"deploy-storybook": "yarn relay && NODE_ENV=production storybook-to-ghpages",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/master && yarn install && npm run dump-schema -- ../../data",
"sync-schema:localhost": "cd ../metaphysics && yarn dump-schema -- ../emission/data",
"sync-colors": "cd externals/elan && git fetch && git checkout origin/master && cp components/lib/variables/colors.json ../../data",
"lint": "tslint -c tslint.json --project tsconfig.json",
"type-check": "tsc --noEmit --pretty",
Expand All @@ -32,10 +33,10 @@
"compile": "env GRAPHQL_NO_NAME_WARNING=true gulp compile",
"prepublishOnly": "rm -rf dist && npm run compile",
"precommit": "lint-staged",
"prepush": "npm run type-check",
"prepush": "yarn run type-check",
"prettier": "prettier",
"prettier-write": "npm run prettier --write",
"prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'"
"prettier-write": "yarn run prettier --write",
"prettier-project": "yarn run prettier-write 'src/**/*.{ts,tsx}'"
},
"prettier": {
"printWidth": 120,
Expand Down
12 changes: 6 additions & 6 deletions src/Components/ArtworkFilter/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { find } from "lodash"

interface DropdownProps extends RelayProps, React.HTMLProps<Dropdown> {
aggregation: any
onSelect?: any
onSelected?: (slice: string, value: string) => void
selected?: any
}

Expand Down Expand Up @@ -41,12 +41,12 @@ export class Dropdown extends React.Component<DropdownProps, DropdownState> {
})
}

onSelect(count, slice) {
onSelect(slice: string, value: string) {
this.setState({
selected: count.id,
selected: value,
isHovered: false,
})
this.props.onSelect(count, slice)
this.props.onSelected(slice, value)
}

getSelectedName(id) {
Expand All @@ -61,15 +61,15 @@ export class Dropdown extends React.Component<DropdownProps, DropdownState> {

let navItems = this.props.aggregation.counts.map(count => {
return (
<NavItem key={count.id} onClick={() => this.onSelect(count, slice)}>
<NavItem key={count.id} onClick={() => this.onSelect(slice, count.id)}>
<span>{count.name}</span>
<NavItemCount>&nbsp;({numeral(count.count).format("0,0")})</NavItemCount>
</NavItem>
)
})

navItems.unshift(
<NavItem key="all" onClick={() => this.onSelect({ value: "*" }, slice)}>
<NavItem key="all" onClick={() => this.onSelect(slice, "*")}>
<span>All {labels.plural}</span>
</NavItem>
)
Expand Down
8 changes: 4 additions & 4 deletions src/Components/ArtworkFilter/ForSaleCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import colors from "../../Assets/Colors"
import { primary } from "../../Assets/Fonts"

interface Props extends React.HTMLProps<ForSaleCheckbox> {
onClick?: any
onChange?: any
}

interface State {
Expand All @@ -23,15 +23,15 @@ export class ForSaleCheckbox extends React.Component<Props, State> {
this.setState({
isChecked: !this.state.isChecked,
})
this.props.onClick()
this.props.onChange()
}

render() {
const { isChecked } = this.state

const { checked } = this.props
return (
<div className={this.props.className} onClick={() => this.onClick()}>
<StyledCheckbox checked={isChecked} />
<StyledCheckbox checked={isChecked || checked} />
<label>Only for Sale</label>
</div>
)
Expand Down
4 changes: 3 additions & 1 deletion src/Components/ArtworkFilter/Headline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class Headline extends React.Component<Props, null> {

medium() {
const { medium, facet } = this.props

if (medium && medium !== "*") {
return this.getCountName("medium", medium)
}
Expand Down Expand Up @@ -87,6 +86,9 @@ export default createFragmentContainer(
... on ArtworkFilterTag {
name
}
... on ArtworkFilterGene {
name
}
}
`
)
5 changes: 3 additions & 2 deletions src/Components/ArtworkFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ArtworkFilter extends React.Component<Props, State> {
<Dropdown
aggregation={aggregation}
key={aggregation.slice}
onSelect={(count, slice) => this.onSelect(count, slice)}
onSelected={(count, slice) => this.onSelect(count, slice)}
/>
))
const pulldownOptions = [
Expand Down Expand Up @@ -186,16 +186,17 @@ export default createPaginationContainer(
...TotalCount_filter_artworks
artworks: artworks_connection(first: $count, after: $cursor)
@connection(key: "ArtworkFilter_filter_artworks") {
...ArtworkGrid_artworks
pageInfo {
hasNextPage
endCursor
}
edges {

node {
__id
}
}
...ArtworkGrid_artworks
}
facet {
...Headline_facet
Expand Down
5 changes: 3 additions & 2 deletions src/Components/BorderedPulldown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props extends React.HTMLProps<BorderedPulldown> {
options: any
defaultValue: string
onChange?: any
selectedName?: string
}

interface State {
Expand Down Expand Up @@ -38,7 +39,7 @@ export class BorderedPulldown extends React.Component<Props, State> {
}

render() {
const { options, defaultValue } = this.props
const { options, defaultValue, selectedName } = this.props

const optionEls = options.map(option => {
return (
Expand All @@ -48,7 +49,7 @@ export class BorderedPulldown extends React.Component<Props, State> {
)
})

const displayValue = (this.state.selected && this.state.selected.name) || defaultValue
const displayValue = (this.state.selected && this.state.selected.name) || selectedName || defaultValue
let pulldownStyles = {}

if (this.state.isHovered) {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Checkbox extends React.Component<Props, null> {

return (
<div className={this.props.className}>
<CheckboxInput type="checkbox" checked={checked} />
<CheckboxInput onChange={() => null} type="checkbox" checked={checked} />
<Label />
</div>
)
Expand Down
92 changes: 84 additions & 8 deletions src/Components/Gene/Artists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import * as fonts from "../../Assets/Fonts"
import Spinner from "../Spinner"
import ArtistRow from "./ArtistRow"

import Dropdown from "../ArtworkFilter/Dropdown"

import { ButtonState } from "../Buttons/Default"
import Button from "../Buttons/Ghost"

const PageSize = 10

interface Props extends RelayProps {
relay?: RelayPaginationProp
onDropdownSelected: (slice: string, value: string) => void
}

interface State {
Expand Down Expand Up @@ -44,6 +50,23 @@ const SpinnerContainer = styled.div`
position: relative;
`

const ArtistFilterButtons = styled.div`
margin-right: 10px;
button {
height: 52px;
padding: 16px;
}
`

const FilterBar = styled.div`
vertical-align: middle;
text-align: center;

> div {
display: inline-block;
}
`

export class Artists extends React.Component<Props, State> {
state = {
loading: false,
Expand All @@ -60,6 +83,36 @@ export class Artists extends React.Component<Props, State> {
}
}

renderArtistFilter() {
return (
<ArtistFilterButtons>
<span>By Artists:</span>
<Button
onClick={() => {
return null
}}
state={ButtonState.Success}
>
All Artists
</Button>
<span>By Work:</span>
</ArtistFilterButtons>
)
}

renderArtistDropdown() {
return this.props.gene.filter_aggregations.aggregations.map(aggregation => {
return (
<Dropdown
aggregation={aggregation}
key={aggregation.slice}
selected={aggregation.slice && this.state[aggregation.slice.toLowerCase()]}
onSelected={this.props.onDropdownSelected}
/>
)
})
}

render() {
const artists = this.props.gene.artists

Expand All @@ -74,11 +127,17 @@ export class Artists extends React.Component<Props, State> {
)

return (
<ArtistRowsContainer>
{artistRows}
<SpinnerContainer>{this.state.loading ? <Spinner /> : ""}</SpinnerContainer>
{artists && artists.pageInfo.hasNextPage && !this.state.loading && loadMoreButton}
</ArtistRowsContainer>
<div>
<FilterBar>
{this.renderArtistFilter()}
{this.renderArtistDropdown()}
</FilterBar>
<ArtistRowsContainer>
{artistRows}
<SpinnerContainer>{this.state.loading ? <Spinner /> : ""}</SpinnerContainer>
{artists && artists.pageInfo.hasNextPage && !this.state.loading && loadMoreButton}
</ArtistRowsContainer>
</div>
)
}
}
Expand All @@ -88,7 +147,11 @@ export default createPaginationContainer(
{
gene: graphql.experimental`
fragment Artists_gene on Gene
@argumentDefinitions(count: { type: "Int", defaultValue: 10 }, cursor: { type: "String", defaultValue: "" }) {
@argumentDefinitions(
aggregations: { type: "[ArtworkAggregation]", defaultValue: [MEDIUM, TOTAL, PRICE_RANGE, DIMENSION_RANGE] }
count: { type: "Int", defaultValue: 10 }
cursor: { type: "String", defaultValue: "" }
) {
__id
artists: artists_connection(first: $count, after: $cursor) @connection(key: "Artists_artists") {
pageInfo {
Expand All @@ -101,6 +164,13 @@ export default createPaginationContainer(
}
}
}
filter_aggregations: filtered_artworks(aggregations: $aggregations, size: 0) {
...TotalCount_filter_artworks
aggregations {
slice
...Dropdown_aggregation
}
}
}
`,
},
Expand All @@ -122,12 +192,13 @@ export default createPaginationContainer(
...fragmentVariables,
count,
cursor,
geneNodeID: props.gene.__id,
}
},
query: graphql.experimental`
query ArtistsQuery($geneNodeID: ID!, $count: Int!, $cursor: String) {
query ArtistsQuery($geneNodeID: ID!, $count: Int!, $cursor: String, $aggregations: [ArtworkAggregation]) {
node(__id: $geneNodeID) {
...Artists_gene @arguments(count: $count, cursor: $cursor)
...Artists_gene @arguments(count: $count, cursor: $cursor, aggregations: $aggregations)
}
}
`,
Expand All @@ -147,5 +218,10 @@ interface RelayProps {
}
}>
}
filter_aggregations: {
aggregations: Array<{
slice: string
}>
}
}
}
Loading