-
Notifications
You must be signed in to change notification settings - Fork 89
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
dariakoko
wants to merge
10
commits into
main
Choose a base branch
from
dariakoko/feat/add-quick-links-section
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
67f363d
feat: add quick links section
dariakoko a96cd8c
chore: add tracking
dariakoko 9a781b6
chore: add tests
dariakoko 6e9b2d9
feat: add contextScreenOwnerId and ownerType
dariakoko 48a6fbf
Update src/schema/v2/homeView/sectionTypes/QuickLinks.ts
dariakoko a9ddd2e
Update src/schema/v2/homeView/sectionTypes/QuickLinks.ts
dariakoko 65680d9
chore: rename QiockLinks to NavigationPills
dariakoko b11c956
chore: rename section id
dariakoko 7dc80e8
chore: rename
dariakoko 142eb4c
chore: remove contextScreenOwnerId
dariakoko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}), | ||
}) | ||
|
||
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) : [], | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
80
src/schema/v2/homeView/sections/__tests__/QuickLinks.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
], | ||
} | ||
`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 usedestination_path
which we've included in similar events.artsy/cohesion#525