Skip to content

Commit c721be7

Browse files
committed
Bug 1954653 - Build reporting UI. r=home-newtab-reviewers,fluent-reviewers,frontend-codestyle-reviewers,mossop,nbarrett,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D242283
1 parent a6e6f64 commit c721be7

File tree

29 files changed

+581
-65
lines changed

29 files changed

+581
-65
lines changed

browser/app/profile/firefox.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,9 @@ pref("browser.newtabpage.activity-stream.discoverystream.spocMessageVariant", ""
19391939

19401940
pref("browser.newtabpage.activity-stream.discoverystream.sendToPocket.enabled", true);
19411941

1942+
// Pref enabling content reporting
1943+
pref("browser.newtabpage.activity-stream.discoverystream.reportContent.enabled", false);
1944+
19421945
// List of regions that do not get stories, regardless of locale-list-config.
19431946
pref("browser.newtabpage.activity-stream.discoverystream.region-stories-block", "");
19441947
// List of locales that get stories, regardless of region-stories-config.

browser/components/preferences/preferences.xhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<link rel="localization" href="preview/translations.ftl"/>
7575
<link rel="localization" href="preview/enUS-searchFeatures.ftl"/>
7676
<link rel="localization" href="preview/backupSettings.ftl"/>
77+
<link rel="localization" href="preview/reportContentTemporary.ftl"/>
7778
<link rel="localization" href="security/certificates/certManager.ftl"/>
7879
<link rel="localization" href="security/certificates/deviceManager.ftl"/>
7980
<link rel="localization" href="toolkit/updates/history.ftl"/>

browser/extensions/newtab/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
"content-src/components/WallpapersSection/**",
3333
"content-src/components/DiscoveryStreamComponents/TopicSelection/TopicSelection.jsx",
3434
"content-src/components/DiscoveryStreamComponents/InterestPicker/InterestPicker.jsx",
35+
"content-src/components/DiscoveryStreamComponents/ReportContent/ReportContent.jsx",
3536
],
3637
rules: {
3738
"jsx-a11y/anchor-has-content": "off",

browser/extensions/newtab/bin/render-activity-stream-html.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ function templateHTML(options) {
7979
<link rel="localization" href="toolkit/branding/brandings.ftl" />
8080
<link rel="localization" href="browser/newtab/newtab.ftl" />
8181
<link rel="localization" href="toolkit/global/mozMessageBar.ftl" />
82+
<link rel="localization" href="preview/reportContentTemporary.ftl" />
8283
<link
8384
rel="stylesheet"
8485
href="chrome://global/skin/design-system/tokens-brand.css"
@@ -119,6 +120,11 @@ function templateHTML(options) {
119120
type="module"
120121
src="chrome://global/content/elements/moz-message-bar.mjs"
121122
></script>
123+
<script
124+
async
125+
type="module"
126+
src="chrome://global/content/elements/moz-radio-group.mjs"
127+
></script>
122128
</body>
123129
</html>
124130
`.trimLeft();

browser/extensions/newtab/common/Actions.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ for (const type of [
137137
"PREVIEW_REQUEST_CANCEL",
138138
"PREVIEW_RESPONSE",
139139
"REMOVE_DOWNLOAD_FILE",
140+
"REPORT_CLOSE",
141+
"REPORT_OPEN",
140142
"RICH_ICON_MISSING",
141143
"SAVE_SESSION_PERF_DATA",
142144
"SAVE_TO_POCKET",

browser/extensions/newtab/common/Reducers.sys.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export const INITIAL_STATE = {
102102
isUserLoggedIn: false,
103103
recentSavesEnabled: false,
104104
showTopicSelection: false,
105+
report: {
106+
visible: false,
107+
data: {},
108+
},
105109
},
106110
// Messages received from ASRouter to render in newtab
107111
Messages: {
@@ -892,6 +896,22 @@ function DiscoveryStream(prevState = INITIAL_STATE.DiscoveryStream, action) {
892896
showBlockSectionConfirmation: true,
893897
sectionData: action.data,
894898
};
899+
case at.REPORT_OPEN:
900+
return {
901+
...prevState,
902+
report: {
903+
...prevState.report,
904+
visible: true,
905+
},
906+
};
907+
case at.REPORT_CLOSE:
908+
return {
909+
...prevState,
910+
report: {
911+
...prevState.report,
912+
visible: false,
913+
},
914+
};
895915
default:
896916
return prevState;
897917
}

browser/extensions/newtab/content-src/components/DiscoveryStreamBase/DiscoveryStreamBase.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CollapsibleSection } from "content-src/components/CollapsibleSection/Co
88
import { connect } from "react-redux";
99
import { DSMessage } from "content-src/components/DiscoveryStreamComponents/DSMessage/DSMessage";
1010
import { DSPrivacyModal } from "content-src/components/DiscoveryStreamComponents/DSPrivacyModal/DSPrivacyModal";
11+
import { ReportContent } from "../DiscoveryStreamComponents/ReportContent/ReportContent";
1112
import { DSSignup } from "content-src/components/DiscoveryStreamComponents/DSSignup/DSSignup";
1213
import { DSTextPromo } from "content-src/components/DiscoveryStreamComponents/DSTextPromo/DSTextPromo";
1314
import { Highlights } from "content-src/components/DiscoveryStreamComponents/Highlights/Highlights";
@@ -252,6 +253,8 @@ export class _DiscoveryStreamBase extends React.PureComponent {
252253
const { config } = this.props.DiscoveryStream;
253254
const topicSelectionEnabled =
254255
this.props.Prefs.values["discoverystream.topicSelection.enabled"];
256+
const reportContentEnabled =
257+
this.props.Prefs.values["discoverystream.reportContent.enabled"];
255258

256259
// Allow rendering without extracting special components
257260
if (!config.collapsible) {
@@ -322,6 +325,9 @@ export class _DiscoveryStreamBase extends React.PureComponent {
322325
{this.props.DiscoveryStream.isPrivacyInfoModalVisible && (
323326
<DSPrivacyModal dispatch={this.props.dispatch} />
324327
)}
328+
329+
{reportContentEnabled && <ReportContent />}
330+
325331
{topSites &&
326332
this.renderLayout([
327333
{

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/AdBanner/AdBanner.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export const AdBanner = ({
8989
spoc={spoc}
9090
position={row}
9191
type={type}
92+
prefs={prefs}
9293
/>
9394
<SafeAnchor
9495
className="ad-banner-link"

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/AdBannerContextMenu/AdBannerContextMenu.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ import { LinkMenu } from "../../LinkMenu/LinkMenu";
2020
* @returns {Element}
2121
* @constructor
2222
*/
23-
export function AdBannerContextMenu({ dispatch, spoc, position, type }) {
23+
export function AdBannerContextMenu({ dispatch, spoc, position, type, prefs }) {
24+
const PREF_REPORT_CONTENT_ENABLED = "discoverystream.reportContent.enabled";
25+
const showReporting = prefs[PREF_REPORT_CONTENT_ENABLED];
26+
2427
const ADBANNER_CONTEXT_MENU_OPTIONS = [
2528
"BlockAdUrl",
29+
...(showReporting ? ["ReportAd"] : []),
2630
"ManageSponsoredContent",
2731
"OurSponsorsAndYourPrivacy",
2832
];

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/DSLinkMenu/DSLinkMenu.jsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@ import { LinkMenu } from "content-src/components/LinkMenu/LinkMenu";
66
import { ContextMenuButton } from "content-src/components/ContextMenu/ContextMenuButton";
77
import { actionCreators as ac } from "common/Actions.mjs";
88
import React from "react";
9+
import { connect } from "react-redux";
910

10-
export class DSLinkMenu extends React.PureComponent {
11+
export class _DSLinkMenu extends React.PureComponent {
1112
render() {
1213
const { index, dispatch } = this.props;
1314
let TOP_STORIES_CONTEXT_MENU_OPTIONS;
15+
const PREF_REPORT_CONTENT_ENABLED = "discoverystream.reportContent.enabled";
16+
const prefs = this.props.Prefs.values;
17+
const showReporting = prefs[PREF_REPORT_CONTENT_ENABLED];
18+
const isSpoc = this.props.card_type === "spoc";
1419

15-
// Sponsored stories have their own context menu options.
16-
if (this.props.card_type === "spoc") {
20+
if (isSpoc) {
1721
TOP_STORIES_CONTEXT_MENU_OPTIONS = [
1822
"BlockUrl",
23+
...(showReporting ? ["ReportAd"] : []),
1924
"ManageSponsoredContent",
2025
"OurSponsorsAndYourPrivacy",
2126
];
22-
// Recommended stories have a different context menu.
2327
} else {
24-
// If Pocket is enabled, insert extra menu options after the bookmark.
2528
const saveToPocketOptions = this.props.pocket_button_enabled
2629
? ["CheckArchiveFromPocket", "CheckSavedToPocket"]
2730
: [];
2831

2932
TOP_STORIES_CONTEXT_MENU_OPTIONS = [
3033
"CheckBookmark",
34+
...(showReporting ? ["ReportContent"] : []),
3135
...saveToPocketOptions,
3236
"Separator",
3337
"OpenInNewWindow",
@@ -88,3 +92,7 @@ export class DSLinkMenu extends React.PureComponent {
8892
);
8993
}
9094
}
95+
96+
export const DSLinkMenu = connect(state => ({
97+
Prefs: state.Prefs,
98+
}))(_DSLinkMenu);

0 commit comments

Comments
 (0)