0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Cleaned up hasPortalImprovements GA feature flag (#20548)

no issue

- the feature has been GA for a long time now so the conditionals are no longer required
This commit is contained in:
Kevin Ansfield 2024-07-04 17:21:48 +01:00 committed by GitHub
parent 3b87c9be53
commit 191a301242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 23 deletions

View file

@ -1,5 +1,4 @@
import React, {useCallback, useEffect, useMemo} from 'react'; import React, {useCallback, useEffect, useMemo} from 'react';
import useFeatureFlag from '../../../../hooks/useFeatureFlag';
import {CheckboxGroup, CheckboxProps, Form, HtmlField, Select, SelectOption, Toggle} from '@tryghost/admin-x-design-system'; import {CheckboxGroup, CheckboxProps, Form, HtmlField, Select, SelectOption, Toggle} from '@tryghost/admin-x-design-system';
import {Setting, SettingValue, checkStripeEnabled, getSettingValues} from '@tryghost/admin-x-framework/api/settings'; import {Setting, SettingValue, checkStripeEnabled, getSettingValues} from '@tryghost/admin-x-framework/api/settings';
import {Tier, getPaidActiveTiers} from '@tryghost/admin-x-framework/api/tiers'; import {Tier, getPaidActiveTiers} from '@tryghost/admin-x-framework/api/tiers';
@ -14,7 +13,6 @@ const SignupOptions: React.FC<{
setError: (key: string, error: string | undefined) => void setError: (key: string, error: string | undefined) => void
}> = ({localSettings, updateSetting, localTiers, updateTier, errors, setError}) => { }> = ({localSettings, updateSetting, localTiers, updateTier, errors, setError}) => {
const {config} = useGlobalData(); const {config} = useGlobalData();
const hasPortalImprovements = useFeatureFlag('portalImprovements');
const [membersSignupAccess, portalName, portalSignupTermsHtml, portalSignupCheckboxRequired, portalPlansJson, portalDefaultPlan] = getSettingValues( const [membersSignupAccess, portalName, portalSignupTermsHtml, portalSignupCheckboxRequired, portalPlansJson, portalDefaultPlan] = getSettingValues(
localSettings, ['members_signup_access', 'portal_name', 'portal_signup_terms_html', 'portal_signup_checkbox_required', 'portal_plans', 'portal_default_plan'] localSettings, ['members_signup_access', 'portal_name', 'portal_signup_terms_html', 'portal_signup_checkbox_required', 'portal_plans', 'portal_default_plan']
); );
@ -52,16 +50,14 @@ const SignupOptions: React.FC<{
updateSetting('portal_plans', JSON.stringify(portalPlans)); updateSetting('portal_plans', JSON.stringify(portalPlans));
// Check default plan is included // Check default plan is included
if (hasPortalImprovements) { if (portalDefaultPlan === 'yearly') {
if (portalDefaultPlan === 'yearly') { if (!portalPlans.includes('yearly') && portalPlans.includes('monthly')) {
if (!portalPlans.includes('yearly') && portalPlans.includes('monthly')) { updateSetting('portal_default_plan', 'monthly');
updateSetting('portal_default_plan', 'monthly'); }
} } else if (portalDefaultPlan === 'monthly') {
} else if (portalDefaultPlan === 'monthly') { if (!portalPlans.includes('monthly')) {
if (!portalPlans.includes('monthly')) { // If both yearly and monthly are missing from plans, still set it to yearly
// If both yearly and monthly are missing from plans, still set it to yearly updateSetting('portal_default_plan', 'yearly');
updateSetting('portal_default_plan', 'yearly');
}
} }
} }
}; };
@ -79,7 +75,7 @@ const SignupOptions: React.FC<{
tiersCheckboxes.push({ tiersCheckboxes.push({
checked: (portalPlans.includes('free')), checked: (portalPlans.includes('free')),
disabled: isDisabled, disabled: isDisabled,
label: hasPortalImprovements ? tier.name : 'Free', label: tier.name,
value: 'free', value: 'free',
onChange: (checked) => { onChange: (checked) => {
if (portalPlans.includes('free') && !checked) { if (portalPlans.includes('free') && !checked) {
@ -158,7 +154,7 @@ const SignupOptions: React.FC<{
]} ]}
title='Prices available at signup' title='Prices available at signup'
/> />
{(hasPortalImprovements && portalPlans.includes('yearly') && portalPlans.includes('monthly')) && {(portalPlans.includes('yearly') && portalPlans.includes('monthly')) &&
<Select <Select
options={defaultPlanOptions} options={defaultPlanOptions}
selectedOption={defaultPlanOptions.find(option => option.value === portalDefaultPlan)} selectedOption={defaultPlanOptions.find(option => option.value === portalDefaultPlan)}

View file

@ -1,7 +1,6 @@
import NiceModal from '@ebay/nice-modal-react'; import NiceModal from '@ebay/nice-modal-react';
import React, {useEffect, useRef} from 'react'; import React, {useEffect, useRef} from 'react';
import TierDetailPreview from './TierDetailPreview'; import TierDetailPreview from './TierDetailPreview';
import useFeatureFlag from '../../../../hooks/useFeatureFlag';
import useSettingGroup from '../../../../hooks/useSettingGroup'; import useSettingGroup from '../../../../hooks/useSettingGroup';
import {Button, ButtonProps, ConfirmationModal, CurrencyField, Form, Heading, Icon, Modal, Select, SortableList, TextField, Toggle, URLTextField, showToast, useSortableIndexedList} from '@tryghost/admin-x-design-system'; import {Button, ButtonProps, ConfirmationModal, CurrencyField, Form, Heading, Icon, Modal, Select, SortableList, TextField, Toggle, URLTextField, showToast, useSortableIndexedList} from '@tryghost/admin-x-design-system';
import {ErrorMessages, useForm, useHandleError} from '@tryghost/admin-x-framework/hooks'; import {ErrorMessages, useForm, useHandleError} from '@tryghost/admin-x-framework/hooks';
@ -25,8 +24,6 @@ const TierDetailModalContent: React.FC<{tier?: Tier}> = ({tier}) => {
const handleError = useHandleError(); const handleError = useHandleError();
const {localSettings, siteData} = useSettingGroup(); const {localSettings, siteData} = useSettingGroup();
const [portalPlansJson] = getSettingValues(localSettings, ['portal_plans']) as string[]; const [portalPlansJson] = getSettingValues(localSettings, ['portal_plans']) as string[];
const hasPortalImprovements = useFeatureFlag('portalImprovements');
const allowNameChange = !isFreeTier || hasPortalImprovements;
const portalPlans = JSON.parse(portalPlansJson?.toString() || '[]') as string[]; const portalPlans = JSON.parse(portalPlansJson?.toString() || '[]') as string[];
const validators: {[key in keyof Tier]?: () => string | undefined} = { const validators: {[key in keyof Tier]?: () => string | undefined} = {
@ -70,7 +67,7 @@ const TierDetailModalContent: React.FC<{tier?: Tier}> = ({tier}) => {
} else { } else {
await createTier(values); await createTier(values);
} }
if (isFreeTier && hasPortalImprovements) { if (isFreeTier) {
// If we changed the visibility, we also need to update Portal settings in some situations // If we changed the visibility, we also need to update Portal settings in some situations
// Like the free tier is a special case, and should also be present/absent in portal_plans // Like the free tier is a special case, and should also be present/absent in portal_plans
const visible = formState.visibility === 'public'; const visible = formState.visibility === 'public';
@ -196,7 +193,7 @@ const TierDetailModalContent: React.FC<{tier?: Tier}> = ({tier}) => {
<div className='-mb-8 mt-8 flex items-start gap-8'> <div className='-mb-8 mt-8 flex items-start gap-8'>
<div className='flex grow flex-col gap-8'> <div className='flex grow flex-col gap-8'>
<Form marginBottom={false} title='Basic' grouped> <Form marginBottom={false} title='Basic' grouped>
{allowNameChange && <TextField <TextField
autoComplete='off' autoComplete='off'
error={Boolean(errors.name)} error={Boolean(errors.name)}
hint={errors.name} hint={errors.name}
@ -207,7 +204,7 @@ const TierDetailModalContent: React.FC<{tier?: Tier}> = ({tier}) => {
autoFocus autoFocus
onChange={e => updateForm(state => ({...state, name: e.target.value}))} onChange={e => updateForm(state => ({...state, name: e.target.value}))}
onKeyDown={() => clearError('name')} onKeyDown={() => clearError('name')}
/>} />
<TextField <TextField
autoComplete='off' autoComplete='off'
autoFocus={isFreeTier} autoFocus={isFreeTier}

View file

@ -78,7 +78,6 @@ export default class FeatureService extends Service {
@feature('lexicalIndicators') lexicalIndicators; @feature('lexicalIndicators') lexicalIndicators;
@feature('filterEmailDisabled') filterEmailDisabled; @feature('filterEmailDisabled') filterEmailDisabled;
@feature('adminXDemo') adminXDemo; @feature('adminXDemo') adminXDemo;
@feature('portalImprovements') portalImprovements;
@feature('ActivityPub') ActivityPub; @feature('ActivityPub') ActivityPub;
@feature('internalLinking') internalLinking; @feature('internalLinking') internalLinking;
@feature('editorExcerpt') editorExcerpt; @feature('editorExcerpt') editorExcerpt;

View file

@ -24,7 +24,6 @@ const GA_FEATURES = [
'listUnsubscribeHeader', 'listUnsubscribeHeader',
'filterEmailDisabled', 'filterEmailDisabled',
'newEmailAddresses', 'newEmailAddresses',
'portalImprovements',
'internalLinking' 'internalLinking'
]; ];

View file

@ -1155,7 +1155,7 @@ exports[`Settings API Edit Can edit a setting 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "4587", "content-length": "4559",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,