Skip to content

Commit

Permalink
Site Settings: Disable Photon when in Dev mode (#11783)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Mar 8, 2017
1 parent ca75f7c commit 92c1cf8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions client/my-sites/site-settings/media-settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import FormLabel from 'components/forms/form-label';
import FormToggle from 'components/forms/form-toggle';
import InfoPopover from 'components/info-popover';
import ExternalLink from 'components/external-link';
import { isJetpackModuleActive } from 'state/selectors';
import {
isJetpackModuleActive,
isJetpackModuleUnavailableInDevelopmentMode,
isJetpackSiteInDevelopmentMode
} from 'state/selectors';
import { getSelectedSiteId } from 'state/ui/selectors';
import { updateSettings } from 'state/jetpack/settings/actions';
import QueryJetpackConnection from 'components/data/query-jetpack-connection';

const MediaSettings = ( {
fields,
Expand All @@ -28,12 +33,16 @@ const MediaSettings = ( {
isSavingSettings,
siteId,
carouselActive,
photonModuleUnavailable,
selectedSiteId,
translate
} ) => {
const labelClassName = isSavingSettings || ! carouselActive ? 'is-disabled' : null;

return (
<Card className="media-settings site-settings site-settings__module-settings">
<QueryJetpackConnection siteId={ selectedSiteId } />

<FormFieldset>
<div className="media-settings__info-link-container site-settings__info-link-container">
<InfoPopover position={ 'left' }>
Expand All @@ -47,7 +56,7 @@ const MediaSettings = ( {
moduleSlug="photon"
label={ translate( 'Speed up your images and photos with Photon.' ) }
description="Enabling Photon is required to use Tiled Galleries."
disabled={ isRequestingSettings || isSavingSettings }
disabled={ isRequestingSettings || isSavingSettings || photonModuleUnavailable }
/>
</FormFieldset>
<FormFieldset className="media-settings__formfieldset has-divider is-top-only">
Expand Down Expand Up @@ -107,8 +116,13 @@ MediaSettings.propTypes = {
export default connect(
( state ) => {
const selectedSiteId = getSelectedSiteId( state );
const siteInDevMode = isJetpackSiteInDevelopmentMode( state, selectedSiteId );
const moduleUnavailableInDevMode = isJetpackModuleUnavailableInDevelopmentMode( state, selectedSiteId, 'photon' );

return {
carouselActive: !! isJetpackModuleActive( state, selectedSiteId, 'carousel' )
selectedSiteId,
carouselActive: !! isJetpackModuleActive( state, selectedSiteId, 'carousel' ),
photonModuleUnavailable: siteInDevMode && moduleUnavailableInDevMode,
};
},
{
Expand Down

0 comments on commit 92c1cf8

Please sign in to comment.