Skip to content

Commit

Permalink
rm sponsored and verified categories (#13224)
Browse files Browse the repository at this point in the history
  • Loading branch information
eviljeff authored Sep 24, 2024
1 parent 5a8c257 commit 3b0580c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 166 deletions.
2 changes: 1 addition & 1 deletion src/amo/components/HeroRecommendation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class HeroRecommendationBase extends React.Component<InternalProps> {
// L10n: If uppercase does not work in your locale, change it to lowercase. This is used as a secondary heading.
titleText = i18n.gettext('BY FIREFOX');
} else {
titleText = i18n.gettext('SPONSORED');
titleText = i18n.gettext('PROMOTED');
}
}

Expand Down
10 changes: 2 additions & 8 deletions src/amo/components/IconPromotedBadge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@ import makeClassName from 'classnames';
import * as React from 'react';
import { compose } from 'redux';

import { LINE, RECOMMENDED, VERIFIED } from 'amo/constants';
import { LINE, RECOMMENDED } from 'amo/constants';
import translate from 'amo/i18n/translate';
import Icon from 'amo/components/Icon';
import type { I18nType } from 'amo/types/i18n';
import './styles.scss';

export type PromotedBadgeCategory =
| typeof LINE
| typeof RECOMMENDED
| typeof VERIFIED;
export type PromotedBadgeCategory = typeof LINE | typeof RECOMMENDED;

export type PromotedBadgeSize = 'large' | 'small';

export const paths = {
recommended:
'M15.449999809265137,3.999999523162842 H4.550000190734863 C4.25,3.999999523162842 4,4.219999313354492 4,4.499999523162842 V6.999999523162842 c0,1.100000023841858 0.9800000190734863,2 2.180000066757202,2 h0.05000000074505806 a3.6700000762939453,3.6700000762939453 0 0 0 3.2200000286102295,2.9600000381469727 V13.499999523162842 h1.100000023841858 V11.959999561309814 A3.6700000762939453,3.6700000762939453 0 0 0 13.770000457763672,8.999999523162842 h0.05000000074505806 C15.020000457763672,8.999999523162842 16,8.099998950958252 16,6.999999523162842 V4.499999523162842 c0,-0.2800000011920929 -0.23999999463558197,-0.5 -0.550000011920929,-0.5 zM5.099999904632568,6.999999523162842 V4.999999523162842 h1.100000023841858 v3 c-0.6100000143051147,0 -1.100000023841858,-0.44999998807907104 -1.100000023841858,-1 zm9.819999694824219,0 c0,0.550000011920929 -0.49000000953674316,1 -1.100000023841858,1 V4.999999523162842 h1.100000023841858 v2 zM11.100000381469727,13.999999523162842 H8.899999618530273 c-2.7200000286102295,0 -2.7200000286102295,2 -2.7200000286102295,2 h7.639999866485596 s0,-2 -2.7300000190734863,-2 z',
verified:
'M6 14a1 1 0 0 1-.707-.293l-3-3a1 1 0 0 1 1.414-1.414l2.157 2.157 6.316-9.023a1 1 0 0 1 1.639 1.146l-7 10a1 1 0 0 1-.732.427A.863.863 0 0 1 6 14z',
};

type Props = {|
Expand All @@ -45,7 +40,6 @@ export const IconPromotedBadgeBase = ({
const altTexts = {
line: i18n.gettext('By Firefox'),
recommended: i18n.gettext('Recommended'),
verified: i18n.gettext('Verified'),
};
const alt = altTexts[category];

Expand Down
17 changes: 1 addition & 16 deletions src/amo/components/IconPromotedBadge/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ $icon-promoted-small-size: 16px;
fill: $orange-50;
}

.IconPromotedBadge-circle-bgColor--verified {
fill: $green-70;
}

.IconPromotedBadge-iconPath {
transform-origin: 50% 50%;
}

.IconPromotedBadge-iconPath--recommended,
.IconPromotedBadge-iconPath--verified {
.IconPromotedBadge-iconPath--recommended {
fill: $white;
}

Expand All @@ -60,11 +55,6 @@ $icon-promoted-small-size: 16px;
// Nudge the trophy into the center of the circle.
transform: translate(2px, 2.5px) scale(1.1);
}

.IconPromotedBadge-iconPath--verified {
// Nudge the checkmark into the center of the circle.
transform: translate(4px, 4px) scale(1.1);
}
}

.IconPromotedBadge-small {
Expand All @@ -78,11 +68,6 @@ $icon-promoted-small-size: 16px;
transform: translate(-1.5px, -1.5px) scale(0.8);
}

.IconPromotedBadge-iconPath--verified {
// Nudge the checkmark into the center of the circle.
transform: translate(-0.5px, 0) scale(0.8);
}

&.Icon-line {
background-size: $icon-promoted-small-size - 2;
border: 1px solid $grey-30;
Expand Down
11 changes: 2 additions & 9 deletions src/amo/components/PromotedBadge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,13 @@ export const PromotedBadgeBase = ({
);
break;

case 'recommended':
// This is the recommended badge
default:
label = i18n.gettext('Recommended');
linkTitle = i18n.gettext(
'Firefox only recommends add-ons that meet our standards for security and performance.',
);
break;

// This is the verified badge.
default:
label = i18n.gettext('Verified');
linkTitle = i18n.gettext(
'This add-on has been reviewed to meet our standards for security and performance.',
);
break;
}

return (
Expand Down
31 changes: 0 additions & 31 deletions src/amo/components/PromotedBadge/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
color: $orange-50;
}

.PromotedBadge--verified {
color: $green-70;
}

.PromotedBadge-link {
align-items: center;
border-radius: 20px;
Expand Down Expand Up @@ -102,29 +98,6 @@
}
}

.PromotedBadge-link--verified {
border: 1px solid $green-70;

@include border-start(0);

&,
&:link,
&:visited {
color: $green-70;
}

&:active,
&:focus,
&:hover {
border-color: $green-80;
color: $green-80;

.IconPromotedBadge-circle-bgColor--verified {
fill: $green-80;
}
}
}

.PromotedBadge-label {
@include margin-start(6px);
@include margin-end(8px);
Expand All @@ -137,7 +110,3 @@
.PromotedBadge-label--recommended {
color: $orange-80;
}

.PromotedBadge-label--verified {
color: $green-80;
}
18 changes: 3 additions & 15 deletions src/amo/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,36 +324,24 @@ export const GET_FIREFOX_BANNER_UTM_CONTENT = 'banner-download-button';
// Promoted categories
export const LINE = 'line';
export const RECOMMENDED = 'recommended';
export const SPONSORED = 'sponsored';
export const SPOTLIGHT = 'spotlight';
export const STRATEGIC = 'strategic';
export const VERIFIED = 'verified';

export const ALL_PROMOTED_CATEGORIES = [
LINE,
RECOMMENDED,
SPONSORED,
SPOTLIGHT,
STRATEGIC,
VERIFIED,
];
export const BADGE_CATEGORIES = [LINE, RECOMMENDED, VERIFIED];
export const EXCLUDE_WARNING_CATEGORIES = [
LINE,
RECOMMENDED,
SPONSORED,
SPOTLIGHT,
VERIFIED,
];
export const BADGE_CATEGORIES = [LINE, RECOMMENDED];
export const EXCLUDE_WARNING_CATEGORIES = [LINE, RECOMMENDED, SPOTLIGHT];
export const REVIEWED_FILTER = 'badged';

export type PromotedCategoryType =
| typeof LINE
| typeof RECOMMENDED
| typeof SPONSORED
| typeof SPOTLIGHT
| typeof STRATEGIC
| typeof VERIFIED;
| typeof STRATEGIC;

export const APP_NAME = 'amo';
export const WEBPACK_ENTRYPOINT = APP_NAME;
Expand Down
14 changes: 2 additions & 12 deletions src/amo/utils/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
FATAL_INSTALL_ERROR,
FATAL_UNINSTALL_ERROR,
INSTALL_FAILED,
SPONSORED,
VERIFIED,
} from 'amo/constants';
import log from 'amo/logger';
import { getPreviewImage } from 'amo/imageUtils';
Expand Down Expand Up @@ -129,16 +127,8 @@ export const getPromotedCategory = ({
}

// Special logic if we're using the category for badging.
if (forBadging) {
// SPONSORED is badged as VERIFIED.
if (category === SPONSORED) {
category = VERIFIED;
}

// We only have badges for certain categories.
if (!BADGE_CATEGORIES.includes(category)) {
category = null;
}
if (forBadging && !BADGE_CATEGORIES.includes(category)) {
category = null;
}

return category;
Expand Down
48 changes: 20 additions & 28 deletions tests/unit/amo/components/TestIconPromotedBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,24 @@ describe(__filename, () => {
expect(root).toHaveClass(className);
});

it.each(['recommended', 'verified'])(
'adds the expected classes for category="%s"',
(category) => {
render({ category });

expect(screen.getByTagName('circle')).toHaveClass(
`IconPromotedBadge-circle-bgColor--${category}`,
);
expect(screen.getByTagName('path')).toHaveClass(
`IconPromotedBadge-iconPath--${category}`,
);
},
);
it('adds the expected classes for category="%s"', () => {
const category = 'recommended';
render({ category });

expect(screen.getByTagName('circle')).toHaveClass(
`IconPromotedBadge-circle-bgColor--${category}`,
);
expect(screen.getByTagName('path')).toHaveClass(
`IconPromotedBadge-iconPath--${category}`,
);
});

it.each(['recommended', 'verified'])(
'uses the expected path for category="%s"',
(category) => {
render({ category });
it('uses the expected path for category="%s"', () => {
const category = 'recommended';
render({ category });

expect(screen.getByTagName('path')).toHaveAttribute('d', paths[category]);
},
);
expect(screen.getByTagName('path')).toHaveAttribute('d', paths[category]);
});

it('adds a custom class', () => {
const className = 'MyCoolBadge';
Expand All @@ -55,7 +51,6 @@ describe(__filename, () => {
it.each([
['line', 'By Firefox'],
['recommended', 'Recommended'],
['verified', 'Verified'],
])(
'adds an alt property for category="%s" when showAlt is true',
(category, alt) => {
Expand All @@ -73,14 +68,11 @@ describe(__filename, () => {
expect(screen.queryByClassName('visually-hidden')).not.toBeInTheDocument();
});

it.each(['recommended', 'verified'])(
'sets the icon with category="%s" to inline content',
(category) => {
const { root } = render({ category });
it('sets the icon with category="recommended" to inline content', () => {
const { root } = render({ category: 'recommended' });

expect(root).toHaveClass('Icon-inline-content');
},
);
expect(root).toHaveClass('Icon-inline-content');
});

it('does not use inline-content but a real icon (image) for the category="line"', () => {
const { root } = render({ category: 'line' });
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/amo/pages/TestAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2930,11 +2930,6 @@ describe(__filename, () => {
'Firefox only recommends add-ons that meet our standards for security and performance.',
'Recommended',
],
[
'verified',
'This add-on has been reviewed to meet our standards for security and performance.',
'Verified',
],
])(
'renders the category "%s" as expected',
(category, linkTitle, label) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/amo/pages/TestAddonVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
INCOMPATIBLE_UNDER_MIN_VERSION,
INCOMPATIBLE_UNSUPPORTED_PLATFORM,
INSTALLING,
RECOMMENDED,
STRATEGIC,
VERIFIED,
} from 'amo/constants';
import { extractId } from 'amo/pages/AddonVersions';
import { formatFilesize } from 'amo/i18n/utils';
Expand Down Expand Up @@ -1050,7 +1050,7 @@ describe(__filename, () => {
addon: {
...fakeAddon,
slug: defaultSlug,
promoted: { category: VERIFIED, apps: [CLIENT_APP_FIREFOX] },
promoted: { category: RECOMMENDED, apps: [CLIENT_APP_FIREFOX] },
},
});

Expand Down
37 changes: 15 additions & 22 deletions tests/unit/amo/pages/TestHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ import {
LANDING_PAGE_THEME_COUNT,
LINE,
RECOMMENDED,
SPONSORED,
VIEW_CONTEXT_HOME,
VERIFIED,
} from 'amo/constants';
import {
FETCH_HOME_DATA,
Expand Down Expand Up @@ -652,9 +650,7 @@ describe(__filename, () => {
it.each([
[LINE, 'BY FIREFOX'],
[RECOMMENDED, 'RECOMMENDED'],
[SPONSORED, 'SPONSORED'],
[VERIFIED, 'SPONSORED'],
['unknown category', 'SPONSORED'],
['unknown category', 'PROMOTED'],
])('displays the expected title for %s add-ons', (category, title) => {
renderWithHomeData({
primaryProps: {
Expand All @@ -667,24 +663,21 @@ describe(__filename, () => {
);
});

it.each([SPONSORED, VERIFIED, 'unknown category'])(
'displays an additional link for %s add-ons',
(category) => {
renderWithHomeData({
primaryProps: {
addon: addonForPromotedCategory(category),
},
});
it('displays an additional link for %s add-ons', () => {
renderWithHomeData({
primaryProps: {
addon: addonForPromotedCategory('unknown category'),
},
});

expect(
screen.getByRole('link', {
name:
`Firefox only recommends extensions that meet our ` +
`standards for security and performance.`,
}),
).toBeInTheDocument();
},
);
expect(
screen.getByRole('link', {
name:
`Firefox only recommends extensions that meet our ` +
`standards for security and performance.`,
}),
).toBeInTheDocument();
});

it('does not display an additional link when loading', () => {
render();
Expand Down
Loading

0 comments on commit 3b0580c

Please sign in to comment.