Skip to content

Commit

Permalink
Enable NTP Background customization if SuperReferral is not active
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Jan 31, 2023
1 parent 320de29 commit 7b797b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 5 additions & 1 deletion components/brave_new_tab_ui/containers/newTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ class NewTabPage extends React.Component<Props, State> {
showTopSites = this.props.gridSitesData.gridSites.length !== 0
}

// Allow background customization if Super Referrals is not activated.
const isSuperReferral = newTabData.brandedWallpaper && !newTabData.brandedWallpaper.isSponsored
const allowBackgroundCustomization = !isSuperReferral

if (forceToHideWidget) {
showTopSites = false
showStats = false
Expand Down Expand Up @@ -726,7 +730,7 @@ class NewTabPage extends React.Component<Props, State> {
showRewards={newTabData.showRewards}
braveRewardsSupported={newTabData.braveRewardsSupported}
brandedWallpaperOptIn={newTabData.brandedWallpaperOptIn}
allowSponsoredWallpaperUI={newTabData.featureFlagBraveNTPSponsoredImagesWallpaper}
allowBackgroundCustomization={allowBackgroundCustomization}
toggleShowRewards={this.toggleShowRewards}
braveTalkSupported={newTabData.braveTalkSupported}
toggleShowBraveTalk={this.toggleShowBraveTalk}
Expand Down
17 changes: 5 additions & 12 deletions components/brave_new_tab_ui/containers/newTab/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface Props {
showTopSites: boolean
customLinksEnabled: boolean
brandedWallpaperOptIn: boolean
allowSponsoredWallpaperUI: boolean
allowBackgroundCustomization: boolean
showRewards: boolean
showBraveTalk: boolean
braveRewardsSupported: boolean
Expand Down Expand Up @@ -163,7 +163,7 @@ export default class Settings extends React.PureComponent<Props, State> {
}

getInitialTab () {
let tab = this.props.allowSponsoredWallpaperUI
let tab = this.props.allowBackgroundCustomization
? TabType.BackgroundImage
: TabType.BraveStats
if (this.props.setActiveTab) {
Expand Down Expand Up @@ -196,17 +196,10 @@ export default class Settings extends React.PureComponent<Props, State> {
}

getActiveTabTypes (): TabType[] {
// TODO(petemill): We're not allowing
// any background image changes when user is not
// in a sponsored image region, which is weird.
// Seems like this should actually only be for
// super referral users, where the bg image is
// mandatory. Maybe that's the only case
// allowSponsoredWallpaperUI is false?
if (!this.props.allowSponsoredWallpaperUI) {
return this.allTabTypesWithoutBackground
} else {
if (this.props.allowBackgroundCustomization) {
return this.allTabTypes
} else {
return this.allTabTypesWithoutBackground
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/test/brave_new_tab_ui/components/settings_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('settings component tests', () => {
toggleShowRewards: () => undefined,
toggleBrandedWallpaperOptIn: () => undefined,
brandedWallpaperOptIn: false,
allowSponsoredWallpaperUI: false,
allowBackgroundCustomization: false,
showRewards: false
}

Expand All @@ -48,7 +48,7 @@ describe('settings component tests', () => {
toggleShowRewards={mockProps.toggleShowRewards}
toggleBrandedWallpaperOptIn={mockProps.toggleBrandedWallpaperOptIn}
brandedWallpaperOptIn={mockProps.brandedWallpaperOptIn}
allowSponsoredWallpaperUI={mockProps.allowSponsoredWallpaperUI}
allowBackgroundCustomization={mockProps.allowBackgroundCustomization}
showRewards={mockProps.showRewards}
/>)
expect(wrapper.find(SettingsMenu)).toHaveLength(0)
Expand All @@ -71,7 +71,7 @@ describe('settings component tests', () => {
toggleShowRewards={mockProps.toggleShowRewards}
toggleBrandedWallpaperOptIn={mockProps.toggleBrandedWallpaperOptIn}
brandedWallpaperOptIn={mockProps.brandedWallpaperOptIn}
allowSponsoredWallpaperUI={mockProps.allowSponsoredWallpaperUI}
allowBackgroundCustomization={mockProps.allowBackgroundCustomization}
showRewards={mockProps.showRewards}
/>)
expect(wrapper.find(SettingsMenu)).toHaveLength(1)
Expand Down

0 comments on commit 7b797b6

Please sign in to comment.