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 6 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
33 changes: 33 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 HomeViewSectionQuickLinks 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: [QuickLink]
}

# 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 @@ -17596,6 +17615,20 @@ type Query {
): ViewingRoomsConnection
}

type QuickLink {
# The owner ID for the context module
contextScreenOwnerId: String

# Quick link URL
href: String!

# The context module for analytics
ownerType: String!

# Quick link title
title: String!
}

type Quiz {
completedAt(
format: String
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
51 changes: 51 additions & 0 deletions src/schema/v2/homeView/sectionTypes/QuickLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 QuickLinkType = new GraphQLObjectType<QuickLink, ResolverContext>({
name: "QuickLink",
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",
},
contextScreenOwnerId: {
type: GraphQLString,
description: "The owner ID for the context module",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anandaroop @dblandin what do you think about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for? The only specific value I see currently is "/collect?price_range=*-1000" which doesn't read as an ID to me.

Is this needed value need for the analytics support?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what we have in mind. We can also use the href as a payload for the tracking event. it's not clear so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To capture the href value, you could use destination_path which we've included in similar events.

artsy/cohesion#525

},
}),
})

export const HomeViewQuickLinksSectionType = new GraphQLObjectType<
any,
ResolverContext
>({
name: HomeViewSectionTypeNames.HomeViewSectionQuickLinks,
description: "A selection of quick links in the home view",
interfaces: [HomeViewGenericSectionInterface, NodeInterface],
fields: {
...standardSectionFields,
quickLinks: {
type: new GraphQLNonNull(new GraphQLList(QuickLinkType)),
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 { HomeViewQuickLinksSectionType } from "./QuickLinks"

export const homeViewSectionTypes: GraphQLObjectType<any, ResolverContext>[] = [
HomeViewActivitySectionType,
Expand All @@ -26,6 +27,7 @@ export const homeViewSectionTypes: GraphQLObjectType<any, ResolverContext>[] = [
HomeViewFairsSectionType,
HomeViewHeroUnitsSectionType,
HomeViewMarketingCollectionsSectionType,
HomeViewQuickLinksSectionType,
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",
HomeViewSectionQuickLinks: "HomeViewSectionQuickLinks",
HomeViewSectionSales: "HomeViewSectionSales",
HomeViewSectionShows: "HomeViewSectionShows",
HomeViewSectionTasks: "HomeViewSectionTasks",
Expand Down
39 changes: 39 additions & 0 deletions src/schema/v2/homeView/sections/QuickLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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.HomeViewSectionQuickLinks,
requiresAuthentication: true,
resolver: () => {
return QUICK_LINKS
},
}

export interface QuickLink {
contextScreenOwnerId?: string | null
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,
contextScreenOwnerId: "/collect?price_range=*-1000",
},
{
title: "Price Database",
href: "/price-database",
ownerType: OwnerType.priceDatabase,
},
{ title: "Editorial", href: "/news", ownerType: OwnerType.articles },
]
80 changes: 80 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,80 @@
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 HomeViewSectionQuickLinks {
quickLinks {
title
href
ownerType
contextScreenOwnerId
}
}
}
}
}
`

const context = {
accessToken: "424242",
}

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

expect(homeView.section).toMatchInlineSnapshot(`
{
"__typename": "HomeViewSectionQuickLinks",
"contextModule": "quickLinks",
"internalID": "home-view-section-quick-links",
"ownerType": "quickLinks",
"quickLinks": [
{
"contextScreenOwnerId": null,
"href": "/favorites",
"ownerType": "follows",
"title": "Follows",
},
{
"contextScreenOwnerId": null,
"href": "/auctions",
"ownerType": "auctions",
"title": "Auctions",
},
{
"contextScreenOwnerId": null,
"href": "/favorites/saves",
"ownerType": "saves",
"title": "Saves",
},
{
"contextScreenOwnerId": "/collect?price_range=*-1000",
"href": "/collect?price_range=%2A-1000",
"ownerType": "collect",
"title": "Art under $1000",
},
{
"contextScreenOwnerId": null,
"href": "/price-database",
"ownerType": "priceDatabase",
"title": "Price Database",
},
{
"contextScreenOwnerId": null,
"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
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