DSLinkMenu.jsx (3553B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { LinkMenu } from "content-src/components/LinkMenu/LinkMenu"; 6 import { ContextMenuButton } from "content-src/components/ContextMenu/ContextMenuButton"; 7 import { actionCreators as ac } from "common/Actions.mjs"; 8 import React from "react"; 9 import { connect } from "react-redux"; 10 11 export class _DSLinkMenu extends React.PureComponent { 12 render() { 13 const { index, dispatch } = this.props; 14 let TOP_STORIES_CONTEXT_MENU_OPTIONS; 15 const PREF_REPORT_ADS_ENABLED = "discoverystream.reportAds.enabled"; 16 const prefs = this.props.Prefs.values; 17 const showAdsReporting = prefs[PREF_REPORT_ADS_ENABLED]; 18 const isSpoc = this.props.card_type === "spoc"; 19 20 if (isSpoc) { 21 TOP_STORIES_CONTEXT_MENU_OPTIONS = [ 22 "BlockUrl", 23 ...(showAdsReporting ? ["ReportAd"] : []), 24 "ManageSponsoredContent", 25 "OurSponsorsAndYourPrivacy", 26 ]; 27 } else { 28 TOP_STORIES_CONTEXT_MENU_OPTIONS = [ 29 "CheckBookmark", 30 "Separator", 31 "OpenInNewWindow", 32 "OpenInPrivateWindow", 33 "Separator", 34 "BlockUrl", 35 ...(this.props.section ? ["ReportContent"] : []), 36 ]; 37 } 38 39 const type = this.props.type || "DISCOVERY_STREAM"; 40 const title = this.props.title || this.props.source; 41 42 return ( 43 <div className="context-menu-position-container"> 44 <ContextMenuButton 45 tooltip={"newtab-menu-content-tooltip"} 46 tooltipArgs={{ title }} 47 onUpdate={this.props.onMenuUpdate} 48 tabIndex={this.props.tabIndex} 49 > 50 <LinkMenu 51 dispatch={dispatch} 52 index={index} 53 source={type.toUpperCase()} 54 onShow={this.props.onMenuShow} 55 options={TOP_STORIES_CONTEXT_MENU_OPTIONS} 56 shouldSendImpressionStats={true} 57 userEvent={ac.DiscoveryStreamUserEvent} 58 site={{ 59 referrer: "https://getpocket.com/recommendations", 60 title: this.props.title, 61 type: this.props.type, 62 url: this.props.url, 63 guid: this.props.id, 64 pocket_id: this.props.pocket_id, 65 card_type: this.props.card_type, 66 shim: this.props.shim, 67 bookmarkGuid: this.props.bookmarkGuid, 68 flight_id: this.props.flightId, 69 tile_id: this.props.tile_id, 70 recommendation_id: this.props.recommendation_id, 71 corpus_item_id: this.props.corpus_item_id, 72 scheduled_corpus_item_id: this.props.scheduled_corpus_item_id, 73 firstVisibleTimestamp: this.props.firstVisibleTimestamp, 74 recommended_at: this.props.recommended_at, 75 received_rank: this.props.received_rank, 76 topic: this.props.topic, 77 position: index, 78 ...(this.props.format ? { format: this.props.format } : {}), 79 ...(this.props.section 80 ? { 81 section: this.props.section, 82 section_position: this.props.section_position, 83 is_section_followed: this.props.is_section_followed, 84 } 85 : {}), 86 }} 87 /> 88 </ContextMenuButton> 89 </div> 90 ); 91 } 92 } 93 94 export const DSLinkMenu = connect(state => ({ 95 Prefs: state.Prefs, 96 }))(_DSLinkMenu);