Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into enhancement/4226-zero…
…-data-states.
- Loading branch information
Showing
9 changed files
with
186 additions
and
12 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
assets/js/modules/adsense/components/dashboard/AdBlockerWarningWidget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* AdBlockerWarningWidget component. | ||
* | ||
* Site Kit by Google, Copyright 2021 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'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Data from 'googlesitekit-data'; | ||
import { MODULES_ADSENSE } from '../../datastore/constants'; | ||
import AdBlockerWarning from '../common/AdBlockerWarning'; | ||
import whenActive from '../../../../util/when-active'; | ||
const { useSelect } = Data; | ||
|
||
function AdBlockerWarningWidget( { Widget } ) { | ||
const isAdBlockerActive = useSelect( ( select ) => | ||
select( MODULES_ADSENSE ).isAdBlockerActive() | ||
); | ||
|
||
if ( ! isAdBlockerActive ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Widget noPadding> | ||
<AdBlockerWarning /> | ||
</Widget> | ||
); | ||
} | ||
|
||
AdBlockerWarningWidget.propTypes = { | ||
Widget: PropTypes.elementType.isRequired, | ||
}; | ||
|
||
export default whenActive( { moduleName: 'adsense' } )( | ||
AdBlockerWarningWidget | ||
); |
62 changes: 62 additions & 0 deletions
62
assets/js/modules/adsense/components/dashboard/AdBlockerWarningWidget.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* AdBlockerWarningWidget Component Stories. | ||
* | ||
* Site Kit by Google, Copyright 2021 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. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { MODULES_ADSENSE } from '../../datastore/constants'; | ||
import { provideModules } from '../../../../../../tests/js/utils'; | ||
import { withWidgetComponentProps } from '../../../../googlesitekit/widgets/util'; | ||
import WithRegistrySetup from '../../../../../../tests/js/WithRegistrySetup'; | ||
import AdBlockerWarningWidget from './AdBlockerWarningWidget'; | ||
|
||
const WidgetWithComponentProps = withWidgetComponentProps( 'adBlockerWarning' )( | ||
AdBlockerWarningWidget | ||
); | ||
|
||
const Template = () => <WidgetWithComponentProps />; | ||
|
||
export const Ready = Template.bind( {} ); | ||
Ready.storyName = 'Ready'; | ||
|
||
export default { | ||
title: 'Modules/AdSense/Widgets/AdBlockerWarning', | ||
decorators: [ | ||
( Story ) => { | ||
const setupRegistry = ( registry ) => { | ||
provideModules( registry, [ | ||
{ | ||
active: true, | ||
connected: true, | ||
slug: 'adsense', | ||
}, | ||
] ); | ||
|
||
registry | ||
.dispatch( MODULES_ADSENSE ) | ||
.receiveIsAdBlockerActive( true ); | ||
}; | ||
|
||
return ( | ||
<WithRegistrySetup func={ setupRegistry }> | ||
<Story /> | ||
</WithRegistrySetup> | ||
); | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
assets/sass/widgets/_googlesitekit-widget-adBlockerWarning.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* AdSense AdBlocker Warning widget styles. | ||
* | ||
* Site Kit by Google, Copyright 2021 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. | ||
*/ | ||
|
||
.googlesitekit-plugin { | ||
|
||
.googlesitekit-widget--adBlockerWarning { | ||
background-color: transparent; | ||
box-shadow: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters