Skip to content

Commit

Permalink
Settings: Removing disabled CSS from active controls
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz-cp committed Oct 1, 2024
1 parent 242d276 commit 2337c4f
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 101 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fixed
Comment: Remove disabled visuals from controls that are active.


14 changes: 2 additions & 12 deletions projects/plugins/jetpack/_inc/client/newsletter/email-settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import TextInput from 'components/text-input';
import analytics from 'lib/analytics';
import { useCallback, useState } from 'react';
import { connect } from 'react-redux';
import { isUnavailableInOfflineMode, isUnavailableInSiteConnectionMode } from 'state/connection';
import { isUnavailableInOfflineMode } from 'state/connection';
import {
getSiteTitle,
getUserGravatar,
Expand Down Expand Up @@ -58,7 +58,6 @@ const EmailSettings = props => {
subscriptionReplyTo,
subscriptionFromName,
updateFormStateAndSaveOptionValue,
unavailableInSiteConnectionMode,
gravatar,
email,
adminUrl,
Expand All @@ -67,8 +66,7 @@ const EmailSettings = props => {
siteName,
} = props;

const disabled =
! isSubscriptionsActive || unavailableInOfflineMode || unavailableInSiteConnectionMode;
const disabled = ! isSubscriptionsActive || unavailableInOfflineMode;
const gravatarInputDisabled = disabled || isSavingAnyOption( [ GRAVATER_OPTION ] );
const authorInputDisabled = disabled || isSavingAnyOption( [ AUTHOR_OPTION ] );
const postDateInputDisabled = disabled || isSavingAnyOption( [ POST_DATE_OPTION ] );
Expand Down Expand Up @@ -185,7 +183,6 @@ const EmailSettings = props => {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
support={ {
link: featuredImageInEmailSupportUrl,
Expand All @@ -210,7 +207,6 @@ const EmailSettings = props => {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
className="newsletter-group"
>
Expand Down Expand Up @@ -319,7 +315,6 @@ const EmailSettings = props => {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
support={ {
link: subscriptionsAndNewslettersSupportUrl,
Expand Down Expand Up @@ -357,7 +352,6 @@ const EmailSettings = props => {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
className="newsletter-group"
support={ {
Expand Down Expand Up @@ -475,10 +469,6 @@ export default withModuleSettingsFormHelpers(
subscriptionFromName: ownProps.getOptionValue( FROM_NAME_OPTION ),
dateExample: getNewsetterDateExample( state ),
unavailableInOfflineMode: isUnavailableInOfflineMode( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
};
} )( EmailSettings )
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { FormLabel } from 'components/forms';
import { withModuleSettingsFormHelpers } from 'components/module-settings/with-module-settings-form-helpers';
import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';
import React, { useCallback } from 'react';
import { useCallback } from 'react';
import { connect } from 'react-redux';
import { isUnavailableInOfflineMode, isUnavailableInSiteConnectionMode } from 'state/connection';
import { isUnavailableInOfflineMode } from 'state/connection';
import { getModule } from 'state/modules';
import Textarea from '../components/textarea';
import { SUBSCRIPTIONS_MODULE_NAME } from './constants';
Expand All @@ -20,7 +20,6 @@ const MessagesSetting = props => {
onOptionChange,
welcomeMessage,
unavailableInOfflineMode,
unavailableInSiteConnectionMode,
} = props;

const changeWelcomeMessageState = useCallback(
Expand All @@ -34,11 +33,7 @@ const MessagesSetting = props => {
);

const isSaving = isSavingAnyOption( [ SUBSCRIPTION_OPTIONS ] );
const disabled =
! isSubscriptionsActive ||
unavailableInOfflineMode ||
unavailableInSiteConnectionMode ||
isSaving;
const disabled = ! isSubscriptionsActive || unavailableInOfflineMode || isSaving;

return (
<SettingsCard
Expand All @@ -48,12 +43,7 @@ const MessagesSetting = props => {
saveDisabled={ isSaving }
isDisabled={ disabled }
>
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
>
<SettingsGroup hasChild disableInOfflineMode module={ subscriptionsModule }>
<p className="jp-settings-card__email-settings">
{ __(
'These settings change the emails sent from your site to your readers.',
Expand Down Expand Up @@ -92,10 +82,6 @@ export default withModuleSettingsFormHelpers(
onOptionChange: ownProps.onOptionChange,
welcomeMessage: ownProps.getOptionValue( SUBSCRIPTION_OPTIONS )?.welcome || '',
unavailableInOfflineMode: isUnavailableInOfflineMode( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
};
} )( MessagesSetting )
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';
import React, { useCallback, useMemo } from 'react';
import { connect } from 'react-redux';
import {
isUnavailableInOfflineMode,
isUnavailableInSiteConnectionMode,
requiresConnection,
} from 'state/connection';
import { isUnavailableInOfflineMode, requiresConnection } from 'state/connection';
import { getModule } from 'state/modules';
import Card from '../components/card';
import { withModuleSettingsFormHelpers } from '../components/module-settings/with-module-settings-form-helpers';
Expand Down Expand Up @@ -44,7 +40,6 @@ function NewsletterCategories( props ) {
newsletterCategories,
categories,
unavailableInOfflineMode,
unavailableInSiteConnectionMode,
subscriptionsModule,
updateFormStateOptionValue,
isSavingAnyOption,
Expand Down Expand Up @@ -85,11 +80,7 @@ function NewsletterCategories( props ) {
NEWSLETTER_CATEGORIES_ENABLED_OPTION,
NEWSLETTER_CATEGORIES_OPTION,
] );
const disabled =
! isSubscriptionsActive ||
unavailableInOfflineMode ||
unavailableInSiteConnectionMode ||
isSaving;
const disabled = ! isSubscriptionsActive || unavailableInOfflineMode || isSaving;

return (
<SettingsCard
Expand All @@ -102,7 +93,6 @@ function NewsletterCategories( props ) {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
support={ {
text: __(
Expand Down Expand Up @@ -173,10 +163,6 @@ export default withModuleSettingsFormHelpers(
categories: ownProps.getOptionValue( 'categories' ),
requiresConnection: requiresConnection( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInOfflineMode: isUnavailableInOfflineMode( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
};
} )( NewsletterCategories )
);
15 changes: 2 additions & 13 deletions projects/plugins/jetpack/_inc/client/newsletter/newsletter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import SettingsGroup from 'components/settings-group';
import analytics from 'lib/analytics';
import React from 'react';
import { connect } from 'react-redux';
import {
isCurrentUserLinked,
isUnavailableInOfflineMode,
isOfflineMode,
isUnavailableInSiteConnectionMode,
} from 'state/connection';
import { isCurrentUserLinked, isUnavailableInOfflineMode, isOfflineMode } from 'state/connection';
import { getModule } from 'state/modules';
import { SUBSCRIPTIONS_MODULE_NAME } from './constants';

Expand All @@ -38,7 +33,6 @@ function Newsletter( props ) {
isOffline,
isSubscriptionsActive,
unavailableInOfflineMode,
unavailableInSiteConnectionMode,
subscriptions,
} = props;

Expand Down Expand Up @@ -73,7 +67,6 @@ function Newsletter( props ) {
<SettingsGroup
hasChild
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptions }
support={ {
text: __(
Expand All @@ -85,7 +78,7 @@ function Newsletter( props ) {
>
<ModuleToggle
slug="subscriptions"
disabled={ unavailableInOfflineMode || unavailableInSiteConnectionMode }
disabled={ unavailableInOfflineMode }
activated={ isSubscriptionsActive }
toggling={ isSavingAnyOption( SUBSCRIPTIONS_MODULE_NAME ) }
toggleModule={ toggleModuleNow }
Expand Down Expand Up @@ -119,10 +112,6 @@ export default withModuleSettingsFormHelpers(
isOffline: isOfflineMode( state ),
isSubscriptionsActive: ownProps.getOptionValue( SUBSCRIPTIONS_MODULE_NAME ),
unavailableInOfflineMode: isUnavailableInOfflineMode( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
subscriptions: getModule( state, SUBSCRIPTIONS_MODULE_NAME ),
};
} )( Newsletter )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SettingsGroup from 'components/settings-group';
import analytics from 'lib/analytics';
import React, { useCallback } from 'react';
import { connect } from 'react-redux';
import { isUnavailableInSiteConnectionMode, isOfflineMode } from 'state/connection';
import { isOfflineMode } from 'state/connection';
import { getJetpackCloudUrl } from 'state/initial-state';
import { getModule } from 'state/modules';
import { SUBSCRIPTIONS_MODULE_NAME } from './constants';
Expand All @@ -18,27 +18,17 @@ import { SUBSCRIPTIONS_MODULE_NAME } from './constants';
* @return {React.Component} Paid Newsletter component.
*/
function PaidNewsletter( props ) {
const {
isSubscriptionsActive,
setupPaymentPlansUrl,
subscriptionsModule,
unavailableInSiteConnectionMode,
} = props;
const { isSubscriptionsActive, setupPaymentPlansUrl, subscriptionsModule } = props;

const setupPaymentPlansButtonDisabled =
! isSubscriptionsActive || unavailableInSiteConnectionMode;
const setupPaymentPlansButtonDisabled = ! isSubscriptionsActive;

const trackSetupPaymentPlansButtonClick = useCallback( () => {
analytics.tracks.recordJetpackClick( 'newsletter_settings_setup_payment_plans_button_click' );
}, [] );

return (
<SettingsCard { ...props } header={ __( 'Paid Newsletter', 'jetpack' ) } hideButton>
<SettingsGroup
disableInOfflineMode
disableInSiteConnectionMode
module={ subscriptionsModule }
>
<SettingsGroup disableInOfflineMode module={ subscriptionsModule }>
<p className="jp-settings-card__email-settings">
{ __(
'Earn money through your Newsletter. Reward your most loyal subscribers with exclusive content or add a paywall to monetize content.',
Expand Down Expand Up @@ -67,10 +57,6 @@ export default withModuleSettingsFormHelpers(
setupPaymentPlansUrl: getJetpackCloudUrl( state, 'monetize/payments' ),
subscriptionsModule: getModule( state, SUBSCRIPTIONS_MODULE_NAME ),
isOffline: isOfflineMode( state ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
};
} )( PaidNewsletter )
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';
import React, { useCallback } from 'react';
import { connect } from 'react-redux';
import {
isCurrentUserLinked,
isUnavailableInOfflineMode,
isOfflineMode,
isUnavailableInSiteConnectionMode,
} from 'state/connection';
import { isCurrentUserLinked, isUnavailableInOfflineMode, isOfflineMode } from 'state/connection';
import {
currentThemeIsBlockTheme,
currentThemeStylesheet,
Expand All @@ -32,7 +27,6 @@ import { SUBSCRIPTIONS_MODULE_NAME } from './constants';
function SubscriptionsSettings( props ) {
const {
unavailableInOfflineMode,
unavailableInSiteConnectionMode,
isSavingAnyOption,
isStbEnabled,
isStcEnabled,
Expand Down Expand Up @@ -119,8 +113,7 @@ function SubscriptionsSettings( props ) {
);
}, [ updateFormStateModuleOption ] );

const isDisabled =
! isSubscriptionsActive || unavailableInOfflineMode || unavailableInSiteConnectionMode;
const isDisabled = ! isSubscriptionsActive || unavailableInOfflineMode;

return (
<SettingsCard
Expand All @@ -129,7 +122,7 @@ function SubscriptionsSettings( props ) {
module={ SUBSCRIPTIONS_MODULE_NAME }
header={ __( 'Subscriptions', 'jetpack' ) }
>
<SettingsGroup disableInOfflineMode disableInSiteConnectionMode module={ subscriptions }>
<SettingsGroup disableInOfflineMode module={ subscriptions }>
<p>
{ __(
'Automatically add subscription forms to your site and turn visitors into subscribers.',
Expand Down Expand Up @@ -282,10 +275,6 @@ export default withModuleSettingsFormHelpers(
isOffline: isOfflineMode( state ),
isSubscriptionsActive: ownProps.getOptionValue( SUBSCRIPTIONS_MODULE_NAME ),
unavailableInOfflineMode: isUnavailableInOfflineMode( state, SUBSCRIPTIONS_MODULE_NAME ),
unavailableInSiteConnectionMode: isUnavailableInSiteConnectionMode(
state,
SUBSCRIPTIONS_MODULE_NAME
),
subscriptions: getModule( state, SUBSCRIPTIONS_MODULE_NAME ),
isStbEnabled: ownProps.getOptionValue( 'stb_enabled' ),
isStcEnabled: ownProps.getOptionValue( 'stc_enabled' ),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Remove disabled visuals from controls that are active.


0 comments on commit 2337c4f

Please sign in to comment.