Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup post_title_language experiment (won) #3502

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 27 additions & 34 deletions packages/shared/src/components/filters/ContentTypesFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import {
import { Divider } from '../utilities';
import { LanguageDropdown } from '../profile/LanguageDropdown';
import { useAuthContext } from '../../contexts/AuthContext';
import { useFeature } from '../GrowthBookProvider';
import { feature } from '../../lib/featureManagement';
import { useLanguage } from '../../hooks/useLanguage';

export function ContentTypesFilter(): ReactElement {
const postTitleLanguageFeature = useFeature(feature.postTitleLanguage);
const { advancedSettings, isLoading } = useFeedSettings();
const { selectedSettings, onToggleSettings } = useAdvancedSettings();
const { user } = useAuthContext();
Expand All @@ -28,37 +25,33 @@ export function ContentTypesFilter(): ReactElement {

return (
<div className="flex flex-col gap-4">
{postTitleLanguageFeature && (
<>
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<Typography
tag={TypographyTag.H3}
color={TypographyColor.Primary}
type={TypographyType.Body}
bold
className="mb-1"
>
Preferred language
</Typography>
<Typography
color={TypographyColor.Tertiary}
type={TypographyType.Callout}
>
Choose your preferred language for the post titles on the feed
</Typography>
</div>
<LanguageDropdown
className={{ container: 'w-full max-w-60' }}
name="language"
defaultValue={user.language}
onChange={(value) => onLanguageChange(value)}
icon={null}
/>
</section>
<Divider className="bg-border-subtlest-tertiary" />
</>
)}
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<Typography
tag={TypographyTag.H3}
color={TypographyColor.Primary}
type={TypographyType.Body}
bold
className="mb-1"
>
Preferred language
</Typography>
<Typography
color={TypographyColor.Tertiary}
type={TypographyType.Callout}
>
Choose your preferred language for the post titles on the feed
</Typography>
</div>
<LanguageDropdown
className={{ container: 'w-full max-w-60' }}
name="language"
defaultValue={user.language}
onChange={(value) => onLanguageChange(value)}
icon={null}
/>
</section>
<Divider className="bg-border-subtlest-tertiary" />
<section className="flex flex-col gap-4" aria-busy={isLoading}>
<div className="flex flex-col">
<Typography
Expand Down
25 changes: 4 additions & 21 deletions packages/shared/src/components/filters/FeedFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ import { UnblockSourceCopy, UnblockTagCopy } from './UnblockCopy';
import { ContentTypesFilter } from './ContentTypesFilter';
import { Source } from '../../graphql/sources';
import { webappUrl } from '../../lib/constants';
import {
ViewSize,
useConditionalFeature,
useFeeds,
useViewSize,
} from '../../hooks';
import { feature } from '../../lib/featureManagement';
import { useAuthContext } from '../../contexts/AuthContext';
import { ViewSize, useFeeds, useViewSize } from '../../hooks';

enum FilterMenuTitle {
MyFeed = 'My feed',
Tags = 'Manage tags',
ManageCategories = 'Manage categories',
ContentTypes = 'Content types',
ContentTypes = 'Content & Language',
Blocked = 'Blocked items',
}

Expand All @@ -48,7 +41,6 @@ const unBlockPromptOptions: PromptOptions = {
};

export default function FeedFilters(props: FeedFiltersProps): ReactElement {
const { isLoggedIn } = useAuthContext();
const { showPrompt } = usePrompt();
const unBlockPrompt = async ({ action, source, tag }: UnblockItem) => {
const description = tag ? (
Expand All @@ -66,15 +58,6 @@ export default function FeedFilters(props: FeedFiltersProps): ReactElement {

const filtersTab = FilterMenuTitle.MyFeed;

const { value: postTitleLanguageFeature } = useConditionalFeature({
feature: feature.postTitleLanguage,
shouldEvaluate: isLoggedIn,
});

const contentTypesTab = postTitleLanguageFeature
? 'Content & Language'
: FilterMenuTitle.ContentTypes;

const tabs = [
{
title: filtersTab,
Expand Down Expand Up @@ -104,7 +87,7 @@ export default function FeedFilters(props: FeedFiltersProps): ReactElement {
options: { icon: <FilterIcon />, group: 'Preference' },
},
{
title: contentTypesTab,
title: FilterMenuTitle.ContentTypes,
options: { icon: <AppIcon />, group: 'Preference' },
},
{
Expand Down Expand Up @@ -145,7 +128,7 @@ export default function FeedFilters(props: FeedFiltersProps): ReactElement {
<Modal.Body view={FilterMenuTitle.ManageCategories}>
<AdvancedSettingsFilter />
</Modal.Body>
<Modal.Body view={contentTypesTab}>
<Modal.Body view={FilterMenuTitle.ContentTypes}>
<ContentTypesFilter />
</Modal.Body>
<Modal.Body view={FilterMenuTitle.Blocked}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Dropdown, DropdownClassName } from '../fields/Dropdown';
import { LanguageIcon } from '../icons';
import { BaseFieldProps } from '../fields/BaseFieldContainer';
import { ContentLanguage, contnetLanguageToLabelMap } from '../../lib/user';
import { withExperiment } from '../withExperiment';
import { feature } from '../../lib/featureManagement';
import { IconProps } from '../Icon';

type ClassName = {
Expand All @@ -22,7 +20,7 @@ type Props = {

const defaultIcon = <LanguageIcon className="ml-0 mr-1" />;

const LanguageDropdownDefault = ({
export const LanguageDropdown = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also see down the line (after some more adoption?) to make language required in registration flow on API? (not blocker for this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah correct indeed :) 🙏

className = {},
onChange,
hint = '',
Expand Down Expand Up @@ -108,8 +106,3 @@ const LanguageDropdownDefault = ({
</div>
);
};

export const LanguageDropdown = withExperiment(LanguageDropdownDefault, {
feature: feature.postTitleLanguage,
value: true,
});
1 change: 0 additions & 1 deletion packages/shared/src/lib/featureManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const feature = {
showRoadmap: new Feature('show_roadmap', true),
onboardingChecklist: new Feature('onboarding_checklist', true),
searchUsers: new Feature('search_users', false),
postTitleLanguage: new Feature('post_title_language', false),
};

export { feature };