Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into infrastructure/848…
Browse files Browse the repository at this point in the history
…3-reference-date-eslint-rule.
  • Loading branch information
eugene-manuilov committed Jun 18, 2024
2 parents 60b70a7 + 721401e commit b10a787
Show file tree
Hide file tree
Showing 67 changed files with 1,356 additions and 81 deletions.
44 changes: 44 additions & 0 deletions assets/js/event-providers/ninja-forms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Site Kit by Google, Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

( ( jQuery ) => {
// eslint-disable-next-line no-undef
if ( ! jQuery || ! Marionette || ! Backbone ) {
return;
}

// eslint-disable-next-line no-undef
const ninjaFormEventController = Marionette.Object.extend( {
initialize() {
this.listenTo(
// eslint-disable-next-line no-undef
Backbone.Radio.channel( 'forms' ),
'submit:response',
this.actionSubmit
);
},

actionSubmit( response ) {
global._googlesitekit?.gtagEvent?.( 'submit_lead_form', {
event_category: response.data.form_id,
} );
},
} );

jQuery( document ).ready( function () {
new ninjaFormEventController();
} );
} )( global.jQuery );
6 changes: 3 additions & 3 deletions assets/js/googlesitekit/data/create-settings-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ROLLBACK_SETTINGS = 'ROLLBACK_SETTINGS';
* while the fourth defines the names of the sub-settings to support.
*
* @since 1.6.0
* @since n.e.x.t Added haveSettingsChanged optional paramter.
* @since 1.129.0 Added haveSettingsChanged optional paramter.
* @private
*
* @param {string} type The data to access. One of 'core' or 'modules'.
Expand Down Expand Up @@ -283,7 +283,7 @@ export const createSettingsStore = (
*
* @since 1.6.0
* @since 1.77.0 Added ability to filter settings using `keys` argument.
* @since n.e.x.t Changed the approach to use validateHaveSettingsChanged callback.
* @since 1.129.0 Changed the approach to use validateHaveSettingsChanged callback.
*
* @param {Object} state Data store's state.
* @param {Array|null} keys Settings keys to check; if not provided, all settings are checked.
Expand Down Expand Up @@ -500,7 +500,7 @@ export function makeDefaultCanSubmitChanges( storeName ) {
/**
* Creates Default haveSettingsChanged.
*
* @since n.e.x.t
* @since 1.129.0
*
* @return {boolean} True if the settings have changed, false otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const baseActions = {
/**
* Returns the current settings back to the current saved values.
*
* @since n.e.x.t
* @since 1.129.0
* @private
*
* @return {Object} Redux-style action.
Expand Down
11 changes: 8 additions & 3 deletions assets/js/modules/ads/datastore/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ export async function submitChanges( { select, dispatch } ) {

export function validateCanSubmitChanges( select ) {
const strictSelect = createStrictSelect( select );
const { isDoingSubmitChanges, haveSettingsChanged, getConversionID } =
strictSelect( MODULES_ADS );
const {
isDoingSubmitChanges,
haveSettingsChanged,
getConversionID,
getPaxConversionID,
} = strictSelect( MODULES_ADS );

invariant( ! isDoingSubmitChanges(), INVARIANT_DOING_SUBMIT_CHANGES );
invariant( haveSettingsChanged(), INVARIANT_SETTINGS_NOT_CHANGED );

invariant(
isValidConversionID( getConversionID() ),
isValidConversionID( getConversionID() ) ||
isValidConversionID( getPaxConversionID() ),
INVARIANT_INVALID_CONVERSION_ID
);
}
Expand Down
1 change: 1 addition & 0 deletions assets/js/modules/ads/datastore/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe( 'modules/ads settings', () => {
it( 'should throw if the given conversion ID is invalid', () => {
registry.dispatch( MODULES_ADS ).receiveGetSettings( {
conversionID: '12345',
paxConversionID: '',
} );

registry.dispatch( MODULES_ADS ).setConversionID( 'invalid' );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/modules/ads/pax/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { PAX_GLOBAL_CONFIG } from './constants';
/**
* Creates PAX configuration.
*
* @since n.e.x.t
* @since 1.129.0
*
* @param {Object} options Optional.
* @param {string} options.contentContainer Optional. The container selector to launch the Ads app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export default function AdBlockingRecoverySetupCTANotice() {
<SupportLink
path="/adsense/answer/11576589"
external
hideExternalIndicator
onClick={ handleLearnMoreClick }
/>
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* AudienceTileCollectingData component.
*
* Site Kit by Google, Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import AudienceTileCollectingDataImage from '../../../../../../../svg/graphics/audience-segmentation-collecting-data.svg';

export default function AudienceTileCollectingData() {
return (
<Fragment>
<AudienceTileCollectingDataImage className="googlesitekit-audience-segmentation-tile__zero-data-image" />
<p className="googlesitekit-audience-segmentation-tile__zero-data-description">
{ __(
'Site Kit is collecting data for this group.',
'google-site-kit'
) }
</p>
</Fragment>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* AudienceTileCollectingDataHideable component.
*
* Site Kit by Google, Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* External dependencies
*/
import PropTypes from 'prop-types';

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import Link from '../../../../../../components/Link';
import VisibilityIcon from '../../../../../../../svg/icons/visibility.svg';

export default function AudienceTileCollectingDataHideable( { onHideTile } ) {
return (
<Fragment>
<p className="googlesitekit-audience-segmentation-tile__zero-data-description">
{ __(
'You can hide this group until data is available.',
'google-site-kit'
) }
</p>
<Link
secondary
linkButton
className="googlesitekit-audience-segmentation-tile-hide-cta"
onClick={ onHideTile }
leadingIcon={ <VisibilityIcon width={ 22 } height={ 22 } /> }
>
{ __( 'Temporarily hide', 'google-site-kit' ) }
</Link>
</Fragment>
);
}

AudienceTileCollectingDataHideable.propTypes = {
onHideTile: PropTypes.func.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import InfoTooltip from '../../../../../../components/InfoTooltip';
import PartialDataBadge from '../PartialDataBadge';
import PartialDataNotice from '../PartialDataNotice';
import { numFmt } from '../../../../../../util';
import AudienceTileCollectingData from './AudienceTileCollectingData';
import AudienceTileCollectingDataHideable from './AudienceTileCollectingDataHideable';
const { useSelect } = Data;

// TODO: as part of #8484 the report props should be updated to expect
Expand All @@ -71,6 +73,10 @@ export default function AudienceTile( {
topContentTitles,
Widget,
audienceResourceName,
isZeroData,
isPartialData,
isTileHideable,
onHideTile,
} ) {
const breakpoint = useBreakpoint();

Expand Down Expand Up @@ -103,8 +109,40 @@ export default function AudienceTile( {
);

// TODO: Loading states will be implemented as part of https://github.com/google/site-kit-wp/issues/8145.
if ( ! loaded ) {
return <PreviewBlock width="100%" height="500px" />;
if ( ! loaded || isZeroData === undefined || isPartialData === undefined ) {
return <PreviewBlock width="100%" height="600px" />;
}

if ( isPartialData && isZeroData ) {
return (
<Widget noPadding>
<div className="googlesitekit-audience-segmentation-tile">
<div className="googlesitekit-audience-segmentation-tile__zero-data-container">
{ ! isMobileBreakpoint && (
<div className="googlesitekit-audience-segmentation-tile__header">
<div className="googlesitekit-audience-segmentation-tile__header-title">
{ title }
{ infoTooltip && (
<InfoTooltip
title={ infoTooltip }
tooltipClassName="googlesitekit-info-tooltip__content--audience"
/>
) }
</div>
</div>
) }
<div className="googlesitekit-audience-segmentation-tile__zero-data-content">
<AudienceTileCollectingData />
{ isTileHideable && (
<AudienceTileCollectingDataHideable
onHideTile={ onHideTile }
/>
) }
</div>
</div>
</div>
</Widget>
);
}

return (
Expand Down Expand Up @@ -242,4 +280,8 @@ AudienceTile.propTypes = {
topContentTitles: PropTypes.object,
Widget: PropTypes.elementType.isRequired,
audienceResourceName: PropTypes.string.isRequired,
isZeroData: PropTypes.bool,
isPartialData: PropTypes.bool,
isTileHideable: PropTypes.bool,
onHideTile: PropTypes.func,
};
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ const readyProps = {
'/en/test-post-2/': 'Test Post 2',
'/en/test-post-3/': 'Test Post 3',
},
isZeroData: false,
isPartialData: false,
};

const audienceResourceName = 'properties/12345/audiences/12345';
Expand Down Expand Up @@ -276,6 +278,34 @@ TopContentPartialData.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTile/TopContentPartialData',
};

export const ZeroDataHideable = Template.bind( {} );
ZeroDataHideable.storyName = 'ZeroDataHideable';
ZeroDataHideable.args = {
...readyProps,
infoTooltip: 'This is a tooltip',
audienceResourceName,
isZeroData: true,
isPartialData: true,
isTileHideable: true,
onHideTile: () => {},
};
ZeroDataHideable.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTile/ZeroDataHideable',
};

export const ZeroDataNonHideable = Template.bind( {} );
ZeroDataNonHideable.storyName = 'ZeroDataNonHideable';
ZeroDataNonHideable.args = {
...readyProps,
infoTooltip: 'This is a tooltip',
audienceResourceName,
isZeroData: true,
isPartialData: true,
};
ZeroDataNonHideable.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTile/ZeroDataNonHideable',
};

export default {
title: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTile',
};
Loading

0 comments on commit b10a787

Please sign in to comment.