-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ONYX-1479): add quick links section (#6354)
* feat: add quick links section Co-authored-by: Mounir Dhahri <[email protected]> * chore: add tracking Co-authored-by: Mounir Dhahri <[email protected]> * chore: add tests Co-authored-by: Mounir Dhahri <[email protected]> * feat: add contextScreenOwnerId and ownerType * Update src/schema/v2/homeView/sectionTypes/QuickLinks.ts Co-authored-by: Mounir Dhahri <[email protected]> * Update src/schema/v2/homeView/sectionTypes/QuickLinks.ts Co-authored-by: Mounir Dhahri <[email protected]> * chore: rename QiockLinks to NavigationPills * chore: rename section id * chore: rename * chore: remove contextScreenOwnerId * chore: fix text * fix: broken test --------- Co-authored-by: Mounir Dhahri <[email protected]>
- Loading branch information
1 parent
c4e72f6
commit e50a89b
Showing
12 changed files
with
206 additions
and
5 deletions.
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
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,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) : [], | ||
}, | ||
}, | ||
}) |
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,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
73
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,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", | ||
}, | ||
], | ||
} | ||
`) | ||
}) | ||
}) |
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
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