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

feat(ONYX-1479): add quick links section #6354

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
30 changes: 30 additions & 0 deletions _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11480,6 +11480,25 @@ type HomeViewSectionMarketingCollections implements HomeViewSectionGeneric & Nod
ownerType: String
}

# A selection of quick links in the home view
type HomeViewSectionNavigationPills implements HomeViewSectionGeneric & Node {
# Component prescription for this section, for overriding or customizing presentation and behavior
component: HomeViewComponent

# [Analytics] `context module` analytics value for this section, as defined in our schema (artsy/cohesion)
contextModule: String

# A globally unique ID.
id: ID!

# A type-specific ID likely used as a database ID.
internalID: ID!

# [Analytics] `owner type` analytics value for this scetion when displayed in a standalone UI, as defined in our schema (artsy/cohesion)
ownerType: String
quickLinks: [NavigationPill]!
}

# A sales (auctions) section in the home view
type HomeViewSectionSales implements HomeViewSectionGeneric & Node {
# Component prescription for this section, for overriding or customizing presentation and behavior
Expand Down Expand Up @@ -14489,6 +14508,17 @@ type MyLocation {
timezone: String
}

type NavigationPill {
# Quick link URL
href: String!

# The context module for analytics
ownerType: String!

# Quick link title
title: String!
}

input Near {
lat: Float!
lng: Float!
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"string-width": "4.2.3"
},
"dependencies": {
"@artsy/cohesion": "^4.219.0",
"@artsy/cohesion": "^4.224.0",
"@artsy/img": "1.0.3",
"@artsy/morgan": "^1.0.2",
"@artsy/multienv": "^1.2.0",
Expand Down
47 changes: 47 additions & 0 deletions src/schema/v2/homeView/sectionTypes/NavigationPills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
GraphQLString,
} from "graphql"
import { ResolverContext } from "types/graphql"
import { NodeInterface } from "../../object_identification"
import { HomeViewGenericSectionInterface } from "./GenericSectionInterface"
import { HomeViewSectionTypeNames } from "./names"
import { standardSectionFields } from "./GenericSectionInterface"
import { QuickLink } from "../sections/QuickLinks"

const NavigationPillType = new GraphQLObjectType<QuickLink, ResolverContext>({
name: "NavigationPill",
fields: () => ({
title: {
type: new GraphQLNonNull(GraphQLString),
description: "Quick link title",
},
href: {
type: new GraphQLNonNull(GraphQLString),
description: "Quick link URL",
},
ownerType: {
type: new GraphQLNonNull(GraphQLString),
description: "The context module for analytics",
},
}),
})

export const HomeViewNavigationPillsSectionType = new GraphQLObjectType<
any,
ResolverContext
>({
name: HomeViewSectionTypeNames.HomeViewSectionNavigationPills,
description: "A selection of quick links in the home view",
interfaces: [HomeViewGenericSectionInterface, NodeInterface],
fields: {
...standardSectionFields,
quickLinks: {
type: new GraphQLNonNull(new GraphQLList(NavigationPillType)),
resolve: (parent, ...rest) =>
parent.resolver ? parent.resolver(parent, ...rest) : [],
},
},
})
2 changes: 2 additions & 0 deletions src/schema/v2/homeView/sectionTypes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HomeViewSalesSectionType } from "./Sales"
import { HomeViewShowsSectionType } from "./Shows"
import { HomeViewTasksSectionType } from "./Tasks"
import { HomeViewViewingRoomsSectionType } from "./ViewingRooms"
import { HomeViewNavigationPillsSectionType } from "./NavigationPills"

export const homeViewSectionTypes: GraphQLObjectType<any, ResolverContext>[] = [
HomeViewActivitySectionType,
Expand All @@ -26,6 +27,7 @@ export const homeViewSectionTypes: GraphQLObjectType<any, ResolverContext>[] = [
HomeViewFairsSectionType,
HomeViewHeroUnitsSectionType,
HomeViewMarketingCollectionsSectionType,
HomeViewNavigationPillsSectionType,
HomeViewSalesSectionType,
HomeViewShowsSectionType,
HomeViewTasksSectionType,
Expand Down
1 change: 1 addition & 0 deletions src/schema/v2/homeView/sectionTypes/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const HomeViewSectionTypeNames = {
HomeViewSectionGeneric: "HomeViewSectionGeneric",
HomeViewSectionHeroUnits: "HomeViewSectionHeroUnits",
HomeViewSectionMarketingCollections: "HomeViewSectionMarketingCollections",
HomeViewSectionNavigationPills: "HomeViewSectionNavigationPills",
HomeViewSectionSales: "HomeViewSectionSales",
HomeViewSectionShows: "HomeViewSectionShows",
HomeViewSectionTasks: "HomeViewSectionTasks",
Expand Down
37 changes: 37 additions & 0 deletions src/schema/v2/homeView/sections/QuickLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ContextModule, OwnerType } from "@artsy/cohesion"
import { HomeViewSection } from "."
import { HomeViewSectionTypeNames } from "../sectionTypes/names"

export const QuickLinks: HomeViewSection = {
id: "home-view-section-quick-links",
contextModule: ContextModule.quickLinks,
ownerType: OwnerType.quickLinks,
type: HomeViewSectionTypeNames.HomeViewSectionNavigationPills,
requiresAuthentication: true,
resolver: () => {
return QUICK_LINKS
},
}

export interface QuickLink {
title: string
href: string
ownerType: OwnerType
}

const QUICK_LINKS: Array<QuickLink> = [
{ title: "Follows", href: "/favorites", ownerType: OwnerType.follows },
{ title: "Auctions", href: "/auctions", ownerType: OwnerType.auctions },
{ title: "Saves", href: "/favorites/saves", ownerType: OwnerType.saves },
{
title: "Art under $1000",
href: "/collect?price_range=%2A-1000",
ownerType: OwnerType.collect,
},
{
title: "Price Database",
href: "/price-database",
ownerType: OwnerType.priceDatabase,
},
{ title: "Editorial", href: "/news", ownerType: OwnerType.articles },
]
73 changes: 73 additions & 0 deletions src/schema/v2/homeView/sections/__tests__/QuickLinks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import gql from "lib/gql"
import { runQuery } from "schema/v2/test/utils"

describe("QuickLinks", () => {
it("returns the section's data", async () => {
const query = gql`
{
homeView {
section(id: "home-view-section-quick-links") {
__typename
internalID
contextModule
ownerType
... on HomeViewSectionNavigationPills {
quickLinks {
title
href
ownerType
}
}
}
}
}
`

const context = {
accessToken: "424242",
}

const { homeView } = await runQuery(query, context)

expect(homeView.section).toMatchInlineSnapshot(`
{
"__typename": "HomeViewSectionNavigationPills",
"contextModule": "quickLinks",
"internalID": "home-view-section-quick-links",
"ownerType": "quickLinks",
"quickLinks": [
{
"href": "/favorites",
"ownerType": "follows",
"title": "Follows",
},
{
"href": "/auctions",
"ownerType": "auctions",
"title": "Auctions",
},
{
"href": "/favorites/saves",
"ownerType": "saves",
"title": "Saves",
},
{
"href": "/collect?price_range=%2A-1000",
"ownerType": "collect",
"title": "Art under $1000",
},
{
"href": "/price-database",
"ownerType": "priceDatabase",
"title": "Price Database",
},
{
"href": "/news",
"ownerType": "articles",
"title": "Editorial",
},
],
}
`)
})
})
2 changes: 2 additions & 0 deletions src/schema/v2/homeView/sections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { TrendingArtists } from "./TrendingArtists"
import { ViewingRooms } from "./ViewingRooms"
import { InfiniteDiscovery } from "./InfiniteDiscovery"
import { SemanticVersionNumber } from "lib/semanticVersioning"
import { QuickLinks } from "./QuickLinks"

type MaybeResolved<T> =
| T
Expand Down Expand Up @@ -70,6 +71,7 @@ const sections: HomeViewSection[] = [
News,
NewWorksForYou,
NewWorksFromGalleriesYouFollow,
QuickLinks,
RecentlyViewedArtworks,
RecommendedArtists,
RecommendedArtworks,
Expand Down
1 change: 1 addition & 0 deletions src/schema/v2/homeView/zones/__tests__/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("getSections", () => {

expect(sectionIds).toMatchInlineSnapshot(`
[
"home-view-section-navigation-pills",
"home-view-section-tasks",
"home-view-section-latest-activity",
"home-view-section-new-works-for-you",
Expand Down
2 changes: 2 additions & 0 deletions src/schema/v2/homeView/zones/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import { Tasks } from "../sections/Tasks"
import { TrendingArtists } from "../sections/TrendingArtists"
import { ViewingRooms } from "../sections/ViewingRooms"
import { InfiniteDiscovery } from "../sections/InfiniteDiscovery"
import { QuickLinks } from "../sections/QuickLinks"

const SECTIONS: HomeViewSection[] = [
QuickLinks,
Tasks,
LatestActivity,
NewWorksForYou,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"@jridgewell/gen-mapping" "^0.3.5"
"@jridgewell/trace-mapping" "^0.3.24"

"@artsy/cohesion@^4.219.0":
version "4.219.0"
resolved "https://registry.yarnpkg.com/@artsy/cohesion/-/cohesion-4.219.0.tgz#331cdd7ea0b0f76754cac65c17ac8c0a145d1392"
integrity sha512-KzDpewJfnuZ+WoGqlVlFcE307yALyWtzdtw58QjCW1JAZZOGUi4inEf4zpVsqcmeARJCzVHvqySej+ZBkbtkjg==
"@artsy/cohesion@^4.224.0":
version "4.224.0"
resolved "https://registry.yarnpkg.com/@artsy/cohesion/-/cohesion-4.224.0.tgz#b5aeb84cc5f5550714840456185e4ade0879b96d"
integrity sha512-ZKrFCjALTE77R07k9bYz+LURR/4NtKFh38v+DUEev4yzEzGemDZePx7hDd4wwPcs626aL/bPeYdo1I2m9KxqlQ==
dependencies:
core-js "3"

Expand Down