diff --git a/.storybook/storybook-data.js b/.storybook/storybook-data.js index 8467be9bb37..a17f747293f 100644 --- a/.storybook/storybook-data.js +++ b/.storybook/storybook-data.js @@ -80,69 +80,6 @@ module.exports = [ }, }, }, - { - id: 'analytics-module-components-module-page-overview-widget--loaded', - kind: 'Analytics Module', - name: 'Overview Widget', - story: 'Loaded', - parameters: { - fileName: './stories/module-analytics-components.stories.js', - options: { - hierarchyRootSeparator: '|', - hierarchySeparator: {}, - readySelector: - '.googlesitekit-chart .googlesitekit-chart__inner', - }, - }, - }, - { - id: - 'analytics-module-components-module-page-overview-widget--zero-data', - kind: 'Analytics Module', - name: 'Overview Widget with zero data', - story: 'Zero Data', - parameters: { - fileName: './stories/module-analytics-components.stories.js', - options: { - hierarchyRootSeparator: '|', - hierarchySeparator: {}, - readySelector: - '.googlesitekit-chart .googlesitekit-chart__inner', - }, - }, - }, - { - id: - 'search-console-module-components-module-page-overview-widget--loaded', - kind: 'Search Console Module', - name: 'Overview Widget', - story: 'Loaded', - parameters: { - fileName: './stories/module-search-console-components.stories.js', - options: { - hierarchyRootSeparator: '|', - hierarchySeparator: {}, - readySelector: - '.googlesitekit-chart .googlesitekit-chart__inner', - }, - }, - }, - { - id: - 'search-console-module-components-module-page-overview-widget--zero-data', - kind: 'Search Console Module', - name: 'Overview Widget with zero data', - story: 'Zero Data', - parameters: { - fileName: './stories/module-search-console-components.stories.js', - options: { - hierarchyRootSeparator: '|', - hierarchySeparator: {}, - readySelector: - '.googlesitekit-chart .googlesitekit-chart__inner', - }, - }, - }, { id: 'global-notifications--module-setup-complete', kind: 'Global/Notifications', diff --git a/assets/js/components/DashboardEntryPoint.js b/assets/js/components/DashboardEntryPoint.js index 8a28d0e5f45..3be8fa1113a 100644 --- a/assets/js/components/DashboardEntryPoint.js +++ b/assets/js/components/DashboardEntryPoint.js @@ -21,37 +21,18 @@ */ import PropTypes from 'prop-types'; -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; - /** * Internal dependencies */ -import { useFeature } from '../hooks/useFeature'; import ModuleSetup from './setup/ModuleSetup'; -import DashboardApp from './dashboard/DashboardApp'; import DashboardMainApp from './DashboardMainApp'; -import NotificationCounter from './legacy-notifications/notification-counter'; export default function DashboardEntryPoint( { setupModuleSlug } ) { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - if ( !! setupModuleSlug ) { return ; } - if ( unifiedDashboardEnabled ) { - return ; - } - - return ( - - - - - ); + return ; } DashboardEntryPoint.propTypes = { diff --git a/assets/js/components/DashboardEntryPoint.test.js b/assets/js/components/DashboardEntryPoint.test.js index ff65f8c83ad..e689d2e963d 100644 --- a/assets/js/components/DashboardEntryPoint.test.js +++ b/assets/js/components/DashboardEntryPoint.test.js @@ -24,9 +24,6 @@ import { mockCreateComponent } from '../../../tests/js/mock-component-utils'; import DashboardEntryPoint from './DashboardEntryPoint'; jest.mock( './setup/ModuleSetup', () => mockCreateComponent( 'ModuleSetup' ) ); -jest.mock( './dashboard/DashboardApp', () => - mockCreateComponent( 'DashboardApp' ) -); jest.mock( './DashboardMainApp', () => mockCreateComponent( 'DashboardMainApp' ) ); @@ -35,30 +32,12 @@ jest.mock( './legacy-notifications/notification-counter', () => ); describe( 'DashboardEntryPoint', () => { - const unifiedDashboardRenderOptions = { features: [ 'unifiedDashboard' ] }; - - it( 'should render the unified dashboard when unified dashboard is enabled', () => { - const { container } = render( - , - unifiedDashboardRenderOptions - ); - expect( container ).toMatchSnapshot(); - } ); - - it( 'should render the module setup component when unified dashboard is enabled and passed the setupModuleSlug prop', () => { - const { container } = render( - , - unifiedDashboardRenderOptions - ); - expect( container ).toMatchSnapshot(); - } ); - - it( 'should render the non-unified dashboard when unified dashboard is not enabled', () => { + it( 'should render the unified dashboard', () => { const { container } = render( ); expect( container ).toMatchSnapshot(); } ); - it( 'should render the module setup component when unified dashboard is not enabled and passed the setupModuleSlug prop', () => { + it( 'should render the module setup component when the setupModuleSlug prop is passed', () => { const { container } = render( ); diff --git a/assets/js/components/DateRangeSelector.js b/assets/js/components/DateRangeSelector.js index cc9fc53eacd..2b6f226241b 100644 --- a/assets/js/components/DateRangeSelector.js +++ b/assets/js/components/DateRangeSelector.js @@ -40,14 +40,11 @@ import { getAvailableDateRanges } from '../util/date-range'; import Menu from './Menu'; import Button from './Button'; import { trackEvent } from '../util'; -import { useFeature } from '../hooks/useFeature'; import { CORE_UI } from '../googlesitekit/datastore/ui/constants'; import useViewContext from '../hooks/useViewContext'; const { useSelect, useDispatch } = Data; export default function DateRangeSelector() { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - const ranges = getAvailableDateRanges(); const dateRange = useSelect( ( select ) => select( CORE_USER ).getDateRange() @@ -102,10 +99,7 @@ export default function DateRangeSelector() { 'googlesitekit-header__dropdown', 'googlesitekit-header__date-range-selector-menu', 'googlesitekit-border-radius-round--phone', - 'googlesitekit-button-icon--phone', - { - 'googlesitekit-header__date-range-selector-menu--has-unified-dashboard': unifiedDashboardEnabled, - } + 'googlesitekit-button-icon--phone' ) } text onClick={ handleMenu } diff --git a/assets/js/components/Header.js b/assets/js/components/Header.js index ff661cf9982..6962c51c7b3 100644 --- a/assets/js/components/Header.js +++ b/assets/js/components/Header.js @@ -47,7 +47,6 @@ import useDashboardType from '../hooks/useDashboardType'; const { useSelect } = Data; const Header = ( { children, subHeader, showNavigation } ) => { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); const dashboardSharingEnabled = useFeature( 'dashboardSharing' ); const isDashboard = !! useDashboardType(); const isViewOnly = useViewOnly(); @@ -65,7 +64,7 @@ const Header = ( { children, subHeader, showNavigation } ) => {
@@ -106,7 +105,7 @@ const Header = ( { children, subHeader, showNavigation } ) => { { showNavigation && } - { unifiedDashboardEnabled && } + diff --git a/assets/js/components/PostSearcherAutoSuggest.js b/assets/js/components/PostSearcherAutoSuggest.js index 9ecafc474a2..2f4fba5910c 100644 --- a/assets/js/components/PostSearcherAutoSuggest.js +++ b/assets/js/components/PostSearcherAutoSuggest.js @@ -41,7 +41,6 @@ import { END, ENTER, ESCAPE, HOME } from '@wordpress/keycodes'; import API from 'googlesitekit-api'; import Data from 'googlesitekit-data'; import { useDebouncedState } from '../hooks/useDebouncedState'; -import { useFeature } from '../hooks/useFeature'; import { CORE_SITE } from '../googlesitekit/datastore/site/constants'; const { useSelect } = Data; @@ -84,8 +83,6 @@ export default function PostSearcherAutoSuggest( { const [ results, setResults ] = useState( [] ); const noResultsMessage = __( 'No results found', 'google-site-kit' ); - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - const currentEntityTitle = useSelect( ( select ) => select( CORE_SITE ).getCurrentEntityTitle() ); @@ -226,10 +223,6 @@ export default function PostSearcherAutoSuggest( { break; } - if ( ! unifiedDashboardEnabled ) { - return; - } - switch ( e.keyCode ) { case ESCAPE: return onClose(); @@ -239,7 +232,7 @@ export default function PostSearcherAutoSuggest( { break; } }, - [ onClose, onSelectCallback, searchTerm, unifiedDashboardEnabled ] + [ onClose, onSelectCallback, searchTerm ] ); return ( @@ -262,7 +255,7 @@ export default function PostSearcherAutoSuggest( { autoFocus={ autoFocus } /> - { ( ! unifiedDashboardEnabled || ! isLoading ) && + { ! isLoading && showDropdown && debouncedValue !== currentEntityTitle && debouncedValue !== '' && diff --git a/assets/js/components/UserMenu.js b/assets/js/components/UserMenu.js index 599b8bdd7c0..4babc33dd5b 100644 --- a/assets/js/components/UserMenu.js +++ b/assets/js/components/UserMenu.js @@ -19,7 +19,6 @@ /** * External dependencies */ -import classnames from 'classnames'; import { useClickAway } from 'react-use'; /** @@ -44,7 +43,6 @@ import Dialog from './Dialog'; import Button from './Button'; import Menu from './Menu'; import Portal from './Portal'; -import { useFeature } from '../hooks/useFeature'; import { CORE_SITE } from '../googlesitekit/datastore/site/constants'; import { CORE_USER } from '../googlesitekit/datastore/user/constants'; import { CORE_LOCATION } from '../googlesitekit/datastore/location/constants'; @@ -53,7 +51,6 @@ import useViewContext from '../hooks/useViewContext'; const { useSelect, useDispatch } = Data; export default function UserMenu() { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); const proxyPermissionsURL = useSelect( ( select ) => select( CORE_SITE ).getProxyPermissionsURL() ); @@ -152,7 +149,7 @@ export default function UserMenu() { navigateTo( postDisconnectURL ); }, [ postDisconnectURL, navigateTo, viewContext ] ); - if ( ! unifiedDashboardEnabled && ! userEmail ) { + if ( ! userEmail ) { return null; } @@ -163,25 +160,13 @@ export default function UserMenu() { className="googlesitekit-user-selector googlesitekit-dropdown-menu googlesitekit-dropdown-menu__icon-menu mdc-menu-surface--anchor" > + /> + { container = render( , { registry } ).container; fireEvent.click( container.querySelector( - '.googlesitekit-header__dropdown span' + '.googlesitekit-user-selector .googlesitekit-header__dropdown' ) ); menu = container.querySelector( '#user-menu' ); diff --git a/assets/js/components/__snapshots__/DashboardEntryPoint.test.js.snap b/assets/js/components/__snapshots__/DashboardEntryPoint.test.js.snap index 58f7aa2a388..a057cd5288d 100644 --- a/assets/js/components/__snapshots__/DashboardEntryPoint.test.js.snap +++ b/assets/js/components/__snapshots__/DashboardEntryPoint.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DashboardEntryPoint should render the module setup component when unified dashboard is enabled and passed the setupModuleSlug prop 1`] = ` +exports[`DashboardEntryPoint should render the module setup component when the setupModuleSlug prop is passed 1`] = `
ModuleSetup @@ -9,29 +9,7 @@ exports[`DashboardEntryPoint should render the module setup component when unifi
`; -exports[`DashboardEntryPoint should render the module setup component when unified dashboard is not enabled and passed the setupModuleSlug prop 1`] = ` -
-
- ModuleSetup - {"moduleSlug":"analytics"} -
-
-`; - -exports[`DashboardEntryPoint should render the non-unified dashboard when unified dashboard is not enabled 1`] = ` -
-
- NotificationCounter - {} -
-
- DashboardApp - {} -
-
-`; - -exports[`DashboardEntryPoint should render the unified dashboard when unified dashboard is enabled 1`] = ` +exports[`DashboardEntryPoint should render the unified dashboard 1`] = `
DashboardMainApp diff --git a/assets/js/components/dashboard-details/DashboardDetailsApp.js b/assets/js/components/dashboard-details/DashboardDetailsApp.js deleted file mode 100644 index 599a5a7bfbf..00000000000 --- a/assets/js/components/dashboard-details/DashboardDetailsApp.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * DashboardDetailsApp 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. - */ - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import WidgetContextRenderer from '../../googlesitekit/widgets/components/WidgetContextRenderer'; -import DashboardDetailsHeader from './DashboardDetailsHeader'; -import Header from '../Header'; -import DateRangeSelector from '../DateRangeSelector'; -import { CORE_SITE } from '../../googlesitekit/datastore/site/constants'; -import HelpMenu from '../help/HelpMenu'; -import { Grid, Row, Cell } from '../../material-components'; -const { useSelect } = Data; - -export default function DashboardDetailsApp() { - const dashboardURL = useSelect( ( select ) => - select( CORE_SITE ).getAdminURL( 'googlesitekit-dashboard' ) - ); - const currentEntityURL = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - - if ( ! dashboardURL ) { - return null; - } - - return ( - -
- - { currentEntityURL && } -
- - { currentEntityURL ? ( - - ) : ( -
- - - - - - - -
- ) } -
- ); -} diff --git a/assets/js/components/dashboard-details/DashboardDetailsHeader.js b/assets/js/components/dashboard-details/DashboardDetailsHeader.js deleted file mode 100644 index 1c79cc11de7..00000000000 --- a/assets/js/components/dashboard-details/DashboardDetailsHeader.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * DashboardDetailsHeader 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. - */ - -/** - * WordPress dependencies - */ -import { createInterpolateElement, Fragment } from '@wordpress/element'; -import { sprintf, __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { decodeHTMLEntity } from '../../util'; -import Link from '../Link'; -import PageHeader from '../PageHeader'; -import VisuallyHidden from '../VisuallyHidden'; -import Layout from '../layout/Layout'; -import { Grid, Row, Cell } from '../../material-components/layout'; -import { CORE_SITE } from '../../googlesitekit/datastore/site/constants'; -const { useSelect } = Data; - -export default function DashboardDetailsHeader() { - const dashboardURL = useSelect( ( select ) => - select( CORE_SITE ).getAdminURL( 'googlesitekit-dashboard' ) - ); - const currentEntityURL = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - const currentEntityTitle = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityTitle() - ); - const permaLink = useSelect( ( select ) => - select( CORE_SITE ).getPermaLinkParam() - ); - - return ( - - - { __( 'Back to the Site Kit Dashboard', 'google-site-kit' ) } - - - - - - - - - { currentEntityURL && ( - -

- { currentEntityTitle && - decodeHTMLEntity( - currentEntityTitle - ) } -

- - { currentEntityURL } - -
- ) } - { ! currentEntityURL && ( -

- { createInterpolateElement( - sprintf( - /* translators: %s: current entity URL. */ - __( - 'It looks like the URL %s is not part of this site or is not based on standard WordPress content types, therefore there is no data available to display. Visit our support forums or Site Kit website for support or further information.', - 'google-site-kit' - ), - `${ permaLink }` - ), - { - strong: , - link1: ( - - ), - link2: ( - - ), - VisuallyHidden: , - } - ) } -

- ) } -
-
-
-
-
- ); -} diff --git a/assets/js/components/dashboard/DashboardApp.js b/assets/js/components/dashboard/DashboardApp.js deleted file mode 100644 index 3990067ea3e..00000000000 --- a/assets/js/components/dashboard/DashboardApp.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * DashboardApp 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. - */ - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import { DAY_IN_SECONDS } from '../../util'; -import WidgetContextRenderer from '../../googlesitekit/widgets/components/WidgetContextRenderer'; -import DashboardHeader from './DashboardHeader'; -import DashboardNotifications from './dashboard-notifications'; -import Header from '../Header'; -import DateRangeSelector from '../DateRangeSelector'; -import HelpMenu from '../help/HelpMenu'; -import SurveyViewTrigger from '../surveys/SurveyViewTrigger'; - -export default function DashboardApp() { - return ( - -
- - -
- - - - - -
- ); -} diff --git a/assets/js/components/dashboard/DashboardHeader.js b/assets/js/components/dashboard/DashboardHeader.js deleted file mode 100644 index c7ccbb16e39..00000000000 --- a/assets/js/components/dashboard/DashboardHeader.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * DashboardHeader 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. - */ - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import PageHeader from '../PageHeader'; - -export default function DashboardHeader() { - return ( - - ); -} diff --git a/assets/js/components/dashboard/dashboard-notifications.js b/assets/js/components/dashboard/dashboard-notifications.js deleted file mode 100644 index b1c458c6508..00000000000 --- a/assets/js/components/dashboard/dashboard-notifications.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * DashboardNotifications 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. - */ - -/** - * WordPress dependencies - */ -import { withFilters } from '@wordpress/components'; -import { Component } from '@wordpress/element'; - -/** - * A single module. Keeps track of its own active state and settings. - */ -class DashboardNotifications extends Component { - render() { - return null; - } -} - -export default withFilters( 'googlesitekit.DashboardNotifications' )( - DashboardNotifications -); diff --git a/assets/js/components/module/ModuleApp.js b/assets/js/components/module/ModuleApp.js deleted file mode 100644 index 125c0b8d71e..00000000000 --- a/assets/js/components/module/ModuleApp.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * ModuleApp 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. - */ - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; - -/** - * External dependencies - */ -import PropTypes from 'prop-types'; -import classNames from 'classnames'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import Header from '../Header'; -import Alert from '../Alert'; -import ModuleHeader from './ModuleHeader'; -import WidgetContextRenderer from '../../googlesitekit/widgets/components/WidgetContextRenderer'; -import DateRangeSelector from '../DateRangeSelector'; -import HelpMenu from '../help/HelpMenu'; -import { CORE_MODULES } from '../../googlesitekit/modules/datastore/constants'; - -const { useSelect } = Data; - -function ModuleApp( { moduleSlug } ) { - const screenWidgetContext = useSelect( ( select ) => - select( CORE_MODULES ).getScreenWidgetContext( moduleSlug ) - ); - const moduleConnected = useSelect( ( select ) => - select( CORE_MODULES ).isModuleConnected( moduleSlug ) - ); - const getModuleHeader = () => ; - - return ( - -
- - { moduleConnected && } -
- - -
- ); -} - -ModuleApp.propTypes = { - moduleSlug: PropTypes.string, -}; - -export default ModuleApp; diff --git a/assets/js/components/module/ModuleHeader.js b/assets/js/components/module/ModuleHeader.js deleted file mode 100644 index 99422caf026..00000000000 --- a/assets/js/components/module/ModuleHeader.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * ModuleHeader 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. - */ - -/** - * WordPress dependencies - */ -import { sprintf, __ } from '@wordpress/i18n'; - -/** - * External dependencies - */ -import PropTypes from 'prop-types'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import PageHeader from '../PageHeader'; -import { CORE_MODULES } from '../../googlesitekit/modules/datastore/constants'; -const { useSelect } = Data; - -function ModuleHeader( { moduleSlug } ) { - const module = useSelect( ( select ) => - select( CORE_MODULES ).getModule( moduleSlug ) - ); - const moduleConnected = useSelect( ( select ) => - select( CORE_MODULES ).isModuleConnected( moduleSlug ) - ); - const moduleStatus = moduleConnected ? 'connected' : 'not-connected'; - const ModuleIcon = useSelect( ( select ) => - select( CORE_MODULES ).getModuleIcon( moduleSlug ) - ); - - if ( ! module ) { - return null; - } - - const { name } = module; - - const moduleStatusText = sprintf( - /* translators: %s: module name. */ - __( '%s is connected', 'google-site-kit' ), - name - ); - - return ( - - ) - } - status={ moduleStatus } - statusText={ moduleStatusText } - /> - ); -} - -PageHeader.propTypes = { - moduleSlug: PropTypes.string, -}; - -export default ModuleHeader; diff --git a/assets/js/components/notifications/SetupSuccessBannerNotification.js b/assets/js/components/notifications/SetupSuccessBannerNotification.js index bad9fa7dd4a..cc5c60ec357 100644 --- a/assets/js/components/notifications/SetupSuccessBannerNotification.js +++ b/assets/js/components/notifications/SetupSuccessBannerNotification.js @@ -43,12 +43,10 @@ import { PERMISSION_MANAGE_OPTIONS, } from '../../googlesitekit/datastore/user/constants'; import { trackEvent } from '../../util/tracking'; -import { useFeature } from '../../hooks/useFeature'; import useViewContext from '../../hooks/useViewContext'; const { useSelect } = Data; function SetupSuccessBannerNotification() { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); const slug = getQueryParameter( 'slug' ); const viewContext = useViewContext(); const modules = useSelect( ( select ) => @@ -171,9 +169,7 @@ function SetupSuccessBannerNotification() { }; if ( 'pagespeed-insights' === slug ) { - anchor.link = unifiedDashboardEnabled - ? '#speed' - : '#googlesitekit-pagespeed-header'; + anchor.link = '#speed'; anchor.label = __( 'Jump to the bottom of the dashboard to see how fast your home page is', 'google-site-kit' diff --git a/assets/js/feature-tours/unified-dashboard.js b/assets/js/feature-tours/unified-dashboard.js index b007cc58b48..f99acbe4160 100644 --- a/assets/js/feature-tours/unified-dashboard.js +++ b/assets/js/feature-tours/unified-dashboard.js @@ -33,14 +33,12 @@ import { VIEW_CONTEXT_DASHBOARD, VIEW_CONTEXT_DASHBOARD_VIEW_ONLY, } from '../googlesitekit/constants'; -import { isFeatureEnabled } from '../features'; const unifiedDashboard = { slug: 'unifiedDashboard', contexts: [ VIEW_CONTEXT_DASHBOARD, VIEW_CONTEXT_DASHBOARD_VIEW_ONLY ], version: '1.68.0', gaEventCategory: ( viewContext ) => `${ viewContext }_unified-dashboard`, - checkRequirements: () => isFeatureEnabled( 'unifiedDashboard' ), steps: [ { target: '.googlesitekit-navigation', diff --git a/assets/js/googlesitekit-dashboard-details.js b/assets/js/googlesitekit-dashboard-details.js index 329b695c7ff..f68f6debc18 100644 --- a/assets/js/googlesitekit-dashboard-details.js +++ b/assets/js/googlesitekit-dashboard-details.js @@ -26,8 +26,6 @@ import { render } from '@wordpress/element'; * Internal dependencies. */ import './components/legacy-notifications'; -import { useFeature } from './hooks/useFeature'; -import DashboardDetailsApp from './components/dashboard-details/DashboardDetailsApp'; import DashboardEntityApp from './components/DashboardEntityApp'; import Root from './components/Root'; import { @@ -35,15 +33,6 @@ import { VIEW_CONTEXT_PAGE_DASHBOARD_VIEW_ONLY, } from './googlesitekit/constants'; -const GoogleSitekitDashboardDetails = () => { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - - if ( unifiedDashboardEnabled ) { - return ; - } - return ; -}; - // Initialize the app once the DOM is ready. domReady( () => { const renderTarget = document.getElementById( @@ -61,7 +50,7 @@ domReady( () => { : VIEW_CONTEXT_PAGE_DASHBOARD } > - + , renderTarget ); diff --git a/assets/js/googlesitekit-module.js b/assets/js/googlesitekit-module.js deleted file mode 100644 index 28a56a3fe73..00000000000 --- a/assets/js/googlesitekit-module.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Module 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. - */ - -/** - * WordPress dependencies - */ -import domReady from '@wordpress/dom-ready'; -import { render } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import './components/legacy-notifications'; -import Root from './components/Root'; -import ModuleApp from './components/module/ModuleApp'; -import ModuleSetup from './components/setup/ModuleSetup'; -import { - VIEW_CONTEXT_MODULE, - VIEW_CONTEXT_MODULE_SETUP, -} from './googlesitekit/constants'; - -const GoogleSitekitModule = ( { moduleSlug, setupModuleSlug } ) => { - if ( !! setupModuleSlug ) { - return ; - } - - return ; -}; - -// Initialize the app once the DOM is ready. -domReady( () => { - const renderTarget = document.getElementById( 'js-googlesitekit-module' ); - - if ( renderTarget ) { - const { moduleSlug, setupModuleSlug } = renderTarget.dataset; - - render( - - - , - renderTarget - ); - } -} ); diff --git a/assets/js/googlesitekit/modules/create-info-store.js b/assets/js/googlesitekit/modules/create-info-store.js index 00fc6a75be2..0a2b1da0138 100644 --- a/assets/js/googlesitekit/modules/create-info-store.js +++ b/assets/js/googlesitekit/modules/create-info-store.js @@ -44,17 +44,12 @@ const { createRegistrySelector } = Data; * @param {string} slug Slug of the module that the store is for. * @param {Object} args Arguments to configure the store. * @param {number} args.storeName Store name to use. - * @param {string} [args.adminPage] Optional. Store admin page. Default is 'googlesitekit-dashboard'. * @param {boolean} [args.requiresSetup] Optional. Store flag, for requires setup. Default is 'true'. * @return {Object} The info store object. */ export const createInfoStore = ( slug, - { - storeName = undefined, - adminPage = 'googlesitekit-dashboard', - requiresSetup = true, - } = {} + { storeName = undefined, requiresSetup = true } = {} ) => { invariant( storeName, 'storeName is required.' ); @@ -76,7 +71,10 @@ export const createInfoStore = ( */ getAdminScreenURL: createRegistrySelector( ( select ) => ( state, queryArgs ) => { - return select( CORE_SITE ).getAdminURL( adminPage, queryArgs ); + return select( CORE_SITE ).getAdminURL( + 'googlesitekit-dashboard', + queryArgs + ); } ), diff --git a/assets/js/googlesitekit/modules/create-info-store.test.js b/assets/js/googlesitekit/modules/create-info-store.test.js index 997e76919f1..824cd4baf22 100644 --- a/assets/js/googlesitekit/modules/create-info-store.test.js +++ b/assets/js/googlesitekit/modules/create-info-store.test.js @@ -87,30 +87,6 @@ describe( 'createInfoStore store', () => { } ); } ); - // It uses `adminPage` when provided. - it( 'returns adminPage url when `adminPage` is provided', () => { - registry.dispatch( CORE_SITE ).receiveSiteInfo( { - adminURL: 'http://example.com/wp-admin/', - } ); - const { STORE_NAME, ...store } = createInfoStore( MODULE_SLUG, { - storeName: TEST_STORE_NAME, - adminPage: 'test-admin-page', - } ); - registry.registerStore( STORE_NAME, store ); - - const adminSreenURL = registry - .select( STORE_NAME ) - .getAdminScreenURL(); - - const { origin, pathname } = new URL( adminSreenURL ); - expect( origin + pathname ).toEqual( - 'http://example.com/wp-admin/admin.php' - ); - expect( adminSreenURL ).toMatchQueryParameters( { - page: 'test-admin-page', - } ); - } ); - // It adds extra query parameters if provided. it( 'adds extra query parameters to the adminScreenURL when provided', () => { registry.dispatch( CORE_SITE ).receiveSiteInfo( { diff --git a/assets/js/googlesitekit/modules/create-module-store.js b/assets/js/googlesitekit/modules/create-module-store.js index d342c46a285..8883983216a 100644 --- a/assets/js/googlesitekit/modules/create-module-store.js +++ b/assets/js/googlesitekit/modules/create-module-store.js @@ -54,7 +54,6 @@ import { createValidationSelector } from '../data/utils'; * @param {number} args.storeName Store name to use. * @param {Array} [args.settingSlugs] Optional. If the module store should support settings, this needs to be a list of the slugs that are part of the module and handled by the module's 'modules/{slug}/data/settings' API endpoint. Default is undefined. * @param {Array} [args.ownedSettingsSlugs] Optional. List of "owned settings" for this module, if they exist. - * @param {string} [args.adminPage] Optional. Store admin page. Default is 'googlesitekit-dashboard'. * @param {boolean} [args.requiresSetup] Optional. Store flag for requires setup. Default is 'true'. * @param {Function} [args.submitChanges] Optional. Submit settings changes handler. * @param {Function} [args.rollbackChanges] Optional. Rollbacks settings changes handler. @@ -68,7 +67,6 @@ export function createModuleStore( slug, args = {} ) { storeName, settingSlugs, ownedSettingsSlugs = undefined, - adminPage = 'googlesitekit-dashboard', requiresSetup = true, submitChanges, rollbackChanges, @@ -90,7 +88,6 @@ export function createModuleStore( slug, args = {} ) { const infoStore = createInfoStore( slug, { storeName, - adminPage, requiresSetup, } ); diff --git a/assets/js/googlesitekit/modules/datastore/modules.js b/assets/js/googlesitekit/modules/datastore/modules.js index 230c7655555..a574de3b8d4 100644 --- a/assets/js/googlesitekit/modules/datastore/modules.js +++ b/assets/js/googlesitekit/modules/datastore/modules.js @@ -311,7 +311,6 @@ const baseActions = { * @param {WPComponent} [settings.SettingsSetupIncompleteComponent] Optional. React component to render the incomplete settings panel. Default none. * @param {WPComponent} [settings.SetupComponent] Optional. React component to render the setup panel. Default none. * @param {Function} [settings.checkRequirements] Optional. Function to check requirements for the module. Throws a WP error object for error or returns on success. - * @param {Function} [settings.screenWidgetContext] Optional. Get the registered context name for a given module. */ registerModule: createValidatedAction( ( slug ) => { @@ -332,7 +331,6 @@ const baseActions = { SetupComponent, SettingsSetupIncompleteComponent, checkRequirements, - screenWidgetContext, } = {} ) { const settings = { @@ -348,7 +346,6 @@ const baseActions = { SetupComponent, SettingsSetupIncompleteComponent, checkRequirements, - screenWidgetContext, }; yield { @@ -1190,34 +1187,6 @@ const baseSelectors = { } ), - /** - * Gets the module's screenWidgetContext. - * - * Returns the registered context string, screenWidgetContext for the given module. - * - * @since 1.28.0 - * - * @param {Object} state Data store's state. - * @param {string} moduleSlug Module slug. - * @return {(string|null|undefined)} The module's registered context string, null if there is - * none, undefined if not loaded yet. - */ - getScreenWidgetContext: createRegistrySelector( - ( select ) => ( state, moduleSlug ) => { - invariant( moduleSlug, 'slug is required.' ); - const modules = select( CORE_MODULES ).getModules(); - - if ( modules === undefined ) { - return undefined; - } - - const screenWidgetContext = - modules[ moduleSlug ]?.screenWidgetContext; - - return screenWidgetContext || null; - } - ), - /** * Gets the module's list of features. * diff --git a/assets/js/googlesitekit/widgets/components/WidgetAreaRenderer.js b/assets/js/googlesitekit/widgets/components/WidgetAreaRenderer.js index cf9384fb1c1..24b7e882e34 100644 --- a/assets/js/googlesitekit/widgets/components/WidgetAreaRenderer.js +++ b/assets/js/googlesitekit/widgets/components/WidgetAreaRenderer.js @@ -37,7 +37,6 @@ import { getHeaderHeight } from '../../../util/scroll'; import { CORE_WIDGETS, WIDGET_AREA_STYLES } from '../datastore/constants'; import { CORE_UI, ACTIVE_CONTEXT_ID } from '../../datastore/ui/constants'; import { Cell, Grid, Row } from '../../../material-components'; -import { useFeature } from '../../../hooks/useFeature'; import { useBreakpoint, BREAKPOINT_XLARGE, @@ -75,8 +74,6 @@ function getRootMargin( breakpoint ) { } export default function WidgetAreaRenderer( { slug, totalAreas, contextID } ) { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - const viewOnlyDashboard = useViewOnly(); const viewableModules = useSelect( ( select ) => { @@ -215,7 +212,7 @@ export default function WidgetAreaRenderer( { slug, totalAreas, contextID } ) { ) } ref={ widgetAreaRef } > - { ( unifiedDashboardEnabled || totalAreas > 1 ) && ( + { totalAreas > 1 && ( - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - compare: true, - } ) - ); - - const previousPeriodArgs = { - startDate: compareStartDate, - endDate: compareEndDate, - metrics: [ 'ESTIMATED_EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS' ], - }; - - const periodArgs = { - startDate, - endDate, - metrics: [ 'ESTIMATED_EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS' ], - }; - - const dailyArgs = { - ...periodArgs, - dimensions: [ 'DATE' ], - }; - - const dateRangeArgs = generateDateRangeArgs( { startDate, endDate } ); - - const { - error, - loading, - rpmReportURL, - earningsURL, - impressionsURL, - isAdblockerActive, - } = useSelect( ( select ) => { - return { - loading: - ! select( MODULES_ADSENSE ).hasFinishedResolution( - 'getReport', - [ periodArgs ] - ) || - ! select( MODULES_ADSENSE ).hasFinishedResolution( - 'getReport', - [ previousPeriodArgs ] - ) || - ! select( MODULES_ADSENSE ).hasFinishedResolution( - 'getReport', - [ dailyArgs ] - ), - error: - select( MODULES_ADSENSE ).getErrorForSelector( 'getReport', [ - periodArgs, - ] ) || - select( MODULES_ADSENSE ).getErrorForSelector( 'getReport', [ - previousPeriodArgs, - ] ) || - select( MODULES_ADSENSE ).getErrorForSelector( 'getReport', [ - dailyArgs, - ] ), - rpmReportURL: select( MODULES_ADSENSE ).getServiceReportURL( { - ...dateRangeArgs, - gm: 'pageViewsRpm', - } ), - earningsURL: select( MODULES_ADSENSE ).getServiceReportURL( { - ...dateRangeArgs, - gm: 'earnings', - } ), - impressionsURL: select( MODULES_ADSENSE ).getServiceReportURL( { - ...dateRangeArgs, - gm: 'monetizableImpressions', - } ), - isAdblockerActive: select( MODULES_ADSENSE ).isAdBlockerActive(), - }; - } ); - - const period = useInViewSelect( ( select ) => - select( MODULES_ADSENSE ).getReport( periodArgs ) - ); - - const previousPeriod = useInViewSelect( ( select ) => - select( MODULES_ADSENSE ).getReport( previousPeriodArgs ) - ); - - const daily = useInViewSelect( ( select ) => - select( MODULES_ADSENSE ).getReport( dailyArgs ) - ); - - if ( isAdblockerActive ) { - return ( - - - - ); - } - - if ( loading ) { - return ( - - - - ); - } - - if ( error ) { - return ( - - - - ); - } - - if ( - isZeroReport( previousPeriod ) && - isZeroReport( period ) && - isZeroReport( daily ) - ) { - return ( - - - - ); - } - - const processedData = reduceAdSenseData( daily?.rows || [] ); - - const currencyHeader = period.headers.find( - ( header ) => - null !== header.currencyCode && 0 < header.currencyCode.length - ); - const currencyCode = currencyHeader ? currencyHeader.currencyCode : false; - - return ( - - - - - - ) - } - context="compact" - /> - - - - - ) - } - context="compact" - /> - - - - - ) - } - context="compact" - /> - - - - - ); -} - -export default whenActive( { moduleName: 'adsense' } )( - DashboardSummaryWidget -); diff --git a/assets/js/modules/adsense/components/dashboard/index.js b/assets/js/modules/adsense/components/dashboard/index.js index 3242314865d..85d8bd602bd 100644 --- a/assets/js/modules/adsense/components/dashboard/index.js +++ b/assets/js/modules/adsense/components/dashboard/index.js @@ -17,7 +17,6 @@ */ export { default as DashboardZeroData } from './DashboardZeroData'; -export { default as DashboardSummaryWidget } from './DashboardSummaryWidget'; export { default as DashboardTopEarningPagesWidget } from './DashboardTopEarningPagesWidget'; export { default as AdBlockerWarningWidget } from './AdBlockerWarningWidget'; export { default as AdSenseConnectCTAWidget } from './AdSenseConnectCTAWidget'; diff --git a/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Header.js b/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Header.js index 22dda3ea7e9..1d0ed6e8359 100644 --- a/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Header.js +++ b/assets/js/modules/adsense/components/module/ModuleOverviewWidget/Header.js @@ -19,66 +19,34 @@ /** * WordPress dependencies */ -import { Fragment } from '@wordpress/element'; -import { __, sprintf, _n, _x } from '@wordpress/i18n'; +import { sprintf, _n } from '@wordpress/i18n'; /** * Internal dependencies */ -import { - MODULES_ADSENSE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { useFeature } from '../../../../../hooks/useFeature'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; import Data from 'googlesitekit-data'; const { useSelect } = Data; const Header = () => { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - - const dateRangeDates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const accountSiteURL = useSelect( ( select ) => - select( MODULES_ADSENSE ).getServiceReportURL( - generateDateRangeArgs( dateRangeDates ) - ) - ); const currentDayCount = useSelect( ( select ) => select( CORE_USER ).getDateRangeNumberOfDays() ); return ( - - - { ! unifiedDashboardEnabled && ( - + + /> ); }; diff --git a/assets/js/modules/adsense/components/module/ModuleOverviewWidget/index.js b/assets/js/modules/adsense/components/module/ModuleOverviewWidget/index.js index 7400ac38d74..49bbdfb32eb 100644 --- a/assets/js/modules/adsense/components/module/ModuleOverviewWidget/index.js +++ b/assets/js/modules/adsense/components/module/ModuleOverviewWidget/index.js @@ -32,7 +32,6 @@ import { __ } from '@wordpress/i18n'; */ import { MODULES_ADSENSE } from '../../../datastore/constants'; import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { useFeature } from '../../../../../hooks/useFeature'; import { isZeroReport } from '../../../util'; import DashboardZeroData from '../../dashboard/DashboardZeroData'; import { HIDDEN_CLASS } from '../../../../../googlesitekit/widgets/util/constants'; @@ -50,8 +49,6 @@ const ModuleOverviewWidget = ( { WidgetReportZero, WidgetReportError, } ) => { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - const [ selectedStats, setSelectedStats ] = useState( 0 ); const { @@ -127,11 +124,9 @@ const ModuleOverviewWidget = ( { ] ) ); - const widgetProps = unifiedDashboardEnabled ? { Footer } : {}; - if ( loading ) { return ( - + @@ -140,7 +135,7 @@ const ModuleOverviewWidget = ( { if ( error ) { return ( - + ); @@ -161,7 +156,7 @@ const ModuleOverviewWidget = ( { } return ( - + { - const { startDate, endDate } = select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ); - - return { - currentDayCount: select( CORE_USER ).getDateRangeNumberOfDays(), - analyticsMainURL: select( MODULES_ANALYTICS ).getServiceReportURL( - 'content-publisher-overview', - generateDateRangeArgs( { startDate, endDate } ) - ), - }; - } ); - - const title = sprintf( - /* translators: %s: number of days */ - _n( - 'Performance by page over the last %s day', - 'Performance by page over the last %s days', - currentDayCount, - 'google-site-kit' - ), - currentDayCount - ); - - const headerCTALabel = sprintf( - /* translators: %s: module name. */ - __( 'See full stats in %s', 'google-site-kit' ), - _x( 'Analytics', 'Service name', 'google-site-kit' ) - ); - - return ( - - - - - ); -} diff --git a/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/Table.js b/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/Table.js deleted file mode 100644 index 2ef9fe2555a..00000000000 --- a/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/Table.js +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Table component for the ModuleTopEarningPagesWidget widget. - * - * 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. - */ - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * External dependencies - */ -import PropTypes from 'prop-types'; -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import ReportTable from '../../../../../components/ReportTable'; -import TableOverflowContainer from '../../../../../components/TableOverflowContainer'; -import Link from '../../../../../components/Link'; -import { - MODULES_ANALYTICS, - DATE_RANGE_OFFSET, -} from '../../../../analytics/datastore/constants'; -import { MODULES_ADSENSE } from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { getCurrencyFormat } from '../../../util/currency'; -import { numFmt } from '../../../../../util'; -import { generateDateRangeArgs } from '../../../../analytics/util/report-date-range-args'; -import { ZeroDataMessage } from '../../../../analytics/components/common'; -const { useSelect, useInViewSelect } = Data; - -export default function Table( { report } ) { - const { startDate, endDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const adsenseData = useInViewSelect( ( select ) => - select( MODULES_ADSENSE ).getReport( { - startDate, - endDate, - metrics: 'ESTIMATED_EARNINGS', - } ) - ); - - const currencyFormat = getCurrencyFormat( adsenseData ); - - const tableColumns = [ - { - title: __( 'Page Title', 'google-site-kit' ), - description: __( 'Page Title', 'google-site-kit' ), - primary: true, - Component: ( { row } ) => { - const [ title, url ] = row.dimensions; - const dateRange = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const serviceURL = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'content-pages', - { - 'explorer-table.plotKeys': '[]', - '_r.drilldown': `analytics.pagePath:${ url }`, - ...generateDateRangeArgs( dateRange ), - } - ) - ); - return ( - - { title } - - ); - }, - }, - { - title: __( 'Earnings', 'google-site-kit' ), - description: __( 'Earnings', 'google-site-kit' ), - field: 'metrics.0.values.0', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, currencyFormat ) } - ), - }, - { - title: __( 'Page RPM', 'google-site-kit' ), - description: __( 'Page RPM', 'google-site-kit' ), - field: 'metrics.0.values.1', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, currencyFormat ) } - ), - }, - { - title: __( 'Impressions', 'google-site-kit' ), - description: __( 'Impressions', 'google-site-kit' ), - field: 'metrics.0.values.2', - hideOnMobile: true, - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, { style: 'decimal' } ) } - ), - }, - ]; - - return ( - - - - ); -} - -Table.propTypes = { - report: PropTypes.arrayOf( PropTypes.object ).isRequired, -}; diff --git a/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/index.js b/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/index.js deleted file mode 100644 index 3e109ec7776..00000000000 --- a/assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget/index.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * ModuleTopEarningPagesWidget module - * - * 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'; -import cloneDeep from 'lodash/cloneDeep'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import PreviewTable from '../../../../../components/PreviewTable'; -import AdSenseLinkCTA from '../../../../analytics/components/common/AdSenseLinkCTA'; -import { DATE_RANGE_OFFSET } from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { MODULES_ANALYTICS } from '../../../../analytics/datastore/constants'; -import { isZeroReport } from '../../../../analytics/util/is-zero-report'; -import WhenActive from '../../../../../util/when-active'; -import { isRestrictedMetricsError } from '../../../../analytics/util/error'; -import Header from './Header'; -import Table from './Table'; -const { useSelect, useInViewSelect } = Data; - -function ModuleTopEarningPagesWidget( { - Widget, - WidgetReportZero, - WidgetReportError, -} ) { - const { startDate, endDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const reportArgs = { - startDate, - endDate, - dimensions: [ 'ga:pagePath' ], - metrics: [ - { expression: 'ga:adsenseRevenue', alias: 'Earnings' }, - { expression: 'ga:adsenseECPM', alias: 'Page RPM' }, - { - expression: 'ga:adsensePageImpressions', - alias: 'Impressions', - }, - ], - orderby: { - fieldName: 'ga:adsenseRevenue', - sortOrder: 'DESCENDING', - }, - limit: 10, - }; - - const { isAdSenseLinked, error } = useSelect( ( select ) => { - return { - isAdSenseLinked: select( MODULES_ANALYTICS ).getAdsenseLinked(), - error: select( MODULES_ANALYTICS ).getErrorForSelector( - 'getReport', - [ reportArgs ] - ), - }; - } ); - - const data = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( reportArgs ) - ); - - const titles = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getPageTitles( data, reportArgs ) - ); - - const isLoading = useSelect( ( select ) => { - const hasLoadedPageTitles = undefined !== error || undefined !== titles; - - const hasLoaded = - hasLoadedPageTitles && - select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - reportArgs, - ] ); - - return ! hasLoaded; - } ); - - // A restricted metrics error will cause this value to change in the resolver - // so this check should happen before an error, which is only relevant if they are linked. - if ( ! isAdSenseLinked ) { - return ( - - - - ); - } - - if ( isLoading ) { - return ( - - - - ); - } - - if ( error && ! isRestrictedMetricsError( error ) ) { - return ( - - - - ); - } - - if ( isZeroReport( data ) || isRestrictedMetricsError( error ) ) { - return ( - - - - ); - } - - const rows = data?.[ 0 ]?.data?.rows?.length - ? cloneDeep( data[ 0 ].data.rows ) - : []; - - // Combine the titles from the pageTitles with the rows from the metrics report. - rows.forEach( ( row ) => { - const url = row.dimensions[ 0 ]; - row.dimensions.unshift( titles[ url ] ); // We always have an entry for titles[url]. - } ); - - return ( - - - - ); -} - -ModuleTopEarningPagesWidget.propTypes = { - Widget: PropTypes.func.isRequired, - WidgetReportZero: PropTypes.func.isRequired, - WidgetReportError: PropTypes.func.isRequired, -}; - -export default WhenActive( { moduleName: 'analytics' } )( - ModuleTopEarningPagesWidget -); diff --git a/assets/js/modules/adsense/components/module/index.js b/assets/js/modules/adsense/components/module/index.js index 0db02d7e6bf..5f4999e297c 100644 --- a/assets/js/modules/adsense/components/module/index.js +++ b/assets/js/modules/adsense/components/module/index.js @@ -16,5 +16,4 @@ * limitations under the License. */ -export { default as ModuleTopEarningPagesWidget } from './ModuleTopEarningPagesWidget'; export { default as ModuleOverviewWidget } from './ModuleOverviewWidget'; diff --git a/assets/js/modules/adsense/constants.js b/assets/js/modules/adsense/constants.js index ae1df7c1f1c..a8f40830a0e 100644 --- a/assets/js/modules/adsense/constants.js +++ b/assets/js/modules/adsense/constants.js @@ -17,6 +17,5 @@ */ export const ERROR_CODE_ADBLOCKER_ACTIVE = 'adblocker_active'; -export const CONTEXT_MODULE_ADSENSE = 'moduleAdsense'; export const AREA_MODULE_ADSENSE_MAIN = 'moduleAdsenseMain'; export const ADSENSE_CTA_WIDGET_DISMISSED_ITEM_KEY = 'adsense-connect-cta'; diff --git a/assets/js/modules/adsense/datastore/base.js b/assets/js/modules/adsense/datastore/base.js index b7ebaa278c2..083d7ccbd3a 100644 --- a/assets/js/modules/adsense/datastore/base.js +++ b/assets/js/modules/adsense/datastore/base.js @@ -20,7 +20,6 @@ * Internal dependencies */ import Modules from 'googlesitekit-modules'; -import { isFeatureEnabled } from '../../../features'; import { MODULES_ADSENSE } from './constants'; import { validateCanSubmitChanges } from './settings'; @@ -39,9 +38,6 @@ const baseModuleStore = Modules.createModuleStore( 'adsense', { 'webStoriesAdUnit', 'autoAdsDisabled', ], - adminPage: isFeatureEnabled( 'unifiedDashboard' ) - ? undefined - : 'googlesitekit-module-adsense', validateCanSubmitChanges, validateIsSetupBlocked: ( select ) => { if ( select( MODULES_ADSENSE ).isAdBlockerActive() ) { diff --git a/assets/js/modules/adsense/datastore/base.test.js b/assets/js/modules/adsense/datastore/base.test.js index 25e388b3665..19670233682 100644 --- a/assets/js/modules/adsense/datastore/base.test.js +++ b/assets/js/modules/adsense/datastore/base.test.js @@ -36,10 +36,7 @@ describe( 'modules/adsense base data store', () => { provideSiteInfo( registry ); } ); - it( 'does not define the admin page when unified dashboard is enabled', () => { - const { enabledFeatures } = require( '../../../features' ); - enabledFeatures.add( 'unifiedDashboard' ); - + it( 'does not define the admin page', () => { store = require( './base' ).default; registry.registerStore( MODULES_ADSENSE, store ); @@ -47,13 +44,4 @@ describe( 'modules/adsense base data store', () => { 'http://example.com/wp-admin/admin.php?page=googlesitekit-dashboard' ); } ); - - it( 'does define the admin page when unified dashboard is not enabled', () => { - store = require( './base' ).default; - registry.registerStore( MODULES_ADSENSE, store ); - - expect( registry.select( MODULES_ADSENSE ).getAdminScreenURL() ).toBe( - 'http://example.com/wp-admin/admin.php?page=googlesitekit-module-adsense' - ); - } ); } ); diff --git a/assets/js/modules/adsense/index.js b/assets/js/modules/adsense/index.js index 7f4a11b4c85..ad88b7fe95f 100644 --- a/assets/js/modules/adsense/index.js +++ b/assets/js/modules/adsense/index.js @@ -24,10 +24,7 @@ import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ -import { - AREA_DASHBOARD_EARNINGS, - AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY, -} from '../../googlesitekit/widgets/default-areas'; +import { AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY } from '../../googlesitekit/widgets/default-areas'; import { SetupMain } from './components/setup'; import { SetupMain as SetupMainV2 } from './components/setup/v2'; import { @@ -36,21 +33,17 @@ import { SettingsView, } from './components/settings'; import { - DashboardSummaryWidget, DashboardTopEarningPagesWidget, AdBlockerWarningWidget, AdSenseConnectCTAWidget, } from './components/dashboard'; -import ModuleTopEarningPagesWidget from './components/module/ModuleTopEarningPagesWidget'; import { ModuleOverviewWidget } from './components/module'; import AdSenseIcon from '../../../svg/graphics/adsense.svg'; import { MODULES_ADSENSE } from './datastore/constants'; import { AREA_MODULE_ADSENSE_MAIN, - CONTEXT_MODULE_ADSENSE, ERROR_CODE_ADBLOCKER_ACTIVE, } from './constants'; -import { WIDGET_AREA_STYLES } from '../../googlesitekit/widgets/datastore/constants'; import { isFeatureEnabled } from '../../features'; export { registerStore } from './datastore'; @@ -88,7 +81,6 @@ export const registerModule = ( modules ) => { data: null, }; }, - screenWidgetContext: CONTEXT_MODULE_ADSENSE, } ); }; @@ -105,104 +97,39 @@ export const registerWidgets = ( widgets ) => { [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY, AREA_MODULE_ADSENSE_MAIN ] ); - if ( isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'adsenseModuleOverview', - { - Component: ModuleOverviewWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 2, - wrapWidget: false, - modules: [ 'adsense' ], - }, - [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] - ); - - widgets.registerWidget( - 'adsenseConnectCTA', - { - Component: AdSenseConnectCTAWidget, - width: [ widgets.WIDGET_WIDTHS.FULL ], - priority: 2, - wrapWidget: false, - modules: [ 'adsense' ], - }, - [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] - ); - - widgets.registerWidget( - 'adsenseTopEarningPages', - { - Component: DashboardTopEarningPagesWidget, - width: [ - widgets.WIDGET_WIDTHS.HALF, - widgets.WIDGET_WIDTHS.FULL, - ], - priority: 3, - wrapWidget: false, - modules: [ 'adsense', 'analytics' ], - }, - [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] - ); - } + widgets.registerWidget( + 'adsenseModuleOverview', + { + Component: ModuleOverviewWidget, + width: widgets.WIDGET_WIDTHS.FULL, + priority: 2, + wrapWidget: false, + modules: [ 'adsense' ], + }, + [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] + ); - if ( ! isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidgetArea( - AREA_MODULE_ADSENSE_MAIN, - { - priority: 1, - style: WIDGET_AREA_STYLES.BOXES, - title: __( 'Overview', 'google-site-kit' ), - }, - CONTEXT_MODULE_ADSENSE - ); + widgets.registerWidget( + 'adsenseConnectCTA', + { + Component: AdSenseConnectCTAWidget, + width: [ widgets.WIDGET_WIDTHS.FULL ], + priority: 2, + wrapWidget: false, + modules: [ 'adsense' ], + }, + [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] + ); - widgets.registerWidget( - 'adsenseSummary', - { - Component: DashboardSummaryWidget, - width: widgets.WIDGET_WIDTHS.HALF, - priority: 1, - wrapWidget: false, - modules: [ 'adsense' ], - }, - [ AREA_DASHBOARD_EARNINGS ] - ); - widgets.registerWidget( - 'adsenseTopEarningPages', - { - Component: DashboardTopEarningPagesWidget, - width: [ - widgets.WIDGET_WIDTHS.HALF, - widgets.WIDGET_WIDTHS.FULL, - ], - priority: 2, - wrapWidget: false, - modules: [ 'adsense', 'analytics' ], - }, - [ AREA_DASHBOARD_EARNINGS ] - ); - widgets.registerWidget( - 'adsenseModuleOverview', - { - Component: ModuleOverviewWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 2, - wrapWidget: false, - modules: [ 'adsense' ], - }, - [ AREA_MODULE_ADSENSE_MAIN ] - ); - widgets.registerWidget( - 'adsenseModuleTopEarningPages', - { - Component: ModuleTopEarningPagesWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 2, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_MODULE_ADSENSE_MAIN ] - ); - } + widgets.registerWidget( + 'adsenseTopEarningPages', + { + Component: DashboardTopEarningPagesWidget, + width: [ widgets.WIDGET_WIDTHS.HALF, widgets.WIDGET_WIDTHS.FULL ], + priority: 3, + wrapWidget: false, + modules: [ 'adsense', 'analytics' ], + }, + [ AREA_MAIN_DASHBOARD_MONETIZATION_PRIMARY ] + ); }; diff --git a/assets/js/modules/analytics/components/dashboard/DashboardBounceRateWidget.js b/assets/js/modules/analytics/components/dashboard/DashboardBounceRateWidget.js deleted file mode 100644 index e221c8efbf6..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardBounceRateWidget.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * DashboardBounceRateWidget 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. - */ - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; -import { isURL } from '@wordpress/url'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../datastore/constants'; -import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import whenActive from '../../../../util/when-active'; -import PreviewBlock from '../../../../components/PreviewBlock'; -import DataBlock from '../../../../components/DataBlock'; -import Sparkline from '../../../../components/Sparkline'; -import { calculateChange, getURLPath } from '../../../../util'; -import parseDimensionStringToDate from '../../util/parseDimensionStringToDate'; -import { isZeroReport } from '../../util'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import { useFeature } from '../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -function DashboardBounceRateWidget( { WidgetReportZero, WidgetReportError } ) { - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const currentEntityURL = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - - const { compareStartDate, compareEndDate, startDate, endDate } = useSelect( - ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - compare: true, - } ) - ); - - const args = { - compareStartDate, - compareEndDate, - startDate, - endDate, - dimensions: 'ga:date', - metrics: [ - { - expression: 'ga:bounceRate', - alias: 'Bounce Rate', - }, - ], - }; - - let drilldown; - if ( isURL( currentEntityURL ) ) { - args.url = currentEntityURL; - drilldown = `analytics.pagePath:${ getURLPath( currentEntityURL ) }`; - } - - const error = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getErrorForSelector( 'getReport', [ args ] ) - ); - - const serviceURL = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( 'visitors-overview', { - '_r.drilldown': drilldown, - ...generateDateRangeArgs( { - startDate, - endDate, - compareStartDate, - compareEndDate, - } ), - } ) - ); - - const data = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( args ) - ); - - const loading = useSelect( - ( select ) => - ! select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - args, - ] ) - ); - - if ( loading ) { - return ; - } - - if ( error ) { - return ; - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ; - } - - const sparkLineData = [ - [ - { type: 'date', label: 'Day' }, - { type: 'number', label: 'Bounce Rate' }, - ], - ]; - - const dataRows = data?.[ 0 ]?.data?.rows || []; - // We only want half the date range, having a comparison date range in the query doubles the range. - for ( let i = Math.ceil( dataRows.length / 2 ); i < dataRows.length; i++ ) { - const { values } = dataRows[ i ].metrics[ 0 ]; - const dateString = dataRows[ i ].dimensions[ 0 ]; - const date = parseDimensionStringToDate( dateString ); - sparkLineData.push( [ date, values[ 0 ] ] ); - } - - const { totals } = data[ 0 ].data; - const bounceRate = totals[ 0 ].values[ 0 ] / 100.0; - const previousBounceRate = totals[ 1 ].values[ 0 ] / 100.0; - const bounceRateChange = calculateChange( previousBounceRate, bounceRate ); - - return ( - - } - gatheringData={ isGatheringData } - /> - ); -} - -export default whenActive( { - moduleName: 'analytics', - FallbackComponent: ( { WidgetActivateModuleCTA } ) => ( - - ), - IncompleteComponent: ( { WidgetCompleteModuleActivationCTA } ) => ( - - ), -} )( DashboardBounceRateWidget ); diff --git a/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.js b/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.js deleted file mode 100644 index 2969efb6c66..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.js +++ /dev/null @@ -1,237 +0,0 @@ -/** - * DashboardGoalsWidget 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. - */ - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../datastore/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants'; -import whenActive from '../../../../util/when-active'; -import PreviewBlock from '../../../../components/PreviewBlock'; -import DataBlock from '../../../../components/DataBlock'; -import Sparkline from '../../../../components/Sparkline'; -import CTA from '../../../../components/notifications/CTA'; -import { calculateChange } from '../../../../util'; -import parseDimensionStringToDate from '../../util/parseDimensionStringToDate'; -import { isZeroReport } from '../../util'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import { useFeature } from '../../../../hooks/useFeature'; -import useViewOnly from '../../../../hooks/useViewOnly'; -const { useSelect, useInViewSelect } = Data; - -function DashboardGoalsWidget( { - WidgetNull, - WidgetReportZero, - WidgetReportError, -} ) { - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const viewOnlyDashboard = useViewOnly(); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const url = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - - const { compareStartDate, compareEndDate, startDate, endDate } = useSelect( - ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - compare: true, - } ) - ); - - const args = { - compareStartDate, - compareEndDate, - startDate, - endDate, - dimensions: 'ga:date', - metrics: [ - { - expression: 'ga:goalCompletionsAll', - alias: 'Goal Completions', - }, - ], - }; - - const totalUsersArgs = { - startDate, - endDate, - url, - compareStartDate, - compareEndDate, - metrics: [ - { - expression: 'ga:users', - alias: 'Total Users', - }, - ], - }; - - const { error, loading, serviceURL } = useSelect( ( select ) => { - const store = select( MODULES_ANALYTICS ); - - const isLoading = - ! store.hasFinishedResolution( 'getGoals', [] ) || - ! store.hasFinishedResolution( 'getReport', [ args ] ) || - ! store.hasFinishedResolution( 'getReport', [ totalUsersArgs ] ); - - return { - error: - store.getErrorForSelector( 'getGoals', [] ) || - store.getErrorForSelector( 'getReport', [ args ] ), - loading: isLoading, - serviceURL: store.getServiceReportURL( - 'conversions-goals-overview', - { - ...generateDateRangeArgs( { - startDate, - endDate, - compareStartDate, - compareEndDate, - } ), - } - ), - }; - } ); - - const goals = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getGoals() - ); - - const report = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( args ) - ); - - const totalUsers = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( totalUsersArgs ) - ); - - const supportURL = useSelect( ( select ) => - select( CORE_SITE ).getGoogleSupportURL( { - path: '/analytics/answer/1032415', - hash: 'create_or_edit_goals', - } ) - ); - - if ( error ) { - return ; - } - - if ( loading || isGatheringData === undefined ) { - return ; - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( totalUsers ) ) { - return ; - } - - if ( ! goals?.items?.length ) { - if ( viewOnlyDashboard ) { - return ; - } - - return ( - - ); - } - - const sparkLineData = [ - [ - { type: 'date', label: 'Day' }, - { type: 'number', label: 'Bounce Rate' }, - ], - ]; - - const { totals = [], rows = [] } = report?.[ 0 ]?.data || {}; - - // We only want half the date range, having a comparison date range in the query doubles the range. - for ( let i = Math.ceil( rows.length / 2 ); i < rows.length; i++ ) { - const { values } = rows[ i ].metrics[ 0 ]; - const dateString = rows[ i ].dimensions[ 0 ]; - const date = parseDimensionStringToDate( dateString ); - sparkLineData.push( [ date, values[ 0 ] ] ); - } - - const lastMonth = totals[ 0 ]?.values || []; - const previousMonth = totals[ 1 ]?.values || []; - const goalCompletions = lastMonth[ 0 ] || 0; - const goalCompletionsChange = calculateChange( - previousMonth[ 0 ] || 0, - lastMonth[ 0 ] || 0 - ); - - return ( - - } - gatheringData={ isGatheringData } - /> - ); -} - -export default whenActive( { - moduleName: 'analytics', - FallbackComponent: ( { WidgetActivateModuleCTA } ) => ( - - ), - IncompleteComponent: ( { WidgetCompleteModuleActivationCTA } ) => ( - - ), -} )( DashboardGoalsWidget ); diff --git a/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.stories.js b/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.stories.js deleted file mode 100644 index b637b0bb820..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardGoalsWidget.stories.js +++ /dev/null @@ -1,262 +0,0 @@ -/** - * DashboardGoalsWidget Component Stories. - * - * Site Kit by Google, Copyright 2022 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 { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import { MODULES_ANALYTICS } from '../../datastore/constants'; -import { provideModules } from '../../../../../../tests/js/utils'; -import { replaceValuesInAnalyticsReportWithZeroData } from '../../../../../../.storybook/utils/zeroReports'; -import { withWidgetComponentProps } from '../../../../googlesitekit/widgets/util'; -import { - provideAnalyticsMockReport, - getAnalyticsMockResponse, -} from '../../util/data-mock'; -import { goals } from '../../datastore/__fixtures__'; -import WithRegistrySetup from '../../../../../../tests/js/WithRegistrySetup'; -import DashboardGoalsWidget from './DashboardGoalsWidget'; -import { VIEW_CONTEXT_DASHBOARD_VIEW_ONLY } from '../../../../googlesitekit/constants'; -import { Provider } from '../../../../components/Root/ViewContextContext'; - -const gatheringReportOptions = { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-12-02', - endDate: '2020-12-29', -}; - -const reportOptions = [ - { - compareStartDate: '2020-11-04', - compareEndDate: '2020-12-01', - startDate: '2020-12-02', - endDate: '2020-12-29', - dimensions: 'ga:date', - metrics: [ - { - expression: 'ga:goalCompletionsAll', - alias: 'Goal Completions', - }, - ], - }, - { - compareStartDate: '2020-11-04', - compareEndDate: '2020-12-01', - startDate: '2020-12-02', - endDate: '2020-12-29', - url: null, - metrics: [ - { - expression: 'ga:users', - alias: 'Total Users', - }, - ], - }, -]; - -const WidgetWithComponentProps = withWidgetComponentProps( 'widget-slug' )( - DashboardGoalsWidget -); - -const Template = ( { setupRegistry, ...args } ) => ( - - - -); - -export const Ready = Template.bind( {} ); -Ready.storyName = 'Ready'; -Ready.args = { - setupRegistry: ( registry ) => { - for ( const options of reportOptions ) { - provideAnalyticsMockReport( registry, options ); - } - }, -}; - -export const Loading = Template.bind( {} ); -Loading.storyName = 'Loading'; -Loading.args = { - setupRegistry: ( { dispatch } ) => { - dispatch( MODULES_ANALYTICS ).startResolution( 'getReport', [ - reportOptions[ 0 ], - ] ); - }, -}; - -export const DataUnavailable = Template.bind( {} ); -DataUnavailable.storyName = 'Data Unavailable'; -DataUnavailable.args = { - setupRegistry: ( { dispatch } ) => { - dispatch( MODULES_ANALYTICS ).receiveGetReport( [], { - options: gatheringReportOptions, - } ); - - for ( const options of reportOptions ) { - dispatch( MODULES_ANALYTICS ).receiveGetReport( [], { options } ); - } - }, -}; - -export const ZeroData = Template.bind( {} ); -ZeroData.storyName = 'Zero Data'; -ZeroData.args = { - setupRegistry: ( { dispatch } ) => { - for ( const options of reportOptions ) { - const report = getAnalyticsMockResponse( options ); - - dispatch( MODULES_ANALYTICS ).receiveGetReport( - replaceValuesInAnalyticsReportWithZeroData( report ), - { - options, - } - ); - } - }, -}; - -export const NoGoalsSet = Template.bind( {} ); -NoGoalsSet.storyName = 'No Goals Set (CTA)'; -NoGoalsSet.args = { - setupRegistry: ( { dispatch } ) => { - for ( const options of reportOptions ) { - const report = getAnalyticsMockResponse( options ); - - dispatch( MODULES_ANALYTICS ).receiveGetReport( report, { - options, - } ); - } - - const emptyGoals = { ...goals, items: [] }; - - dispatch( MODULES_ANALYTICS ).receiveGetGoals( emptyGoals ); - }, -}; -NoGoalsSet.parameters = { - features: [ 'zeroDataStates' ], -}; - -export const NoGoalsSetViewOnly = Template.bind( {} ); -NoGoalsSetViewOnly.storyName = 'No Goals Set (View-only)'; -NoGoalsSetViewOnly.args = { - setupRegistry: ( { dispatch } ) => { - for ( const options of reportOptions ) { - const report = getAnalyticsMockResponse( options ); - - dispatch( MODULES_ANALYTICS ).receiveGetReport( report, { - options, - } ); - } - - const emptyGoals = { ...goals, items: [] }; - - dispatch( MODULES_ANALYTICS ).receiveGetGoals( emptyGoals ); - }, -}; -NoGoalsSetViewOnly.decorators = [ - ( Story ) => { - return ( - - - - ); - }, -]; -NoGoalsSetViewOnly.parameters = { - features: [ 'zeroDataStates' ], -}; - -export const Error = Template.bind( {} ); -Error.storyName = 'Error'; -Error.args = { - setupRegistry: ( { dispatch } ) => { - const error = { - code: 'test_error', - message: 'Request parameter is empty: metrics.', - data: {}, - }; - const options = reportOptions[ 0 ]; - - dispatch( MODULES_ANALYTICS ).receiveError( error, 'getReport', [ - options, - ] ); - - dispatch( MODULES_ANALYTICS ).finishResolution( 'getReport', [ - options, - ] ); - }, -}; - -export const GatheringDataZeroDataStates = Template.bind( {} ); -GatheringDataZeroDataStates.storyName = 'Gathering Data'; -GatheringDataZeroDataStates.args = { - setupRegistry: ( { dispatch } ) => { - dispatch( MODULES_ANALYTICS ).receiveGetReport( - {}, - { - options: gatheringReportOptions, - } - ); - - for ( const options of reportOptions ) { - dispatch( MODULES_ANALYTICS ).receiveGetReport( {}, { options } ); - } - }, -}; -GatheringDataZeroDataStates.parameters = { - features: [ 'zeroDataStates' ], -}; - -export default { - title: 'Modules/Analytics/Widgets/DashboardGoalsWidget', - decorators: [ - ( Story ) => ( -
-
- -
-
- ), - ( Story, { args } ) => { - const setupRegistry = ( registry ) => { - provideModules( registry, [ - { - active: true, - connected: true, - slug: 'analytics', - }, - ] ); - - registry.dispatch( CORE_USER ).setReferenceDate( '2020-12-30' ); - registry.dispatch( MODULES_ANALYTICS ).receiveGetGoals( goals ); - - provideAnalyticsMockReport( registry, gatheringReportOptions ); - - // Call story-specific setup. - args.setupRegistry( registry ); - }; - - return ( - - - - ); - }, - ], -}; diff --git a/assets/js/modules/analytics/components/dashboard/DashboardPopularPagesWidget.js b/assets/js/modules/analytics/components/dashboard/DashboardPopularPagesWidget.js deleted file mode 100644 index d992eac606c..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardPopularPagesWidget.js +++ /dev/null @@ -1,200 +0,0 @@ -/** - * DashboardPopularPagesWidget 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 cloneDeep from 'lodash/cloneDeep'; - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../datastore/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import whenActive from '../../../../util/when-active'; -import PreviewTable from '../../../../components/PreviewTable'; -import SourceLink from '../../../../components/SourceLink'; -import { isZeroReport } from '../../util'; -import TableOverflowContainer from '../../../../components/TableOverflowContainer'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import ReportTable from '../../../../components/ReportTable'; -import DetailsPermaLinks from '../../../../components/DetailsPermaLinks'; -import { numFmt } from '../../../../util'; -import { ZeroDataMessage } from '../common'; -import { useFeature } from '../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -function DashboardPopularPagesWidget( props ) { - const { Widget, WidgetReportZero, WidgetReportError } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const { startDate, endDate, compareStartDate, compareEndDate } = useSelect( - ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const args = { - startDate, - endDate, - dimensions: [ 'ga:pagePath' ], - metrics: [ - { - expression: 'ga:pageviews', - alias: 'Pageviews', - }, - ], - orderby: [ - { - fieldName: 'ga:pageviews', - sortOrder: 'DESCENDING', - }, - ], - limit: 10, - }; - - const analyticsMainURL = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'content-pages', - generateDateRangeArgs( { - startDate, - endDate, - compareStartDate, - compareEndDate, - } ) - ) - ); - - const error = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getErrorForSelector( 'getReport', [ args ] ) - ); - - const data = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( args ) - ); - - const titles = useInViewSelect( ( select ) => - ! error - ? select( MODULES_ANALYTICS ).getPageTitles( data, args ) - : undefined - ); - - const loading = useSelect( ( select ) => { - const hasLoadedPageTitles = undefined !== error || undefined !== titles; - const hasLoaded = - hasLoadedPageTitles && - select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - args, - ] ); - - return ! hasLoaded; - } ); - - const Footer = () => ( - - ); - - if ( loading || isGatheringData === undefined ) { - return ( - - - - ); - } - - if ( error ) { - return ( - - - - ); - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ( - - - - ); - } - - const rows = data?.[ 0 ]?.data?.rows?.length - ? cloneDeep( data[ 0 ].data.rows ) - : []; - - // Combine the titles from the pageTitles with the rows from the metrics report. - rows.forEach( ( row ) => { - const url = row.dimensions[ 0 ]; - row.dimensions.unshift( titles[ url ] ); // We always have an entry for titles[url]. - } ); - - return ( - - - - - - ); -} - -const tableColumns = [ - { - title: __( 'Most popular content', 'google-site-kit' ), - primary: true, - Component: ( { row } ) => { - const [ title, path ] = row.dimensions; - return ; - }, - }, - { - title: __( 'Views', 'google-site-kit' ), - field: 'metrics.0.values.0', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, { style: 'decimal' } ) } - ), - }, -]; - -export default whenActive( { moduleName: 'analytics' } )( - DashboardPopularPagesWidget -); diff --git a/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.js b/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.js deleted file mode 100644 index b7c5d9d6b22..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.js +++ /dev/null @@ -1,219 +0,0 @@ -/** - * DashboardSearchVisitorsWidget 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. - */ - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; -import { isURL } from '@wordpress/url'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../datastore/constants'; -import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import whenActive from '../../../../util/when-active'; -import PreviewBlock from '../../../../components/PreviewBlock'; -import DataBlock from '../../../../components/DataBlock'; -import Sparkline from '../../../../components/Sparkline'; -import { calculateChange, getURLPath } from '../../../../util'; -import parseDimensionStringToDate from '../../util/parseDimensionStringToDate'; -import { isZeroReport } from '../../util'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import { useFeature } from '../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -function DashboardSearchVisitorsWidget( props ) { - const { WidgetReportZero, WidgetReportError } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - const url = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - - const { compareStartDate, compareEndDate, startDate, endDate } = useSelect( - ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - compare: true, - } ) - ); - - const commonArgs = { - startDate, - endDate, - metrics: [ - { - expression: 'ga:users', - alias: 'Users', - }, - ], - ...( url && { url } ), - }; - - const sparklineArgs = { - dimensions: [ 'ga:date' ], - dimensionFilters: { 'ga:channelGrouping': 'Organic Search' }, - ...commonArgs, - }; - - // This request needs to be separate from the sparkline request because it would result in a different total if it included the ga:date dimension. - const visitorsArgs = { - compareStartDate, - compareEndDate, - dimensionFilters: { 'ga:channelGrouping': 'Organic Search' }, - ...commonArgs, - }; - - const totalUsersArgs = { - compareStartDate, - compareEndDate, - ...commonArgs, - }; - - const { loading, error, serviceURL } = useSelect( ( select ) => { - const store = select( MODULES_ANALYTICS ); - - const drilldowns = [ 'analytics.trafficChannel:Organic Search' ]; - if ( isURL( url ) ) { - drilldowns.push( `analytics.pagePath:${ getURLPath( url ) }` ); - } - - return { - loading: - ! store.hasFinishedResolution( 'getReport', [ - sparklineArgs, - ] ) || - ! store.hasFinishedResolution( 'getReport', [ - visitorsArgs, - ] ) || - ! store.hasFinishedResolution( 'getReport', [ - totalUsersArgs, - ] ), - error: - store.getErrorForSelector( 'getReport', [ sparklineArgs ] ) || - store.getErrorForSelector( 'getReport', [ visitorsArgs ] ) || - store.getErrorForSelector( 'getReport', [ totalUsersArgs ] ), - serviceURL: store.getServiceReportURL( 'acquisition-channels', { - '_r.drilldown': drilldowns.join( ',' ), - ...generateDateRangeArgs( { - startDate, - endDate, - compareStartDate, - compareEndDate, - } ), - } ), - }; - } ); - - const sparkData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( sparklineArgs ) - ); - - const visitorsData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( visitorsArgs ) - ); - - const totalUsersData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( totalUsersArgs ) - ); - - if ( error ) { - return ; - } - - if ( loading || isGatheringData === undefined ) { - return ; - } - - if ( - ! zeroDataStates && - isGatheringData && - ( isZeroReport( sparkData ) || isZeroReport( visitorsData ) ) && - isZeroReport( totalUsersData ) - ) { - return ; - } - - const sparkLineData = [ - [ - { type: 'date', label: 'Day' }, - { type: 'number', label: 'Unique Visitors from Search' }, - ], - ]; - - const dataRows = sparkData?.[ 0 ]?.data?.rows || []; - - // Loop the rows to build the chart data. - for ( let i = 0; i < dataRows.length; i++ ) { - const { values } = dataRows[ i ].metrics[ 0 ]; - const dateString = dataRows[ i ].dimensions[ 0 ]; - const date = parseDimensionStringToDate( dateString ); - sparkLineData.push( [ date, values[ 0 ] ] ); - } - - const { totals = [] } = visitorsData?.[ 0 ]?.data || {}; - const totalVisitors = totals[ 0 ]?.values?.[ 0 ] || 0; - const previousTotalVisitors = totals[ 1 ]?.values?.[ 0 ] || 0; - const totalVisitorsChange = calculateChange( - previousTotalVisitors, - totalVisitors - ); - - return ( - - } - gatheringData={ isGatheringData } - /> - ); -} - -export default whenActive( { - moduleName: 'analytics', - FallbackComponent: ( { WidgetActivateModuleCTA } ) => ( - - ), - IncompleteComponent: ( { WidgetCompleteModuleActivationCTA } ) => ( - - ), -} )( DashboardSearchVisitorsWidget ); diff --git a/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.stories.js b/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.stories.js deleted file mode 100644 index 582aa702c13..00000000000 --- a/assets/js/modules/analytics/components/dashboard/DashboardSearchVisitorsWidget.stories.js +++ /dev/null @@ -1,314 +0,0 @@ -/** - * DashboardSearchVisitorsWidget 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 { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import { MODULES_ANALYTICS } from '../../datastore/constants'; -import { - provideModules, - provideSiteInfo, -} from '../../../../../../tests/js/utils'; -import { replaceValuesInAnalyticsReportWithZeroData } from '../../../../../../.storybook/utils/zeroReports'; -import { withWidgetComponentProps } from '../../../../googlesitekit/widgets/util'; -import { - provideAnalyticsMockReport, - getAnalyticsMockResponse, -} from '../../util/data-mock'; -import WithRegistrySetup from '../../../../../../tests/js/WithRegistrySetup'; -import DashboardSearchVisitorsWidget from './DashboardSearchVisitorsWidget'; - -const gatheringReportOptions = { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-08-11', - endDate: '2020-09-07', - // url: 'https://www.sitekit.com/', -}; - -const reportOptions = [ - { - // visitorsArgs - compareStartDate: '2020-07-14', - compareEndDate: '2020-08-10', - startDate: '2020-08-11', - endDate: '2020-09-07', - dimensionFilters: { 'ga:channelGrouping': 'Organic Search' }, - metrics: [ - { - expression: 'ga:users', - alias: 'Users', - }, - ], - }, - { - // sparklineArgs - startDate: '2020-08-11', - endDate: '2020-09-07', - dimensionFilters: { 'ga:channelGrouping': 'Organic Search' }, - dimensions: [ 'ga:date' ], - metrics: [ - { - expression: 'ga:users', - alias: 'Users', - }, - ], - }, - { - // totalUsersArgs - startDate: '2020-08-11', - endDate: '2020-09-07', - compareStartDate: '2020-07-14', - compareEndDate: '2020-08-10', - metrics: [ - { - expression: 'ga:users', - alias: 'Users', - }, - ], - }, -]; -const currentEntityURL = 'https://www.example.com/example-page/'; -const reportOptionsWithEntity = reportOptions.map( ( options ) => { - return { - ...options, - url: currentEntityURL, - }; -} ); - -const WidgetWithComponentProps = withWidgetComponentProps( 'widget-slug' )( - DashboardSearchVisitorsWidget -); - -const Template = ( { setupRegistry, ...args } ) => ( - - - -); - -export const Ready = Template.bind( {} ); -Ready.storyName = 'Ready'; -Ready.args = { - setupRegistry: ( registry ) => { - for ( const options of reportOptions ) { - provideAnalyticsMockReport( registry, options ); - } - }, -}; - -export const Loading = Template.bind( {} ); -Loading.storyName = 'Loading'; -Loading.args = { - setupRegistry: ( { dispatch } ) => { - dispatch( MODULES_ANALYTICS ).startResolution( 'getReport', [ - reportOptions[ 0 ], - ] ); - }, -}; - -export const DataUnavailable = Template.bind( {} ); -DataUnavailable.storyName = 'Data Unavailable'; -DataUnavailable.args = { - setupRegistry: ( { dispatch } ) => { - dispatch( MODULES_ANALYTICS ).receiveGetReport( [], { - options: gatheringReportOptions, - } ); - - for ( const options of reportOptions ) { - dispatch( MODULES_ANALYTICS ).receiveGetReport( [], { options } ); - } - }, -}; - -export const ZeroData = Template.bind( {} ); -ZeroData.storyName = 'Zero Data'; -ZeroData.args = { - setupRegistry: ( { dispatch } ) => { - for ( const options of reportOptions ) { - const report = getAnalyticsMockResponse( options ); - - dispatch( MODULES_ANALYTICS ).receiveGetReport( - replaceValuesInAnalyticsReportWithZeroData( report ), - { - options, - } - ); - } - }, -}; - -export const Error = Template.bind( {} ); -Error.storyName = 'Error'; -Error.args = { - setupRegistry: ( { dispatch } ) => { - const error = { - code: 'test_error', - message: 'Error message.', - data: {}, - }; - const options = reportOptions[ 0 ]; - - dispatch( MODULES_ANALYTICS ).receiveError( error, 'getReport', [ - options, - ] ); - - dispatch( MODULES_ANALYTICS ).finishResolution( 'getReport', [ - options, - ] ); - }, -}; - -export const LoadedEntityURL = Template.bind( {} ); -LoadedEntityURL.storyName = 'Ready with entity URL set'; -LoadedEntityURL.args = { - setupRegistry: ( registry ) => { - provideSiteInfo( registry, { currentEntityURL } ); - provideAnalyticsMockReport( registry, { - ...gatheringReportOptions, - url: currentEntityURL, - } ); - - for ( const options of reportOptionsWithEntity ) { - provideAnalyticsMockReport( registry, options ); - } - }, -}; - -export const LoadingEntityURL = Template.bind( {} ); -LoadingEntityURL.storyName = 'Loading with entity URL set'; -LoadingEntityURL.args = { - setupRegistry: ( registry ) => { - provideSiteInfo( registry, { currentEntityURL } ); - provideAnalyticsMockReport( registry, { - ...gatheringReportOptions, - url: currentEntityURL, - } ); - - registry - .dispatch( MODULES_ANALYTICS ) - .startResolution( 'getReport', [ reportOptionsWithEntity[ 0 ] ] ); - }, -}; - -export const DataUnavailableEntityURL = Template.bind( {} ); -DataUnavailableEntityURL.storyName = 'Data Unavailable with entity URL set'; -DataUnavailableEntityURL.args = { - setupRegistry: ( registry ) => { - provideSiteInfo( registry, { currentEntityURL } ); - - registry.dispatch( MODULES_ANALYTICS ).receiveGetReport( [], { - options: { - ...gatheringReportOptions, - url: currentEntityURL, - }, - } ); - - registry - .dispatch( MODULES_ANALYTICS ) - .receiveGetReport( [], { options: reportOptionsWithEntity[ 0 ] } ); - }, -}; - -export const ZeroDataEntityURL = Template.bind( {} ); -ZeroDataEntityURL.storyName = 'Zero Data with entity URL set'; -ZeroDataEntityURL.args = { - setupRegistry: ( registry ) => { - provideSiteInfo( registry, { currentEntityURL } ); - provideAnalyticsMockReport( registry, { - ...gatheringReportOptions, - url: currentEntityURL, - } ); - - for ( const options of reportOptionsWithEntity ) { - const report = getAnalyticsMockResponse( options ); - - registry - .dispatch( MODULES_ANALYTICS ) - .receiveGetReport( - replaceValuesInAnalyticsReportWithZeroData( report ), - { - options, - } - ); - } - }, -}; - -export const ErrorEntityURL = Template.bind( {} ); -ErrorEntityURL.storyName = 'Error with entity URL set'; -ErrorEntityURL.args = { - setupRegistry: ( registry ) => { - const error = { - code: 'test_error', - message: 'Error with entity URL set.', - data: {}, - }; - - provideSiteInfo( registry, { currentEntityURL } ); - provideAnalyticsMockReport( registry, { - ...gatheringReportOptions, - url: currentEntityURL, - } ); - - const options = reportOptionsWithEntity[ 0 ]; - registry - .dispatch( MODULES_ANALYTICS ) - .receiveError( error, 'getReport', [ options ] ); - registry - .dispatch( MODULES_ANALYTICS ) - .finishResolution( 'getReport', [ options ] ); - }, -}; - -export default { - title: 'Modules/Analytics/Widgets/DashboardSearchVisitorsWidget', - decorators: [ - ( Story ) => ( -
-
- -
-
- ), - ( Story, { args } ) => { - const setupRegistry = ( registry ) => { - provideModules( registry, [ - { - active: true, - connected: true, - slug: 'analytics', - }, - ] ); - - registry.dispatch( CORE_USER ).setReferenceDate( '2020-09-08' ); - - provideAnalyticsMockReport( registry, gatheringReportOptions ); - - // Call story-specific setup. - args.setupRegistry( registry ); - }; - - return ( - - - - ); - }, - ], -}; diff --git a/assets/js/modules/analytics/components/dashboard/index.js b/assets/js/modules/analytics/components/dashboard/index.js index e5de93982ce..7bef5ce0655 100644 --- a/assets/js/modules/analytics/components/dashboard/index.js +++ b/assets/js/modules/analytics/components/dashboard/index.js @@ -17,8 +17,4 @@ */ export { default as DashboardAllTrafficWidget } from './DashboardAllTrafficWidget'; -export { default as DashboardPopularPagesWidget } from './DashboardPopularPagesWidget'; -export { default as DashboardBounceRateWidget } from './DashboardBounceRateWidget'; -export { default as DashboardGoalsWidget } from './DashboardGoalsWidget'; -export { default as DashboardSearchVisitorsWidget } from './DashboardSearchVisitorsWidget'; export { default as DashboardOverallPageMetricsWidget } from './DashboardOverallPageMetricsWidget'; diff --git a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/AcquisitionChannelsTable.js b/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/AcquisitionChannelsTable.js deleted file mode 100644 index d44b4b6aced..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/AcquisitionChannelsTable.js +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Table 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'; - -/** - * WordPress dependencies - */ -import { __, _n, sprintf } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { numFmt } from '../../../../../util'; -import MiniChart from '../../../../../components/MiniChart'; -import ReportTable from '../../../../../components/ReportTable'; -import { ZeroDataMessage } from '../../common'; -const { useSelect } = Data; - -export default function AcquisitionChannelsTable( { report, gatheringData } ) { - const dateRangeNumberOfDays = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - - const totalUsers = report?.[ 0 ]?.data?.totals?.[ 0 ]?.values?.[ 1 ]; - let iterator = -1; // We pre-increment, hence starting at -1. - - const tableColumns = [ - { - title: __( 'Channel', 'google-site-kit' ), - tooltip: __( - 'Channel refers to where your traffic originated from', - 'google-site-kit' - ), - Component: ( { row } ) => { row.dimensions[ 0 ] }, - }, - { - title: __( 'Users', 'google-site-kit' ), - tooltip: __( - 'Number of users that originated from that traffic', - 'google-site-kit' - ), - field: 'metrics.0.values.0', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, { style: 'decimal' } ) } - ), - }, - { - title: __( 'New Users', 'google-site-kit' ), - tooltip: sprintf( - /* translators: %s: number of days */ - _n( - 'Number of new users to visit your page over last %s day', - 'Number of new users to visit your page over last %s days', - dateRangeNumberOfDays, - 'google-site-kit' - ), - dateRangeNumberOfDays - ), - field: 'metrics.0.values.1', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, { style: 'decimal' } ) } - ), - }, - { - title: __( 'Sessions', 'google-site-kit' ), - tooltip: sprintf( - /* translators: %s: number of days */ - _n( - 'Number of sessions users had on your website over last %s day', - 'Number of sessions users had on your website over last %s days', - dateRangeNumberOfDays, - 'google-site-kit' - ), - dateRangeNumberOfDays - ), - field: 'metrics.0.values.2', - Component: ( { fieldValue } ) => ( - { numFmt( fieldValue, { style: 'decimal' } ) } - ), - }, - { - title: __( 'Percentage', 'google-site-kit' ), - tooltip: __( 'Percentage of sessions', 'google-site-kit' ), - field: 'metrics.0.values.1', - Component: ( { fieldValue } ) => { - let change = 0; - // Avoid potentially dividing by zero. - if ( 0 < totalUsers ) { - change = fieldValue / totalUsers; - } - iterator += 1; - return ( -
- { numFmt( isFinite( change ) ? change : 0, '%' ) } - -
- ); - }, - }, - ]; - - return ( -
- -
- ); -} - -AcquisitionChannelsTable.propTypes = { - report: PropTypes.arrayOf( PropTypes.object ), - gatheringData: PropTypes.bool, -}; diff --git a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Footer.js b/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Footer.js deleted file mode 100644 index e738df048c9..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Footer.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Footer component for ModuleAcquisitionChannelsWidget 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. - */ - -/** - * WordPress dependencies - */ -import { _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - MODULES_ANALYTICS, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import SourceLink from '../../../../../components/SourceLink'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; -const { useSelect } = Data; - -export default function Footer() { - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const url = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'trafficsources-overview', - generateDateRangeArgs( dates ) - ) - ); - return ( - - ); -} diff --git a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Header.js b/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Header.js deleted file mode 100644 index 02ae00e2379..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/Header.js +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Header component for ModuleAcquisitionChannelsWidget 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. - */ - -/** - * WordPress dependencies - */ -import { sprintf, _x, __, _n } from '@wordpress/i18n'; -import { Fragment } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - MODULES_ANALYTICS, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; -const { useSelect } = Data; - -export default function Header() { - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const url = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'trafficsources-overview', - generateDateRangeArgs( dates ) - ) - ); - const dateRangeNumberOfDays = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - const title = sprintf( - /* translators: %s: number of days */ - _n( - 'Top acquisition channels over the last %s day', - 'Top acquisition channels over the last %s days', - dateRangeNumberOfDays, - 'google-site-kit' - ), - dateRangeNumberOfDays - ); - - const headerCTALabel = sprintf( - /* translators: %s: module name. */ - __( 'See full stats in %s', 'google-site-kit' ), - _x( 'Analytics', 'Service name', 'google-site-kit' ) - ); - - return ( - - - - - ); -} diff --git a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/PieChart.js b/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/PieChart.js deleted file mode 100644 index 926e6d43396..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/PieChart.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * PieChart 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 GoogleChart from '../../../../../components/GoogleChart'; -import { extractAnalyticsDataForPieChart } from '../../../util'; - -export default function PieChart( { report, gatheringData } ) { - const processedData = extractAnalyticsDataForPieChart( report, { - keyColumnIndex: 1, - } ); - - return ( -
- -
- ); -} - -PieChart.options = { - chartArea: { - width: '100%', - height: '100%', - }, - backgroundColor: 'transparent', - height: 250, - legend: { - alignment: 'center', - textStyle: { - color: '#5b5b61', - fontSize: 12, - }, - }, - slices: { - 0: { color: '#178EC5' }, - 1: { color: '#54B23B' }, - 2: { color: '#EB5729' }, - 3: { color: '#ECED33' }, - 4: { color: '#34CBE3' }, - 5: { color: '#82E88E' }, - }, - title: null, - width: '100%', -}; - -PieChart.propTypes = { - report: PropTypes.arrayOf( PropTypes.object ), - gatheringData: PropTypes.bool, -}; diff --git a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/index.js b/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/index.js deleted file mode 100644 index 217ef6fb448..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleAcquisitionChannelsWidget/index.js +++ /dev/null @@ -1,170 +0,0 @@ -/** - * ModuleAcquisitionChannelsWidget 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 { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../../datastore/constants'; -import { isZeroReport } from '../../../util'; -import { Cell, Grid, Row } from '../../../../../material-components'; -import PreviewBlock from '../../../../../components/PreviewBlock'; -import PreviewTable from '../../../../../components/PreviewTable'; -import Header from './Header'; -import AcquisitionChannelsTable from './AcquisitionChannelsTable'; -import PieChart from './PieChart'; -import Footer from './Footer'; -import { useFeature } from '../../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -export default function ModuleAcquisitionChannelsWidget( props ) { - const { Widget, WidgetReportZero, WidgetReportError } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const args = { - ...dates, - dimensions: 'ga:channelGrouping', - metrics: [ - { - expression: 'ga:sessions', - alias: 'Sessions', - }, - { - expression: 'ga:users', - alias: 'Users', - }, - { - expression: 'ga:newUsers', - alias: 'New Users', - }, - ], - orderby: [ - { - fieldName: 'ga:users', - sortOrder: 'DESCENDING', - }, - ], - limit: 10, - }; - - const error = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getErrorForSelector( 'getReport', [ args ] ) - ); - - const loaded = useSelect( ( select ) => - select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - args, - ] ) - ); - - const report = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( args ) - ); - - if ( ! loaded || isGatheringData === undefined ) { - return ( - - - - - - - - - - - - - ); - } - - if ( error ) { - return ( - - - - ); - } - - const isZeroData = isZeroReport( report ); - if ( ! zeroDataStates && isGatheringData && isZeroData ) { - return ( - - - - ); - } - - return ( - - - - { ! isZeroData && ( - - - - ) } - - - - - - - - ); -} - -ModuleAcquisitionChannelsWidget.propTypes = { - Widget: PropTypes.elementType.isRequired, - WidgetReportError: PropTypes.elementType.isRequired, - WidgetReportZero: PropTypes.elementType.isRequired, -}; diff --git a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Header.js b/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Header.js deleted file mode 100644 index 6166315aad6..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Header.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Header component the ModuleOverviewWidget widget. - * - * 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. - */ - -/** - * WordPress dependencies - */ -import { sprintf, _n, _x, __ } from '@wordpress/i18n'; -import { Fragment } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - MODULES_ANALYTICS, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; -const { useSelect } = Data; - -export default function Header() { - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const visitorsOverview = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'visitors-overview', - generateDateRangeArgs( dates ) - ) - ); - const currentDayCount = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - const title = sprintf( - /* translators: %s: number of days */ - _n( - 'Audience overview for the last %s day', - 'Audience overview for the last %s days', - currentDayCount, - 'google-site-kit' - ), - currentDayCount - ); - - const headerCTALabel = sprintf( - /* translators: %s: module name. */ - __( 'See full stats in %s', 'google-site-kit' ), - _x( 'Analytics', 'Service name', 'google-site-kit' ) - ); - - return ( - - - - - ); -} diff --git a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Overview.js b/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Overview.js deleted file mode 100644 index e063725c23f..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/Overview.js +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Overview component the ModuleOverviewWidget widget. - * - * 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'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { MODULES_ANALYTICS } from '../../../datastore/constants'; -import { Grid, Row, Cell } from '../../../../../material-components'; -import DataBlock from '../../../../../components/DataBlock'; -import { calculateChange } from '../../../../../util'; -const { useInViewSelect } = Data; - -function getDatapointAndChange( [ report ], selectedStat, divider = 1 ) { - return { - datapoint: - report?.data?.totals?.[ 0 ]?.values?.[ selectedStat ] / divider, - change: calculateChange( - report?.data?.totals?.[ 1 ]?.values?.[ selectedStat ], - report?.data?.totals?.[ 0 ]?.values?.[ selectedStat ] - ), - }; -} - -export default function Overview( { - report, - selectedStat, - handleStatSelection, -} ) { - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const dataBlocks = [ - { - title: __( 'Users', 'google-site-kit' ), - className: - 'googlesitekit-data-block--users googlesitekit-data-block--button-1', - ...getDatapointAndChange( report, 0 ), - }, - { - title: __( 'Sessions', 'google-site-kit' ), - className: - 'googlesitekit-data-block--sessions googlesitekit-data-block--button-2', - ...getDatapointAndChange( report, 1 ), - }, - { - title: __( 'Bounce Rate', 'google-site-kit' ), - className: - 'googlesitekit-data-block--bounce googlesitekit-data-block--button-3', - datapointUnit: '%', - invertChangeColor: true, - ...getDatapointAndChange( report, 2, 100 ), - }, - { - title: __( 'Session Duration', 'google-site-kit' ), - className: - 'googlesitekit-data-block--duration googlesitekit-data-block--button-4', - datapointUnit: 's', - ...getDatapointAndChange( report, 3 ), - }, - ]; - - return ( - - - { dataBlocks.map( ( block, i ) => ( - - - - ) ) } - - - ); -} - -Overview.propTypes = { - report: PropTypes.arrayOf( PropTypes.object ), - selectedStat: PropTypes.number.isRequired, - handleStatSelection: PropTypes.func.isRequired, -}; diff --git a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/SiteStats.js b/assets/js/modules/analytics/components/module/ModuleOverviewWidget/SiteStats.js deleted file mode 100644 index 3c7d2a23785..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/SiteStats.js +++ /dev/null @@ -1,180 +0,0 @@ -/** - * SiteStats component the ModuleOverviewWidget widget. - * - * 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 { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - extractAnalyticsDashboardData, - getTimeColumnVaxisFormat, - isZeroReport, -} from '../../../util'; -import GoogleChart from '../../../../../components/GoogleChart'; -import { Cell, Row, Grid } from '../../../../../material-components'; -const { useSelect } = Data; - -export default function SiteStats( props ) { - const { selectedStat, report = [], gatheringData } = props; - - const currentDayCount = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - const dataMap = extractAnalyticsDashboardData( - report, - selectedStat, - currentDayCount, - 0, - 1 - ); - - let vAxisFormat; - if ( dataMap[ 0 ][ selectedStat ]?.type === 'timeofday' ) { - vAxisFormat = getTimeColumnVaxisFormat( dataMap, selectedStat ); - } - - const dates = dataMap.slice( 1 ).map( ( [ date ] ) => date ); - - const options = { - ...SiteStats.options, - hAxis: { - ...SiteStats.options.hAxis, - ticks: dates, - }, - vAxis: { - ...SiteStats.options.vAxis, - format: vAxisFormat, - }, - series: { - 0: { - color: SiteStats.colorMap[ selectedStat ], - targetAxisIndex: 0, - }, - 1: { - color: SiteStats.colorMap[ selectedStat ], - targetAxisIndex: 0, - lineDashStyle: [ 3, 3 ], - lineWidth: 1, - }, - }, - }; - - if ( isZeroReport( report ) ) { - options.vAxis.viewWindow.max = 100; - } else { - options.vAxis.viewWindow.max = undefined; - } - - return ( - - - - - - - - ); -} - -SiteStats.propTypes = { - selectedStat: PropTypes.number.isRequired, - report: PropTypes.arrayOf( PropTypes.object ), - gatheringData: PropTypes.bool, -}; - -SiteStats.colorMap = { - 0: '#4285f4', - 1: '#27bcd4', - 2: '#1b9688', - 3: '#673ab7', -}; - -SiteStats.options = { - chart: { - title: '', - }, - curveType: 'function', - height: 270, - width: '100%', - chartArea: { - height: '80%', - left: 60, - right: 25, - }, - legend: { - position: 'top', - textStyle: { - color: '#616161', - fontSize: 12, - }, - }, - hAxis: { - format: 'M/d/yy', - gridlines: { - color: '#fff', - }, - textStyle: { - color: '#616161', - fontSize: 12, - }, - }, - vAxis: { - gridlines: { - color: '#eee', - }, - minorGridlines: { - color: '#eee', - }, - textStyle: { - color: '#616161', - fontSize: 12, - }, - titleTextStyle: { - color: '#616161', - fontSize: 12, - italic: false, - }, - viewWindow: { - min: 0, - }, - }, - focusTarget: 'category', - crosshair: { - color: 'gray', - opacity: 0.1, - orientation: 'vertical', - trigger: 'both', - }, - tooltip: { - isHtml: true, // eslint-disable-line sitekit/acronym-case - trigger: 'both', - }, -}; diff --git a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/index.js b/assets/js/modules/analytics/components/module/ModuleOverviewWidget/index.js deleted file mode 100644 index 71d6a78d9d9..00000000000 --- a/assets/js/modules/analytics/components/module/ModuleOverviewWidget/index.js +++ /dev/null @@ -1,170 +0,0 @@ -/** - * ModuleOverviewWidget 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'; - -/** - * WordPress dependencies - */ -import { useState } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - DATE_RANGE_OFFSET, - MODULES_ANALYTICS, -} from '../../../datastore/constants'; -import { isZeroReport } from '../../../util'; -import PreviewBlock from '../../../../../components/PreviewBlock'; -import Header from './Header'; -import Overview from './Overview'; -import SiteStats from './SiteStats'; -import { useFeature } from '../../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -export default function ModuleOverviewWidget( props ) { - const { Widget, WidgetReportError, WidgetReportZero } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const [ selectedStat, setSelectedState ] = useState( 0 ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).isGatheringData() - ); - - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - compare: true, - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const overviewArgs = { - ...dates, - metrics: [ - 'ga:users', - 'ga:sessions', - 'ga:bounceRate', - 'ga:avgSessionDuration', - ], - }; - - const statsArgs = { - ...dates, - dimensions: 'ga:date', - metrics: [ - 'ga:users', - 'ga:sessions', - 'ga:bounceRate', - 'ga:avgSessionDuration', - ], - }; - - const overviewLoaded = useSelect( ( select ) => - select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - overviewArgs, - ] ) - ); - - const overviewReport = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( overviewArgs ) - ); - - const overviewError = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getErrorForSelector( 'getReport', [ - overviewArgs, - ] ) - ); - - const statsLoaded = useSelect( ( select ) => - select( MODULES_ANALYTICS ).hasFinishedResolution( 'getReport', [ - statsArgs, - ] ) - ); - - const statsReport = useInViewSelect( ( select ) => - select( MODULES_ANALYTICS ).getReport( statsArgs ) - ); - - const statsError = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getErrorForSelector( 'getReport', [ - statsArgs, - ] ) - ); - - if ( ! overviewLoaded || ! statsLoaded || isGatheringData === undefined ) { - return ( - - - - - ); - } - - if ( overviewError || statsError ) { - return ( - - - - ); - } - - if ( - ! zeroDataStates && - isGatheringData && - isZeroReport( overviewReport ) - ) { - return ( - - - - ); - } - - return ( - - - - - - ); -} - -ModuleOverviewWidget.propTypes = { - Widget: PropTypes.elementType.isRequired, - WidgetReportError: PropTypes.elementType.isRequired, - WidgetReportZero: PropTypes.elementType.isRequired, -}; diff --git a/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/Header.js b/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/Header.js index e9152b00b13..e3aa98e5aa9 100644 --- a/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/Header.js +++ b/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/Header.js @@ -19,38 +19,17 @@ /** * WordPress dependencies */ -import { sprintf, _n, _x, __ } from '@wordpress/i18n'; -import { Fragment } from '@wordpress/element'; +import { sprintf, _n } from '@wordpress/i18n'; /** * Internal dependencies */ import Data from 'googlesitekit-data'; import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - MODULES_ANALYTICS, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { useFeature } from '../../../../../hooks/useFeature'; import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; const { useSelect } = Data; export default function Header() { - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const contentPagesURL = useSelect( ( select ) => - select( MODULES_ANALYTICS ).getServiceReportURL( - 'content-pages', - generateDateRangeArgs( dates ) - ) - ); const currentDayCount = useSelect( ( select ) => select( CORE_USER ).getDateRangeNumberOfDays() ); @@ -65,22 +44,5 @@ export default function Header() { currentDayCount ); - const headerCTALabel = sprintf( - /* translators: %s: module name. */ - __( 'See full stats in %s', 'google-site-kit' ), - _x( 'Analytics', 'Service name', 'google-site-kit' ) - ); - - return ( - - - { ! unifiedDashboardEnabled && ( - - ) } - - ); + return ; } diff --git a/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/index.js b/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/index.js index f09b34a259e..9690737e276 100644 --- a/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/index.js +++ b/assets/js/modules/analytics/components/module/ModulePopularPagesWidget/index.js @@ -64,7 +64,6 @@ function ModulePopularPagesWidget( props ) { ); const zeroDataStates = useFeature( 'zeroDataStates' ); - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); const args = { ...dates, @@ -195,10 +194,7 @@ function ModulePopularPagesWidget( props ) { { numFmt( Number( fieldValue ) / 100, '%' ) } ), }, - ]; - - if ( unifiedDashboardEnabled ) { - tableColumns.push( { + { title: __( 'Session Duration', 'google-site-kit' ), description: __( 'Session Duration', 'google-site-kit' ), hideOnMobile: true, @@ -206,8 +202,8 @@ function ModulePopularPagesWidget( props ) { Component: ( { fieldValue } ) => ( { numFmt( fieldValue, 's' ) } ), - } ); - } + }, + ]; const rows = report?.[ 0 ]?.data?.rows?.length ? cloneDeep( report[ 0 ].data.rows ) diff --git a/assets/js/modules/analytics/components/module/index.js b/assets/js/modules/analytics/components/module/index.js index 3f5fee60635..80c012038cd 100644 --- a/assets/js/modules/analytics/components/module/index.js +++ b/assets/js/modules/analytics/components/module/index.js @@ -16,6 +16,4 @@ * limitations under the License. */ -export { default as ModuleOverviewWidget } from './ModuleOverviewWidget'; export { default as ModulePopularPagesWidget } from './ModulePopularPagesWidget'; -export { default as ModuleAcquisitionChannelsWidget } from './ModuleAcquisitionChannelsWidget'; diff --git a/assets/js/modules/analytics/constants.js b/assets/js/modules/analytics/constants.js index fcaf15fa168..1b82f4fc756 100644 --- a/assets/js/modules/analytics/constants.js +++ b/assets/js/modules/analytics/constants.js @@ -16,5 +16,4 @@ * limitations under the License. */ -export const CONTEXT_MODULE_ANALYTICS = 'moduleAnalytics'; export const AREA_MODULE_ANALYTICS_MAIN = 'moduleAnalyticsMain'; diff --git a/assets/js/modules/analytics/datastore/base.js b/assets/js/modules/analytics/datastore/base.js index 6341dc1fb11..9a3767f03c2 100644 --- a/assets/js/modules/analytics/datastore/base.js +++ b/assets/js/modules/analytics/datastore/base.js @@ -20,7 +20,6 @@ * Internal dependencies */ import Modules from 'googlesitekit-modules'; -import { isFeatureEnabled } from '../../../features'; import { MODULES_ANALYTICS } from './constants'; import { getCanUseSnippet, @@ -49,9 +48,6 @@ const baseModuleStore = Modules.createModuleStore( 'analytics', { 'trackingDisabled', 'useSnippet', ], - adminPage: isFeatureEnabled( 'unifiedDashboard' ) - ? undefined - : 'googlesitekit-module-analytics', submitChanges, rollbackChanges, validateCanSubmitChanges, diff --git a/assets/js/modules/analytics/datastore/base.test.js b/assets/js/modules/analytics/datastore/base.test.js index fad4ee4ba15..762bd4fd022 100644 --- a/assets/js/modules/analytics/datastore/base.test.js +++ b/assets/js/modules/analytics/datastore/base.test.js @@ -36,10 +36,7 @@ describe( 'modules/analytics base data store', () => { provideSiteInfo( registry ); } ); - it( 'does not define the admin page when unified dashboard is enabled', () => { - const { enabledFeatures } = require( '../../../features' ); - enabledFeatures.add( 'unifiedDashboard' ); - + it( 'does not define the admin page', () => { store = require( './base' ).default; registry.registerStore( MODULES_ANALYTICS, store ); @@ -47,13 +44,4 @@ describe( 'modules/analytics base data store', () => { 'http://example.com/wp-admin/admin.php?page=googlesitekit-dashboard' ); } ); - - it( 'does define the admin page when unified dashboard is not enabled', () => { - store = require( './base' ).default; - registry.registerStore( MODULES_ANALYTICS, store ); - - expect( registry.select( MODULES_ANALYTICS ).getAdminScreenURL() ).toBe( - 'http://example.com/wp-admin/admin.php?page=googlesitekit-module-analytics' - ); - } ); } ); diff --git a/assets/js/modules/analytics/index.js b/assets/js/modules/analytics/index.js index baa8ff5504d..959417f1513 100644 --- a/assets/js/modules/analytics/index.js +++ b/assets/js/modules/analytics/index.js @@ -24,38 +24,19 @@ import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ -import { isFeatureEnabled } from '../../features'; import { - AREA_DASHBOARD_ALL_TRAFFIC, - AREA_PAGE_DASHBOARD_ALL_TRAFFIC, - AREA_DASHBOARD_SEARCH_FUNNEL, - AREA_PAGE_DASHBOARD_SEARCH_FUNNEL, - AREA_DASHBOARD_ACQUISITION, AREA_MAIN_DASHBOARD_CONTENT_PRIMARY, AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY, } from '../../googlesitekit/widgets/default-areas'; -import { WIDGET_AREA_STYLES } from '../../googlesitekit/widgets/datastore/constants'; import AnalyticsIcon from '../../../svg/graphics/analytics.svg'; -import { - CONTEXT_MODULE_ANALYTICS, - AREA_MODULE_ANALYTICS_MAIN, -} from './constants'; import { MODULES_ANALYTICS } from './datastore/constants'; import { SetupMain } from './components/setup'; import { SettingsEdit, SettingsView } from './components/settings'; import DashboardAllTrafficWidget from './components/dashboard/DashboardAllTrafficWidget'; -import DashboardPopularPagesWidget from './components/dashboard/DashboardPopularPagesWidget'; -import DashboardGoalsWidget from './components/dashboard/DashboardGoalsWidget'; -import DashboardSearchVisitorsWidget from './components/dashboard/DashboardSearchVisitorsWidget'; -import DashboardBounceRateWidget from './components/dashboard/DashboardBounceRateWidget'; import DashboardOverallPageMetricsWidget from './components/dashboard/DashboardOverallPageMetricsWidget'; -import { - ModuleOverviewWidget, - ModulePopularPagesWidget, - ModuleAcquisitionChannelsWidget, -} from './components/module'; +import { ModulePopularPagesWidget } from './components/module'; export { registerStore } from './datastore'; @@ -71,157 +52,46 @@ export const registerModule = ( modules ) => { __( 'Top pages', 'google-site-kit' ), __( 'Top acquisition channels', 'google-site-kit' ), ], - screenWidgetContext: CONTEXT_MODULE_ANALYTICS, } ); }; export const registerWidgets = ( widgets ) => { - if ( ! isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'analyticsAllTraffic', - { - Component: DashboardAllTrafficWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 1, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_DASHBOARD_ALL_TRAFFIC, AREA_PAGE_DASHBOARD_ALL_TRAFFIC ] - ); - - widgets.registerWidget( - 'analyticsUniqueVisitors', - { - Component: DashboardSearchVisitorsWidget, - width: widgets.WIDGET_WIDTHS.QUARTER, - priority: 3, - wrapWidget: true, - modules: [ 'analytics' ], - }, - [ AREA_DASHBOARD_SEARCH_FUNNEL, AREA_PAGE_DASHBOARD_SEARCH_FUNNEL ] - ); - - widgets.registerWidget( - 'analyticsGoals', - { - Component: DashboardGoalsWidget, - width: widgets.WIDGET_WIDTHS.QUARTER, - priority: 4, - wrapWidget: true, - modules: [ 'analytics' ], - }, - [ AREA_DASHBOARD_SEARCH_FUNNEL ] - ); - - widgets.registerWidget( - 'analyticsBounceRate', - { - Component: DashboardBounceRateWidget, - width: widgets.WIDGET_WIDTHS.QUARTER, - priority: 4, - wrapWidget: true, - modules: [ 'analytics' ], - }, - [ AREA_PAGE_DASHBOARD_SEARCH_FUNNEL ] - ); - - widgets.registerWidget( - 'analyticsPopularPages', - { - Component: DashboardPopularPagesWidget, - width: widgets.WIDGET_WIDTHS.HALF, - priority: 3, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_DASHBOARD_ACQUISITION ] - ); - - widgets.registerWidget( - 'analyticsModuleAcquisitionChannels', - { - Component: ModuleAcquisitionChannelsWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 3, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_MODULE_ANALYTICS_MAIN ] - ); - - widgets.registerWidgetArea( - AREA_MODULE_ANALYTICS_MAIN, - { - priority: 1, - style: WIDGET_AREA_STYLES.BOXES, - title: __( 'Overview', 'google-site-kit' ), - }, - CONTEXT_MODULE_ANALYTICS - ); - - widgets.registerWidget( - 'analyticsModuleOverview', - { - Component: ModuleOverviewWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 1, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_MODULE_ANALYTICS_MAIN ] - ); - - widgets.registerWidget( - 'analyticsModulePopularPages', - { - Component: ModulePopularPagesWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 2, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_MODULE_ANALYTICS_MAIN ] - ); - } - - if ( isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'analyticsAllTraffic', - { - Component: DashboardAllTrafficWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 1, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ - AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, - AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, - ] - ); - - widgets.registerWidget( - 'analyticsOverallPageMetrics', - { - Component: DashboardOverallPageMetricsWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 3, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY ] - ); - - widgets.registerWidget( - 'analyticsModulePopularPages', - { - Component: ModulePopularPagesWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 4, - wrapWidget: false, - modules: [ 'analytics' ], - }, - [ AREA_MAIN_DASHBOARD_CONTENT_PRIMARY ] - ); - } + widgets.registerWidget( + 'analyticsAllTraffic', + { + Component: DashboardAllTrafficWidget, + width: widgets.WIDGET_WIDTHS.FULL, + priority: 1, + wrapWidget: false, + modules: [ 'analytics' ], + }, + [ + AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, + AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, + ] + ); + + widgets.registerWidget( + 'analyticsOverallPageMetrics', + { + Component: DashboardOverallPageMetricsWidget, + width: widgets.WIDGET_WIDTHS.FULL, + priority: 3, + wrapWidget: false, + modules: [ 'analytics' ], + }, + [ AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY ] + ); + + widgets.registerWidget( + 'analyticsModulePopularPages', + { + Component: ModulePopularPagesWidget, + width: widgets.WIDGET_WIDTHS.FULL, + priority: 4, + wrapWidget: false, + modules: [ 'analytics' ], + }, + [ AREA_MAIN_DASHBOARD_CONTENT_PRIMARY ] + ); }; diff --git a/assets/js/modules/idea-hub/index.js b/assets/js/modules/idea-hub/index.js index 78dced67d5f..fc15152cf8b 100644 --- a/assets/js/modules/idea-hub/index.js +++ b/assets/js/modules/idea-hub/index.js @@ -29,10 +29,7 @@ import { getQueryArg } from '@wordpress/url'; import { MODULES_IDEA_HUB } from './datastore/constants'; import { registerStore as registerDataStore } from './datastore'; import { isFeatureEnabled } from '../../features'; -import { - AREA_DASHBOARD_ACQUISITION, - AREA_MAIN_DASHBOARD_CONTENT_PRIMARY, -} from '../../googlesitekit/widgets/default-areas'; +import { AREA_MAIN_DASHBOARD_CONTENT_PRIMARY } from '../../googlesitekit/widgets/default-areas'; import DashboardIdeasWidget from './components/dashboard/DashboardIdeasWidget'; import IdeaHubIcon from '../../../svg/graphics/idea-hub.svg'; import { SettingsView } from './components/settings'; @@ -81,31 +78,15 @@ export const registerWidgets = ifIdeaHubIsEnabled( async ( widgets ) => { return; } - if ( ! isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'ideaHubIdeas', - { - Component: DashboardIdeasWidget, - width: widgets.WIDGET_WIDTHS.HALF, - priority: 2, - wrapWidget: false, - modules: [ 'idea-hub' ], - }, - [ AREA_DASHBOARD_ACQUISITION ] - ); - } - - if ( isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'ideaHubIdeas', - { - Component: DashboardIdeasWidget, - width: widgets.WIDGET_WIDTHS.HALF, - priority: 2, - wrapWidget: false, - modules: [ 'idea-hub' ], - }, - [ AREA_MAIN_DASHBOARD_CONTENT_PRIMARY ] - ); - } + widgets.registerWidget( + 'ideaHubIdeas', + { + Component: DashboardIdeasWidget, + width: widgets.WIDGET_WIDTHS.HALF, + priority: 2, + wrapWidget: false, + modules: [ 'idea-hub' ], + }, + [ AREA_MAIN_DASHBOARD_CONTENT_PRIMARY ] + ); } ); diff --git a/assets/js/modules/pagespeed-insights/components/dashboard/DashboardPageSpeed.js b/assets/js/modules/pagespeed-insights/components/dashboard/DashboardPageSpeed.js index fe607e06b7b..dc750af3b32 100644 --- a/assets/js/modules/pagespeed-insights/components/dashboard/DashboardPageSpeed.js +++ b/assets/js/modules/pagespeed-insights/components/dashboard/DashboardPageSpeed.js @@ -22,7 +22,7 @@ import classnames from 'classnames'; import Tab from '@material/react-tab'; import TabBar from '@material/react-tab-bar'; -import { useIntersection, useMount } from 'react-use'; +import { useIntersection } from 'react-use'; /** * WordPress dependencies @@ -61,9 +61,6 @@ import { UI_STRATEGY, UI_DATA_SOURCE, } from '../../datastore/constants'; -import { useFeature } from '../../../../hooks/useFeature'; -import { useBreakpoint } from '../../../../hooks/useBreakpoint'; -import { getContextScrollTop } from '../../../../util/scroll'; import Spinner from '../../../../components/Spinner'; import useViewContext from '../../../../hooks/useViewContext'; const { useSelect, useDispatch, useInViewSelect } = Data; @@ -224,32 +221,6 @@ export default function DashboardPageSpeed() { [ invalidateResolution, referenceURL ] ); - /** - * TODO - Remove this and the useMount() hook - * when the unified dashboard is published and - * the `unifiedDashboard` feature flag is removed. - */ - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - const breakpoint = useBreakpoint(); - - // Scroll to the PSI section if the URL has pagespeed-header hash - useMount( () => { - if ( - ! unifiedDashboardEnabled && - global.location.hash === '#googlesitekit-pagespeed-header' - ) { - setTimeout( () => { - global.scrollTo( { - top: getContextScrollTop( - global.location.hash, - breakpoint - ), - behavior: 'smooth', - } ); - }, 10 ); - } - } ); - const reportData = strategy === STRATEGY_MOBILE ? reportMobile : reportDesktop; const reportError = diff --git a/assets/js/modules/pagespeed-insights/components/settings/SettingsView.js b/assets/js/modules/pagespeed-insights/components/settings/SettingsView.js index 9aa721ef25e..996d7997d23 100644 --- a/assets/js/modules/pagespeed-insights/components/settings/SettingsView.js +++ b/assets/js/modules/pagespeed-insights/components/settings/SettingsView.js @@ -25,7 +25,6 @@ import { __, sprintf } from '@wordpress/i18n'; * Internal dependencies */ import Data from 'googlesitekit-data'; -import { useFeature } from '../../../../hooks/useFeature'; import { sanitizeHTML } from '../../../../util'; import { MODULES_PAGESPEED_INSIGHTS } from '../../datastore/constants'; const { useSelect } = Data; @@ -35,20 +34,13 @@ export default function SettingsView() { select( MODULES_PAGESPEED_INSIGHTS ).getAdminScreenURL() ); - const unifiedDashboardEnabled = useFeature( 'unifiedDashboard' ); - - // Append PSI section hash based on unifiedDashboardEnabled is enabled or not - const dashboardPermalinkWithPSI = unifiedDashboardEnabled - ? `${ dashboardPermalink }#speed` - : `${ dashboardPermalink }#googlesitekit-pagespeed-header`; - const content = sprintf( /* translators: %s is the URL to the Site Kit dashboard. */ __( 'To view insights, visit the dashboard', 'google-site-kit' ), - dashboardPermalinkWithPSI + `${ dashboardPermalink }#speed` ); return ( diff --git a/assets/js/modules/pagespeed-insights/index.js b/assets/js/modules/pagespeed-insights/index.js index cedea4bec5d..424bf3c1425 100644 --- a/assets/js/modules/pagespeed-insights/index.js +++ b/assets/js/modules/pagespeed-insights/index.js @@ -25,16 +25,13 @@ import { __ } from '@wordpress/i18n'; * Internal dependencies */ import { - AREA_DASHBOARD_SPEED, AREA_ENTITY_DASHBOARD_SPEED_PRIMARY, AREA_MAIN_DASHBOARD_SPEED_PRIMARY, - AREA_PAGE_DASHBOARD_SPEED, } from '../../googlesitekit/widgets/default-areas'; import { SettingsView } from './components/settings'; import DashboardPageSpeedWidget from './components/dashboard/DashboardPageSpeedWidget'; import PageSpeedInsightsIcon from '../../../svg/graphics/pagespeed-insights.svg'; import { MODULES_PAGESPEED_INSIGHTS } from './datastore/constants'; -import { isFeatureEnabled } from '../../features'; export { registerStore } from './datastore'; @@ -53,32 +50,17 @@ export const registerModule = ( modules ) => { }; export const registerWidgets = ( widgets ) => { - if ( ! isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'pagespeedInsightsWebVitals', - { - Component: DashboardPageSpeedWidget, - width: widgets.WIDGET_WIDTHS.FULL, - wrapWidget: false, - modules: [ 'pagespeed-insights' ], - }, - [ AREA_DASHBOARD_SPEED, AREA_PAGE_DASHBOARD_SPEED ] - ); - } - - if ( isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'pagespeedInsightsWebVitals', - { - Component: DashboardPageSpeedWidget, - width: widgets.WIDGET_WIDTHS.FULL, - wrapWidget: false, - modules: [ 'pagespeed-insights' ], - }, - [ - AREA_MAIN_DASHBOARD_SPEED_PRIMARY, - AREA_ENTITY_DASHBOARD_SPEED_PRIMARY, - ] - ); - } + widgets.registerWidget( + 'pagespeedInsightsWebVitals', + { + Component: DashboardPageSpeedWidget, + width: widgets.WIDGET_WIDTHS.FULL, + wrapWidget: false, + modules: [ 'pagespeed-insights' ], + }, + [ + AREA_MAIN_DASHBOARD_SPEED_PRIMARY, + AREA_ENTITY_DASHBOARD_SPEED_PRIMARY, + ] + ); }; diff --git a/assets/js/modules/search-console/components/dashboard/DashboardClicksWidget.js b/assets/js/modules/search-console/components/dashboard/DashboardClicksWidget.js deleted file mode 100644 index 9cb0d497027..00000000000 --- a/assets/js/modules/search-console/components/dashboard/DashboardClicksWidget.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * DashboardClicksWidget 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. - */ - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_SEARCH_CONSOLE, -} from '../../datastore/constants'; -import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import extractForSparkline from '../../../../util/extract-for-sparkline'; -import { untrailingslashit, calculateChange } from '../../../../util'; -import { isZeroReport } from '../../util'; -import whenActive from '../../../../util/when-active'; -import DataBlock from '../../../../components/DataBlock'; -import Sparkline from '../../../../components/Sparkline'; -import PreviewBlock from '../../../../components/PreviewBlock'; -import sumObjectListValue from '../../../../util/sum-object-list-value'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import { partitionReport } from '../../../../util/partition-report'; -import { useFeature } from '../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -function DashboardClicksWidget( { WidgetReportZero, WidgetReportError } ) { - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isGatheringData() - ); - - const { compareStartDate, startDate, endDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - compare: true, - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const propertyID = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getPropertyID() - ); - const url = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - const isDomainProperty = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isDomainProperty() - ); - const referenceSiteURLWithSlashes = useSelect( ( select ) => - select( CORE_SITE ).getReferenceSiteURL() - ); - const referenceSiteURL = untrailingslashit( referenceSiteURLWithSlashes ); - - const args = { - dimensions: 'date', - // Combine both date ranges into one single date range. - startDate: compareStartDate, - endDate, - }; - const serviceBaseURLArgs = { - resource_id: propertyID, - ...generateDateRangeArgs( { startDate, endDate } ), - }; - - if ( url ) { - args.url = url; - serviceBaseURLArgs.page = `!${ url }`; - } else if ( isDomainProperty && referenceSiteURL ) { - serviceBaseURLArgs.page = `*${ referenceSiteURL }`; - } - - const { error, loading, serviceURL } = useSelect( ( select ) => { - const store = select( MODULES_SEARCH_CONSOLE ); - - return { - error: store.getErrorForSelector( 'getReport', [ args ] ), - loading: ! store.hasFinishedResolution( 'getReport', [ args ] ), - serviceURL: store.getServiceURL( { - path: '/performance/search-analytics', - query: serviceBaseURLArgs, - } ), - }; - } ); - - const data = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getReport( args ) - ); - - const dateRangeLength = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - - if ( error ) { - return ( - - ); - } - - if ( loading || isGatheringData === undefined ) { - return ; - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ; - } - - const { compareRange, currentRange } = partitionReport( data, { - dateRangeLength, - } ); - const totalClicks = sumObjectListValue( currentRange, 'clicks' ); - const totalOlderClicks = sumObjectListValue( compareRange, 'clicks' ); - const totalClicksChange = calculateChange( totalOlderClicks, totalClicks ); - - const sparklineData = [ - [ - { type: 'string', label: 'Day' }, - { type: 'number', label: 'Clicks' }, - ], - ...extractForSparkline( currentRange, 'clicks', 'keys.0' ).map( - ( row ) => { - const date = new Date( row[ 0 ] ); - // Sparkline data needs headers and dates formatted as MM/DD - return [ - `${ date.getMonth() + 1 }/${ date.getUTCDate() }`, - row[ 1 ], - ]; - } - ), - ]; - - return ( - - } - gatheringData={ isGatheringData } - /> - ); -} - -export default whenActive( { moduleName: 'search-console' } )( - DashboardClicksWidget -); diff --git a/assets/js/modules/search-console/components/dashboard/DashboardImpressionsWidget.js b/assets/js/modules/search-console/components/dashboard/DashboardImpressionsWidget.js deleted file mode 100644 index f97059372a1..00000000000 --- a/assets/js/modules/search-console/components/dashboard/DashboardImpressionsWidget.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - * DashboardImpressionsWidget 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. - */ - -/** - * WordPress dependencies - */ -import { __, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - DATE_RANGE_OFFSET, - MODULES_SEARCH_CONSOLE, -} from '../../datastore/constants'; -import { CORE_SITE } from '../../../../googlesitekit/datastore/site/constants'; -import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants'; -import { isZeroReport } from '../../util'; -import { calculateChange, untrailingslashit } from '../../../../util'; -import extractForSparkline from '../../../../util/extract-for-sparkline'; -import whenActive from '../../../../util/when-active'; -import DataBlock from '../../../../components/DataBlock'; -import Sparkline from '../../../../components/Sparkline'; -import PreviewBlock from '../../../../components/PreviewBlock'; -import sumObjectListValue from '../../../../util/sum-object-list-value'; -import { generateDateRangeArgs } from '../../util/report-date-range-args'; -import { partitionReport } from '../../../../util/partition-report'; -import { useFeature } from '../../../../hooks/useFeature'; -const { useSelect, useInViewSelect } = Data; - -function DashboardImpressionsWidget( { WidgetReportZero, WidgetReportError } ) { - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isGatheringData() - ); - - const { compareStartDate, startDate, endDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - compare: true, - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const propertyID = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getPropertyID() - ); - const url = useSelect( ( select ) => - select( CORE_SITE ).getCurrentEntityURL() - ); - const isDomainProperty = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isDomainProperty() - ); - const referenceSiteURLWithSlashes = useSelect( ( select ) => - select( CORE_SITE ).getReferenceSiteURL() - ); - const referenceSiteURL = untrailingslashit( referenceSiteURLWithSlashes ); - - const args = { - dimensions: 'date', - // Combine both date ranges into one single date range. - startDate: compareStartDate, - endDate, - }; - - const serviceBaseURLArgs = { - resource_id: propertyID, - ...generateDateRangeArgs( { startDate, endDate } ), - }; - if ( url ) { - args.url = url; - serviceBaseURLArgs.page = `!${ url }`; - } else if ( isDomainProperty && referenceSiteURL ) { - serviceBaseURLArgs.page = `*${ referenceSiteURL }`; - } - - const { error, loading, serviceURL } = useSelect( ( select ) => { - const store = select( MODULES_SEARCH_CONSOLE ); - - return { - error: store.getErrorForSelector( 'getReport', [ args ] ), - loading: ! store.hasFinishedResolution( 'getReport', [ args ] ), - serviceURL: store.getServiceURL( { - path: '/performance/search-analytics', - query: serviceBaseURLArgs, - } ), - }; - } ); - - const data = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getReport( args ) - ); - - const dateRangeLength = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - - if ( error ) { - return ( - - ); - } - - if ( loading || isGatheringData === undefined ) { - return ; - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ; - } - - const { compareRange, currentRange } = partitionReport( data, { - dateRangeLength, - } ); - const totalImpressions = sumObjectListValue( currentRange, 'impressions' ); - const totalOlderImpressions = sumObjectListValue( - compareRange, - 'impressions' - ); - const totalImpressionsChange = calculateChange( - totalOlderImpressions, - totalImpressions - ); - - const sparklineData = [ - [ - { type: 'string', label: 'Day' }, - { type: 'number', label: 'Clicks' }, - ], - ...extractForSparkline( currentRange, 'impressions', 'keys.0' ).map( - ( row ) => { - const date = new Date( row[ 0 ] ); - // Sparkline data needs headers and dates formatted as MM/DD - return [ - `${ date.getMonth() + 1 }/${ date.getUTCDate() }`, - row[ 1 ], - ]; - } - ), - ]; - - return ( - - } - gatheringData={ isGatheringData } - /> - ); -} - -export default whenActive( { moduleName: 'search-console' } )( - DashboardImpressionsWidget -); diff --git a/assets/js/modules/search-console/components/dashboard/index.js b/assets/js/modules/search-console/components/dashboard/index.js index f355e134eca..51c261c8181 100644 --- a/assets/js/modules/search-console/components/dashboard/index.js +++ b/assets/js/modules/search-console/components/dashboard/index.js @@ -16,7 +16,5 @@ * limitations under the License. */ -export { default as DashboardClicksWidget } from './DashboardClicksWidget'; -export { default as DashboardImpressionsWidget } from './DashboardImpressionsWidget'; export { default as DashboardPopularKeywordsWidget } from './DashboardPopularKeywordsWidget'; export { default as SearchFunnelWidget } from './SearchFunnelWidget'; diff --git a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Header.js b/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Header.js deleted file mode 100644 index 4fcf409d486..00000000000 --- a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Header.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Header component for ModuleOverviewWidget. - * - * 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'; - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; -import { __, sprintf, _n, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import { - MODULES_SEARCH_CONSOLE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { generateDateRangeArgs } from '../../../util'; -import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; -import Data from 'googlesitekit-data'; -const { useSelect } = Data; - -const Header = ( { metrics, selectedStats } ) => { - const dateRangeDates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const searchConsoleDeepLink = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getServiceReportURL( { - metrics: metrics[ selectedStats ]?.metric, - ...generateDateRangeArgs( dateRangeDates ), - } ) - ); - const currentDayCount = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - - return ( - - - - - ); -}; - -Header.propTypes = { - metrics: PropTypes.arrayOf( PropTypes.object ), - selectedStats: PropTypes.number.isRequired, -}; - -export default Header; diff --git a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Overview.js b/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Overview.js deleted file mode 100644 index 693547a3db6..00000000000 --- a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Overview.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Overview component for ModuleOverviewWidget. - * - * 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'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import { Grid, Row, Cell } from '../../../../../material-components'; -import { extractSearchConsoleDashboardData } from '../../../util'; -import DataBlock from '../../../../../components/DataBlock'; - -export default function Overview( props ) { - const { - data, - selectedStats, - handleStatsSelection, - dateRangeLength, - gatheringData, - } = props; - - const { - totalClicks, - totalImpressions, - averageCTR, - averagePosition, - totalClicksChange, - totalImpressionsChange, - averageCTRChange, - averagePositionChange, - } = extractSearchConsoleDashboardData( data, dateRangeLength ); - - const cellProps = { - smSize: 2, - mdSize: 2, - lgSize: 3, - }; - - return ( - - - - - - - - - - - - - - - - - - - - ); -} - -Overview.propTypes = { - data: PropTypes.arrayOf( PropTypes.object ), - selectedStats: PropTypes.number.isRequired, - handleStatsSelection: PropTypes.func.isRequired, - gatheringData: PropTypes.bool, -}; diff --git a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Stats.js b/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Stats.js deleted file mode 100644 index a924bfc8600..00000000000 --- a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/Stats.js +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Stats component for ModuleOverviewWidget. - * - * 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'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import { getSiteStatsDataForGoogleChart, isZeroReport } from '../../../util'; -import { Grid, Row, Cell } from '../../../../../material-components'; -import GoogleChart from '../../../../../components/GoogleChart'; -import { partitionReport } from '../../../../../util/partition-report'; - -export default function Stats( props ) { - const { - data, - metrics, - selectedStats, - dateRangeLength, - gatheringData, - } = props; - - const { compareRange, currentRange } = partitionReport( data, { - dateRangeLength, - } ); - - const googleChartData = getSiteStatsDataForGoogleChart( - currentRange, - compareRange, - metrics[ selectedStats ].label, - metrics[ selectedStats ].metric, - dateRangeLength - ); - - const dates = googleChartData.slice( 1 ).map( ( [ date ] ) => date ); - - const options = { - chart: { - title: __( 'Search Traffic Summary', 'google-site-kit' ), - }, - curveType: 'function', - height: 270, - width: '100%', - chartArea: { - height: '80%', - left: 60, - right: 25, - }, - legend: { - position: 'top', - textStyle: { - color: '#616161', - fontSize: 12, - }, - }, - hAxis: { - format: 'M/d/yy', - gridlines: { - color: '#fff', - }, - textStyle: { - color: '#616161', - fontSize: 12, - }, - ticks: dates, - }, - vAxis: { - direction: selectedStats === 3 ? -1 : 1, - gridlines: { - color: '#eee', - }, - minorGridlines: { - color: '#eee', - }, - textStyle: { - color: '#616161', - fontSize: 12, - }, - titleTextStyle: { - color: '#616161', - fontSize: 12, - italic: false, - }, - viewWindow: { - min: 0, - }, - }, - series: { - 0: { - color: metrics[ selectedStats ].color, - targetAxisIndex: 0, - }, - 1: { - color: metrics[ selectedStats ].color, - targetAxisIndex: 0, - lineDashStyle: [ 3, 3 ], - lineWidth: 1, - }, - }, - tooltip: { - isHtml: true, // eslint-disable-line sitekit/acronym-case - trigger: 'both', - }, - focusTarget: 'category', - crosshair: { - color: 'gray', - opacity: 0.1, - orientation: 'vertical', - trigger: 'both', - }, - }; - - if ( isZeroReport( data ) ) { - options.vAxis.viewWindow.max = 100; - } else { - options.vAxis.viewWindow.max = undefined; - } - - return ( - - - - - - - - ); -} - -Stats.propTypes = { - data: PropTypes.arrayOf( PropTypes.object ).isRequired, - dateRangeLength: PropTypes.number.isRequired, - metrics: PropTypes.arrayOf( PropTypes.object ).isRequired, - selectedStats: PropTypes.number.isRequired, - gatheringData: PropTypes.bool, -}; diff --git a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/index.js b/assets/js/modules/search-console/components/module/ModuleOverviewWidget/index.js deleted file mode 100644 index b38eec5dd47..00000000000 --- a/assets/js/modules/search-console/components/module/ModuleOverviewWidget/index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** - * ModuleOverviewWidget 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'; - -/** - * WordPress dependencies - */ -import { useState } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - MODULES_SEARCH_CONSOLE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { isZeroReport } from '../../../util'; -import { useFeature } from '../../../../../hooks/useFeature'; -import PreviewBlock from '../../../../../components/PreviewBlock'; -import Header from './Header'; -import Overview from './Overview'; -import Stats from './Stats'; -const { useSelect, useInViewSelect } = Data; - -export default function ModuleOverviewWidget( props ) { - const { Widget, WidgetReportZero, WidgetReportError } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const [ selectedStats, setSelectedStats ] = useState( 0 ); - const { endDate, compareStartDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - compare: true, - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isGatheringData() - ); - - const reportArgs = { - startDate: compareStartDate, - endDate, - dimensions: 'date', - }; - - const data = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getReport( reportArgs ) - ); - const error = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getErrorForSelector( 'getReport', [ - reportArgs, - ] ) - ); - const loading = useSelect( - ( select ) => - ! select( - MODULES_SEARCH_CONSOLE - ).hasFinishedResolution( 'getReport', [ reportArgs ] ) - ); - const dateRangeLength = useSelect( ( select ) => - select( CORE_USER ).getDateRangeNumberOfDays() - ); - - const WidgetHeader = () => ( -
- ); - - if ( loading || isGatheringData === undefined ) { - return ( - - - - - ); - } - - if ( error ) { - return ( - - - - ); - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ( - - - - ); - } - - return ( - - - - - - ); -} - -ModuleOverviewWidget.metrics = [ - { - color: '#4285f4', - label: __( 'Clicks', 'google-site-kit' ), - metric: 'clicks', - }, - { - color: '#27bcd4', - label: __( 'Impressions', 'google-site-kit' ), - metric: 'impressions', - }, - { - color: '#1b9688', - label: __( 'CTR', 'google-site-kit' ), - metric: 'ctr', - }, - { - color: '#673ab7', - label: __( 'Position', 'google-site-kit' ), - metric: 'position', - }, -]; - -ModuleOverviewWidget.propTypes = { - Widget: PropTypes.elementType.isRequired, - WidgetReportZero: PropTypes.elementType.isRequired, - WidgetReportError: PropTypes.elementType.isRequired, -}; diff --git a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Footer.js b/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Footer.js deleted file mode 100644 index 0f2ecb5a96e..00000000000 --- a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Footer.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * ModulePopularKeywordsWidget footer 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. - */ - -/** - * WordPress dependencies - */ -import { _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { - MODULES_SEARCH_CONSOLE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import SourceLink from '../../../../../components/SourceLink'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; - -const { useSelect } = Data; - -export default function Footer() { - const { serviceURL } = useSelect( ( select ) => { - const dateRangeDates = select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ); - - return { - serviceURL: select( MODULES_SEARCH_CONSOLE ).getServiceReportURL( { - ...generateDateRangeArgs( dateRangeDates ), - } ), - }; - } ); - - return ( - - ); -} diff --git a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Header.js b/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Header.js deleted file mode 100644 index ff148c13b1c..00000000000 --- a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/Header.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Header component for ModuleOverviewWidget. - * - * 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. - */ - -/** - * WordPress dependencies - */ -import { Fragment } from '@wordpress/element'; -import { __, sprintf, _n, _x } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import { - MODULES_SEARCH_CONSOLE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { getCurrentDateRangeDayCount } from '../../../../../util/date-range'; -import { generateDateRangeArgs } from '../../../util/report-date-range-args'; -import WidgetHeaderTitle from '../../../../../googlesitekit/widgets/components/WidgetHeaderTitle'; -import WidgetHeaderCTA from '../../../../../googlesitekit/widgets/components/WidgetHeaderCTA'; -import Data from 'googlesitekit-data'; -const { useSelect } = Data; - -const Header = () => { - const dates = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - compare: true, - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - const searchConsoleDeepLink = useSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getServiceReportURL( { - ...generateDateRangeArgs( dates ), - } ) - ); - const dateRange = useSelect( ( select ) => - select( CORE_USER ).getDateRange() - ); - const currentDayCount = getCurrentDateRangeDayCount( dateRange ); - - return ( - - - - - ); -}; - -export default Header; diff --git a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/index.js b/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/index.js deleted file mode 100644 index ccac8517761..00000000000 --- a/assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget/index.js +++ /dev/null @@ -1,180 +0,0 @@ -/** - * ModulePopularKeywordsWidget 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'; - -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ -import Data from 'googlesitekit-data'; -import { CORE_USER } from '../../../../../googlesitekit/datastore/user/constants'; -import { - MODULES_SEARCH_CONSOLE, - DATE_RANGE_OFFSET, -} from '../../../datastore/constants'; -import { numFmt } from '../../../../../util'; -import { isZeroReport, generateDateRangeArgs } from '../../../util'; -import PreviewTable from '../../../../../components/PreviewTable'; -import Link from '../../../../../components/Link'; -import TableOverflowContainer from '../../../../../components/TableOverflowContainer'; -import ReportTable from '../../../../../components/ReportTable'; -import { ZeroDataMessage } from '../../common'; -import { useFeature } from '../../../../../hooks/useFeature'; -import Header from './Header'; -import Footer from './Footer'; -const { useSelect, useInViewSelect } = Data; - -export default function ModulePopularKeywordsWidget( props ) { - const { Widget, WidgetReportZero, WidgetReportError } = props; - - const zeroDataStates = useFeature( 'zeroDataStates' ); - - const isGatheringData = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).isGatheringData() - ); - - const { startDate, endDate } = useSelect( ( select ) => - select( CORE_USER ).getDateRangeDates( { - offsetDays: DATE_RANGE_OFFSET, - } ) - ); - - const reportArgs = { - startDate, - endDate, - dimensions: 'query', - limit: 10, - }; - - const { isLoading, error } = useSelect( ( select ) => { - return { - isLoading: ! select( - MODULES_SEARCH_CONSOLE - ).hasFinishedResolution( 'getReport', [ reportArgs ] ), - error: select( - MODULES_SEARCH_CONSOLE - ).getErrorForSelector( 'getReport', [ reportArgs ] ), - }; - } ); - - const data = useInViewSelect( ( select ) => - select( MODULES_SEARCH_CONSOLE ).getReport( reportArgs ) - ); - - if ( isLoading || isGatheringData === undefined ) { - return ( - - - - ); - } - - if ( error ) { - return ( - - - - ); - } - - if ( ! zeroDataStates && isGatheringData && isZeroReport( data ) ) { - return ( - - - - ); - } - - const tableColumns = [ - { - title: __( 'Keyword', 'google-site-kit' ), - description: __( - 'Most searched for keywords related to your content', - 'google-site-kit' - ), - primary: true, - field: 'keys.0', - Component: ( { fieldValue } ) => { - const searchAnalyticsURL = useSelect( ( select ) => { - return select( MODULES_SEARCH_CONSOLE ).getServiceReportURL( - { - ...generateDateRangeArgs( { startDate, endDate } ), - query: `!${ fieldValue }`, - } - ); - } ); - - return ( - - { fieldValue } - - ); - }, - }, - { - title: __( 'Clicks', 'google-site-kit' ), - description: __( - 'Number of times users clicked on your content in search results', - 'google-site-kit' - ), - Component: ( { row } ) => ( - { numFmt( row.clicks, { style: 'decimal' } ) } - ), - }, - { - title: __( 'Impressions', 'google-site-kit' ), - description: __( - 'Counted each time your content appears in search results', - 'google-site-kit' - ), - Component: ( { row } ) => ( - { numFmt( row.impressions, { style: 'decimal' } ) } - ), - }, - ]; - - return ( - - - - - - ); -} - -ModulePopularKeywordsWidget.propTypes = { - Widget: PropTypes.func.isRequired, - WidgetReportZero: PropTypes.func.isRequired, - WidgetReportError: PropTypes.func.isRequired, -}; diff --git a/assets/js/modules/search-console/components/module/index.js b/assets/js/modules/search-console/components/module/index.js deleted file mode 100644 index bf34ae8d5df..00000000000 --- a/assets/js/modules/search-console/components/module/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Search Console module components. - * - * 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. - */ - -export { default as ModulePopularKeywordsWidget } from './ModulePopularKeywordsWidget'; -export { default as ModuleOverviewWidget } from './ModuleOverviewWidget'; diff --git a/assets/js/modules/search-console/constants.js b/assets/js/modules/search-console/constants.js index baa96ad5ae2..6d0a544b6fb 100644 --- a/assets/js/modules/search-console/constants.js +++ b/assets/js/modules/search-console/constants.js @@ -16,5 +16,4 @@ * limitations under the License. */ -export const CONTEXT_MODULE_SEARCH_CONSOLE = 'moduleSearchConsole'; export const AREA_MODULE_SEARCH_CONSOLE_MAIN = 'moduleSearchConsoleMain'; diff --git a/assets/js/modules/search-console/datastore/base.js b/assets/js/modules/search-console/datastore/base.js index 3175e8c7a8b..35c940c695e 100644 --- a/assets/js/modules/search-console/datastore/base.js +++ b/assets/js/modules/search-console/datastore/base.js @@ -20,7 +20,6 @@ * Internal dependencies */ import Modules from 'googlesitekit-modules'; -import { isFeatureEnabled } from '../../../features'; import { MODULES_SEARCH_CONSOLE } from './constants'; import { submitChanges, validateCanSubmitChanges } from './settings'; @@ -28,9 +27,6 @@ const baseModuleStore = Modules.createModuleStore( 'search-console', { ownedSettingsSlugs: [ 'propertyID' ], storeName: MODULES_SEARCH_CONSOLE, settingSlugs: [ 'propertyID', 'ownerID' ], - adminPage: isFeatureEnabled( 'unifiedDashboard' ) - ? undefined - : 'googlesitekit-module-search-console', requiresSetup: false, submitChanges, validateCanSubmitChanges, diff --git a/assets/js/modules/search-console/datastore/base.test.js b/assets/js/modules/search-console/datastore/base.test.js index ff035215554..3662e175c11 100644 --- a/assets/js/modules/search-console/datastore/base.test.js +++ b/assets/js/modules/search-console/datastore/base.test.js @@ -36,10 +36,7 @@ describe( 'modules/search-console base data store', () => { provideSiteInfo( registry ); } ); - it( 'does not define the admin page when unified dashboard is enabled', () => { - const { enabledFeatures } = require( '../../../features' ); - enabledFeatures.add( 'unifiedDashboard' ); - + it( 'does not define the admin page', () => { store = require( './base' ).default; registry.registerStore( MODULES_SEARCH_CONSOLE, store ); @@ -49,15 +46,4 @@ describe( 'modules/search-console base data store', () => { 'http://example.com/wp-admin/admin.php?page=googlesitekit-dashboard' ); } ); - - it( 'does define the admin page when unified dashboard is not enabled', () => { - store = require( './base' ).default; - registry.registerStore( MODULES_SEARCH_CONSOLE, store ); - - expect( - registry.select( MODULES_SEARCH_CONSOLE ).getAdminScreenURL() - ).toBe( - 'http://example.com/wp-admin/admin.php?page=googlesitekit-module-search-console' - ); - } ); } ); diff --git a/assets/js/modules/search-console/index.js b/assets/js/modules/search-console/index.js index 0401c845715..ef322ac06ee 100644 --- a/assets/js/modules/search-console/index.js +++ b/assets/js/modules/search-console/index.js @@ -16,39 +16,20 @@ * limitations under the License. */ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; - /** * Internal dependencies */ import { SettingsEdit, SettingsView } from './components/settings'; -import DashboardImpressionsWidget from './components/dashboard/DashboardImpressionsWidget'; -import DashboardClicksWidget from './components/dashboard/DashboardClicksWidget'; import DashboardPopularKeywordsWidget from './components/dashboard/DashboardPopularKeywordsWidget'; -import ModulePopularKeywordsWidget from './components/module/ModulePopularKeywordsWidget'; -import ModuleOverviewWidget from './components/module/ModuleOverviewWidget'; import SearchFunnelWidget from './components/dashboard/SearchFunnelWidget'; import { - AREA_DASHBOARD_ACQUISITION, - AREA_DASHBOARD_SEARCH_FUNNEL, - AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY, AREA_MAIN_DASHBOARD_CONTENT_PRIMARY, - AREA_PAGE_DASHBOARD_ACQUISITION, - AREA_PAGE_DASHBOARD_SEARCH_FUNNEL, AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, + AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY, AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, } from '../../googlesitekit/widgets/default-areas'; import SearchConsoleIcon from '../../../svg/graphics/search-console.svg'; import { MODULES_SEARCH_CONSOLE } from './datastore/constants'; -import { - CONTEXT_MODULE_SEARCH_CONSOLE, - AREA_MODULE_SEARCH_CONSOLE_MAIN, -} from './constants'; -import { WIDGET_AREA_STYLES } from '../../googlesitekit/widgets/datastore/constants'; -import { isFeatureEnabled } from '../../features'; export { registerStore } from './datastore'; @@ -58,113 +39,37 @@ export const registerModule = ( modules ) => { SettingsEditComponent: SettingsEdit, SettingsViewComponent: SettingsView, Icon: SearchConsoleIcon, - screenWidgetContext: CONTEXT_MODULE_SEARCH_CONSOLE, } ); }; export const registerWidgets = ( widgets ) => { - if ( ! isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'searchConsoleImpressions', - { - Component: DashboardImpressionsWidget, - width: widgets.WIDGET_WIDTHS.QUARTER, - priority: 1, - wrapWidget: true, - modules: [ 'search-console' ], - }, - [ AREA_DASHBOARD_SEARCH_FUNNEL, AREA_PAGE_DASHBOARD_SEARCH_FUNNEL ] - ); - widgets.registerWidget( - 'searchConsoleClicks', - { - Component: DashboardClicksWidget, - width: widgets.WIDGET_WIDTHS.QUARTER, - priority: 2, - wrapWidget: true, - modules: [ 'search-console' ], - }, - [ AREA_DASHBOARD_SEARCH_FUNNEL, AREA_PAGE_DASHBOARD_SEARCH_FUNNEL ] - ); - widgets.registerWidget( - 'searchConsolePopularKeywords', - { - Component: DashboardPopularKeywordsWidget, - width: [ - widgets.WIDGET_WIDTHS.HALF, - widgets.WIDGET_WIDTHS.FULL, - ], - priority: 1, - wrapWidget: false, - modules: [ 'search-console' ], - }, - [ AREA_DASHBOARD_ACQUISITION, AREA_PAGE_DASHBOARD_ACQUISITION ] - ); - widgets.registerWidget( - 'searchConsoleModuleOverview', - { - Component: ModuleOverviewWidget, - width: widgets.WIDGET_WIDTHS.FULL, - priority: 1, - wrapWidget: false, - modules: [ 'search-console' ], - }, - [ AREA_MODULE_SEARCH_CONSOLE_MAIN ] - ); - widgets.registerWidgetArea( - AREA_MODULE_SEARCH_CONSOLE_MAIN, - { - priority: 1, - style: WIDGET_AREA_STYLES.BOXES, - title: __( 'Overview', 'google-site-kit' ), - }, - CONTEXT_MODULE_SEARCH_CONSOLE - ); - widgets.registerWidget( - 'searchConsoleModulePopularKeywords', - { - Component: ModulePopularKeywordsWidget, - width: [ widgets.WIDGET_WIDTHS.FULL ], - priority: 2, - wrapWidget: false, - modules: [ 'search-console' ], - }, - [ AREA_MODULE_SEARCH_CONSOLE_MAIN ] - ); - } - - if ( isFeatureEnabled( 'unifiedDashboard' ) ) { - widgets.registerWidget( - 'searchConsolePopularKeywords', - { - Component: DashboardPopularKeywordsWidget, - width: [ - widgets.WIDGET_WIDTHS.HALF, - widgets.WIDGET_WIDTHS.FULL, - ], - priority: 1, - wrapWidget: false, - modules: [ 'search-console' ], - }, - [ - AREA_MAIN_DASHBOARD_CONTENT_PRIMARY, - AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY, - ] - ); + widgets.registerWidget( + 'searchConsolePopularKeywords', + { + Component: DashboardPopularKeywordsWidget, + width: [ widgets.WIDGET_WIDTHS.HALF, widgets.WIDGET_WIDTHS.FULL ], + priority: 1, + wrapWidget: false, + modules: [ 'search-console' ], + }, + [ + AREA_MAIN_DASHBOARD_CONTENT_PRIMARY, + AREA_ENTITY_DASHBOARD_CONTENT_PRIMARY, + ] + ); - widgets.registerWidget( - 'searchFunnel', - { - Component: SearchFunnelWidget, - width: [ widgets.WIDGET_WIDTHS.FULL ], - priority: 3, - wrapWidget: false, - modules: [ 'search-console' ], - }, - [ - AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, - AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, - ] - ); - } + widgets.registerWidget( + 'searchFunnel', + { + Component: SearchFunnelWidget, + width: [ widgets.WIDGET_WIDTHS.FULL ], + priority: 3, + wrapWidget: false, + modules: [ 'search-console' ], + }, + [ + AREA_MAIN_DASHBOARD_TRAFFIC_PRIMARY, + AREA_ENTITY_DASHBOARD_TRAFFIC_PRIMARY, + ] + ); }; diff --git a/assets/js/util/scroll.js b/assets/js/util/scroll.js index 20da7307e6a..760c9af6031 100644 --- a/assets/js/util/scroll.js +++ b/assets/js/util/scroll.js @@ -39,18 +39,7 @@ export function getContextScrollTop( context, breakpoint ) { const contextTop = contextElement.getBoundingClientRect().top; const headerHeight = getHeaderHeight( breakpoint ); - /* - * The old PSI dashboard widget anchor points to the widget box and not the - * header of the widget which is 80px higher. - * - * @TODO Remove this when the unified dashboard is published and the - * `unifiedDashboard` feature flag is removed as the new widget uses the new - * #speed anchor. - */ - const anchorAdjustment = - context === '#googlesitekit-pagespeed-header' ? 80 : 0; - - return contextTop + global.scrollY - headerHeight - anchorAdjustment; + return contextTop + global.scrollY - headerHeight; } /** diff --git a/assets/sass/components/global/_googlesitekit-data-block.scss b/assets/sass/components/global/_googlesitekit-data-block.scss index 55a2bc3ca14..dcbebf2f470 100644 --- a/assets/sass/components/global/_googlesitekit-data-block.scss +++ b/assets/sass/components/global/_googlesitekit-data-block.scss @@ -31,16 +31,6 @@ padding-top: 12px; } - .googlesitekit-dashboard-adsense-stats & { - align-items: flex-end; - display: flex; - - @media (max-width: $bp-mobileOnly ) { - align-items: normal; - flex-direction: column; - } - } - &--button { cursor: pointer; display: flex; @@ -111,27 +101,6 @@ } } - .googlesitekit-data-block__title-datapoint-wrapper { - - .googlesitekit-dashboard-adsense-stats & { - flex: 0 0 auto; - } - } - - .googlesitekit-data-block__change-source-wrapper { - - .googlesitekit-dashboard-adsense-stats & { - flex: 0 0 auto; - margin-bottom: 2px; - - @media (max-width: $bp-mobileOnly ) { - align-items: flex-end; - display: flex; - justify-content: space-between; - } - } - } - .googlesitekit-data-block__title { color: $c-primary; font-weight: $fw-primary-normal; @@ -143,11 +112,6 @@ margin-bottom: 5px; } - .googlesitekit-dashboard-adsense-stats & { - font-size: 0.75rem; - margin-bottom: 0; - } - #dashboard-widgets .googlesitekit-wp-dashboard & { font-size: 0.75rem; } @@ -177,10 +141,6 @@ .googlesitekit-wp-dashboard & { font-size: 2.125rem; } - - .googlesitekit-dashboard-adsense-stats & { - font-size: 2.25rem; - } } .googlesitekit-data-block__change { @@ -200,10 +160,6 @@ .googlesitekit-wp-dashboard & { margin-top: 10px; } - - .googlesitekit-dashboard-adsense-stats & { - margin-top: 0; - } } .googlesitekit-data-block__change--no-change { @@ -218,22 +174,6 @@ .googlesitekit-adminbar & { display: none; } - - .googlesitekit-dashboard-adsense-stats & { - flex: 1 1 100%; - margin: 0 0 5px 0; - max-width: initial; - min-width: 10px; - padding: 0 ( $grid-gap-phone / 2 ); - - @media (min-width: $bp-desktop) { - padding: 0 ( $grid-gap-desktop / 2 ); - } - - @media (min-width: $bp-xlarge) { - padding: 0 $grid-gap-desktop; - } - } } /* stylelint-disable no-descending-specificity */ diff --git a/assets/sass/components/global/_googlesitekit-header.scss b/assets/sass/components/global/_googlesitekit-header.scss index 4153a5220fa..1382cd3db74 100644 --- a/assets/sass/components/global/_googlesitekit-header.scss +++ b/assets/sass/components/global/_googlesitekit-header.scss @@ -22,11 +22,13 @@ @include googlesitekit-inner-padding; @include shadow; + background-color: $c-base; left: 0; position: sticky; right: 0; top: 0; + transition: box-shadow $t-default ease-in-out; z-index: 12; .wp-responsive-open & { @@ -49,6 +51,18 @@ } } + &.googlesitekit-header--has-subheader { + + .googlesitekit-plugin--has-scrolled & { + + @include shadow; + } + } + + &.googlesitekit-header--has-navigation { + box-shadow: none; + } + .googlesitekit-header__logo { // prevent the logo from wrapping towards the tablet and mobile breakpoints min-width: 150px; @@ -122,27 +136,15 @@ padding-right: $grid-gap-desktop; @media (max-width: $bp-mobileOnly) { - min-width: 36px; + background: none; + margin-right: 0; padding-right: 8px; } - } - .googlesitekit-header__date-range-selector-menu--has-unified-dashboard { - - &.mdc-button--dropdown { + svg { @media (max-width: $bp-mobileOnly) { - - background: none; margin-right: 0; - padding-right: 8px; - } - - svg { - - @media (max-width: $bp-mobileOnly) { - margin-right: 0; - } } } } @@ -176,20 +178,6 @@ padding: 4px; } } - - } - - .googlesitekit-header--has-unified-dashboard { - box-shadow: none; - transition: box-shadow $t-default ease-in-out; - - &.googlesitekit-header--has-subheader { - - .googlesitekit-plugin--has-scrolled & { - - @include shadow; - } - } } .googlesitekit-subheader { diff --git a/assets/sass/components/global/_googlesitekit-table.scss b/assets/sass/components/global/_googlesitekit-table.scss index 07ab72a0302..580287aa975 100644 --- a/assets/sass/components/global/_googlesitekit-table.scss +++ b/assets/sass/components/global/_googlesitekit-table.scss @@ -26,7 +26,6 @@ padding: $grid-gap-desktop; } - .googlesitekit-details-widget &, .googlesitekit-alltraffic-widget &, .googlesitekit-wp-dashboard & { padding: 0; diff --git a/feature-flags.json b/feature-flags.json index 544abe0cd89..402d6afef54 100644 --- a/feature-flags.json +++ b/feature-flags.json @@ -4,6 +4,5 @@ "ideaHubModule", "swgModule", "userInput", - "unifiedDashboard", "zeroDataStates" ] diff --git a/includes/Core/Admin/Screens.php b/includes/Core/Admin/Screens.php index 2c26c11c132..70acd18f191 100644 --- a/includes/Core/Admin/Screens.php +++ b/includes/Core/Admin/Screens.php @@ -125,10 +125,8 @@ function() { // Redirect dashboard to splash if no dashboard access (yet). $this->no_access_redirect_dashboard_to_splash(); - // Redirect module pages to dashboard if unifiedDashboard is enabled. - if ( Feature_Flags::enabled( 'unifiedDashboard' ) ) { - $this->no_access_redirect_module_to_dashboard(); - } + // Redirect module pages to dashboard. + $this->no_access_redirect_module_to_dashboard(); } ); @@ -466,22 +464,6 @@ private function get_screens() { ) ); - // Wrap this simply to save some unnecessary filter firing and screen instantiation. - if ( current_user_can( Permissions::VIEW_MODULE_DETAILS ) ) { - /** - * Filters the admin screens for modules. - * - * By default this is an empty array, but can be expanded. - * - * @since 1.0.0 - * - * @param array $module_screens List of Screen instances. - */ - $module_screens = apply_filters( 'googlesitekit_module_screens', array() ); - - $screens = array_merge( $screens, $module_screens ); - } - return $screens; } } diff --git a/includes/Core/Assets/Assets.php b/includes/Core/Assets/Assets.php index acafa48cd01..71e655c290f 100644 --- a/includes/Core/Assets/Assets.php +++ b/includes/Core/Assets/Assets.php @@ -584,13 +584,6 @@ private function get_assets() { 'dependencies' => $dependencies_for_dashboard_sharing, ) ), - new Script( - 'googlesitekit-module', - array( - 'src' => $base_url . 'js/googlesitekit-module.js', - 'dependencies' => $dependencies, - ) - ), new Script( 'googlesitekit-settings', array( diff --git a/includes/Core/Modules/Module.php b/includes/Core/Modules/Module.php index 8804affa387..42de81ca2b0 100644 --- a/includes/Core/Modules/Module.php +++ b/includes/Core/Modules/Module.php @@ -178,29 +178,6 @@ final public function __get( $key ) { return $this->info[ $key ]; } - /** - * Returns all module information data for passing it to JavaScript. - * - * @since 1.0.0 - * - * @return array Module information data. - */ - public function prepare_info_for_js() { - // TODO: Modify this to ditch unnecessary backward-compatibility. - return array( - 'slug' => $this->slug, - 'name' => $this->name, - 'description' => $this->description, - 'sort' => $this->order, - 'homepage' => $this->homepage, - 'required' => $this->depends_on, - 'autoActivate' => $this->force_active, - 'internal' => $this->internal, - 'screenID' => $this instanceof Module_With_Screen ? $this->get_screen()->get_slug() : false, - 'settings' => $this instanceof Module_With_Settings ? $this->get_settings()->get() : false, - ); - } - /** * Checks whether the module is connected. * diff --git a/includes/Core/Modules/Module_With_Screen.php b/includes/Core/Modules/Module_With_Screen.php deleted file mode 100644 index 2e051c7b7c8..00000000000 --- a/includes/Core/Modules/Module_With_Screen.php +++ /dev/null @@ -1,32 +0,0 @@ -screen ) { - $module_screen_slug = 'module-' . $this->slug; - $this->screen = new Screen( - Screens::PREFIX . $module_screen_slug, - array( - 'title' => $this->name, - 'capability' => Permissions::VIEW_MODULE_DETAILS, - 'enqueue_callback' => function ( Assets $assets ) { - $assets->enqueue_asset( 'googlesitekit-module' ); - }, - 'initialize_callback' => function () use ( $module_screen_slug ) { - $reauth = $this->context->input()->filter( INPUT_GET, 'reAuth', FILTER_VALIDATE_BOOLEAN ); - // If the module is not set up yet, and `reAuth` is not enabled - // via the query parameter, then redirect to this URL. - if ( ! $reauth && ! $this->is_connected() ) { - wp_safe_redirect( - $this->context->admin_url( - $module_screen_slug, - array( - 'slug' => $this->slug, - 'reAuth' => true, - ) - ) - ); - exit(); - } - }, - 'render_callback' => function ( Context $context ) { - $module_info = $this->prepare_info_for_js(); - $setup_slug = $this->context->input()->filter( INPUT_GET, 'slug', FILTER_SANITIZE_STRING ); - $reauth = $this->context->input()->filter( INPUT_GET, 'reAuth', FILTER_VALIDATE_BOOLEAN ); - $setup_module_slug = $setup_slug && $reauth ? $setup_slug : ''; - ?> -
- screen; - } - - /** - * Registers the hook to add the module screen. - * - * @since 1.0.0 - */ - private function register_screen_hook() { - add_filter( - 'googlesitekit_module_screens', - function( array $screens ) { - $screens[] = $this->get_screen(); - return $screens; - } - ); - } -} diff --git a/includes/Core/Permissions/Permissions.php b/includes/Core/Permissions/Permissions.php index d82094d63da..ecfd137a41d 100644 --- a/includes/Core/Permissions/Permissions.php +++ b/includes/Core/Permissions/Permissions.php @@ -35,7 +35,6 @@ final class Permissions { const SETUP = 'googlesitekit_setup'; const VIEW_POSTS_INSIGHTS = 'googlesitekit_view_posts_insights'; const VIEW_DASHBOARD = 'googlesitekit_view_dashboard'; - const VIEW_MODULE_DETAILS = 'googlesitekit_view_module_details'; const VIEW_WP_DASHBOARD_WIDGET = 'googlesitekit_view_wp_dashboard_widget'; const VIEW_ADMIN_BAR_MENU = 'googlesitekit_view_admin_bar_menu'; const MANAGE_OPTIONS = 'googlesitekit_manage_options'; @@ -163,7 +162,6 @@ public function __construct( Context $context, Authentication $authentication, M // Allow editors and up to view the dashboard and module details. // TODO change to map to edit_posts when Dashboard Sharing feature flag is removed. self::VIEW_DASHBOARD => $editor_capability, - self::VIEW_MODULE_DETAILS => $editor_capability, self::VIEW_WP_DASHBOARD_WIDGET => $editor_capability, self::VIEW_ADMIN_BAR_MENU => $editor_capability, @@ -202,7 +200,6 @@ public function __construct( Context $context, Authentication $authentication, M // Require network admin access to view the dashboard and module details in network mode. // TODO change to map to manage_network when Dashboard Sharing feature flag is removed. self::VIEW_DASHBOARD => $admin_network_capability, - self::VIEW_MODULE_DETAILS => $admin_network_capability, self::VIEW_WP_DASHBOARD_WIDGET => $admin_network_capability, self::VIEW_ADMIN_BAR_MENU => $admin_network_capability, @@ -699,7 +696,6 @@ public static function get_capabilities() { self::SETUP, self::VIEW_POSTS_INSIGHTS, self::VIEW_DASHBOARD, - self::VIEW_MODULE_DETAILS, self::MANAGE_OPTIONS, self::VIEW_SPLASH, self::VIEW_AUTHENTICATED_DASHBOARD, diff --git a/includes/Modules/AdSense.php b/includes/Modules/AdSense.php index 254a9db97d1..9ad6af6c48a 100644 --- a/includes/Modules/AdSense.php +++ b/includes/Modules/AdSense.php @@ -14,8 +14,6 @@ use Google\Site_Kit\Core\Modules\Module_Settings; use Google\Site_Kit\Core\Modules\Module_With_Deactivation; use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields; -use Google\Site_Kit\Core\Modules\Module_With_Screen; -use Google\Site_Kit\Core\Modules\Module_With_Screen_Trait; use Google\Site_Kit\Core\Modules\Module_With_Scopes; use Google\Site_Kit\Core\Modules\Module_With_Scopes_Trait; use Google\Site_Kit\Core\Modules\Module_With_Settings; @@ -55,12 +53,11 @@ * @ignore */ final class AdSense extends Module - implements Module_With_Screen, Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity, Module_With_Deactivation { + implements Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity, Module_With_Deactivation { use Method_Proxy_Trait; use Module_With_Assets_Trait; use Module_With_Owner_Trait; use Module_With_Scopes_Trait; - use Module_With_Screen_Trait; use Module_With_Settings_Trait; /** @@ -76,10 +73,6 @@ final class AdSense extends Module public function register() { $this->register_scopes_hook(); - if ( ! Feature_Flags::enabled( 'unifiedDashboard' ) ) { - $this->register_screen_hook(); - } - add_action( 'wp_head', $this->get_method_proxy_once( 'render_platform_meta_tags' ) ); if ( $this->is_connected() ) { diff --git a/includes/Modules/Analytics.php b/includes/Modules/Analytics.php index b11fb915ac1..fb509ac0066 100644 --- a/includes/Modules/Analytics.php +++ b/includes/Modules/Analytics.php @@ -14,8 +14,6 @@ use Google\Site_Kit\Core\Modules\Module_Settings; use Google\Site_Kit\Core\Modules\Module_With_Deactivation; use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields; -use Google\Site_Kit\Core\Modules\Module_With_Screen; -use Google\Site_Kit\Core\Modules\Module_With_Screen_Trait; use Google\Site_Kit\Core\Modules\Module_With_Scopes; use Google\Site_Kit\Core\Modules\Module_With_Scopes_Trait; use Google\Site_Kit\Core\Modules\Module_With_Settings; @@ -73,12 +71,11 @@ * @ignore */ final class Analytics extends Module - implements Module_With_Screen, Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity, Module_With_Deactivation { + implements Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity, Module_With_Deactivation { use Method_Proxy_Trait; use Module_With_Assets_Trait; use Module_With_Owner_Trait; use Module_With_Scopes_Trait; - use Module_With_Screen_Trait; use Module_With_Settings_Trait; const PROVISION_ACCOUNT_TICKET_ID = 'googlesitekit_analytics_provision_account_ticket_id'; @@ -100,10 +97,6 @@ final class Analytics extends Module public function register() { $this->register_scopes_hook(); - if ( ! Feature_Flags::enabled( 'unifiedDashboard' ) ) { - $this->register_screen_hook(); - } - /** * This filter only exists to be unhooked by the AdSense module if active. * diff --git a/includes/Modules/Search_Console.php b/includes/Modules/Search_Console.php index 4dd3aa8992e..1fa01aaef9e 100644 --- a/includes/Modules/Search_Console.php +++ b/includes/Modules/Search_Console.php @@ -15,8 +15,6 @@ use Google\Site_Kit\Core\Modules\Module_With_Debug_Fields; use Google\Site_Kit\Core\Modules\Module_With_Owner; use Google\Site_Kit\Core\Modules\Module_With_Owner_Trait; -use Google\Site_Kit\Core\Modules\Module_With_Screen; -use Google\Site_Kit\Core\Modules\Module_With_Screen_Trait; use Google\Site_Kit\Core\Modules\Module_With_Scopes; use Google\Site_Kit\Core\Modules\Module_With_Scopes_Trait; use Google\Site_Kit\Core\Authentication\Clients\Google_Site_Kit_Client; @@ -53,8 +51,8 @@ * @ignore */ final class Search_Console extends Module - implements Module_With_Screen, Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity { - use Module_With_Screen_Trait, Module_With_Scopes_Trait, Module_With_Settings_Trait, Google_URL_Matcher_Trait, Module_With_Assets_Trait, Module_With_Owner_Trait; + implements Module_With_Scopes, Module_With_Settings, Module_With_Assets, Module_With_Debug_Fields, Module_With_Owner, Module_With_Service_Entity { + use Module_With_Scopes_Trait, Module_With_Settings_Trait, Google_URL_Matcher_Trait, Module_With_Assets_Trait, Module_With_Owner_Trait; /** * Module slug name. @@ -69,10 +67,6 @@ final class Search_Console extends Module public function register() { $this->register_scopes_hook(); - if ( ! Feature_Flags::enabled( 'unifiedDashboard' ) ) { - $this->register_screen_hook(); - } - // Detect and store Search Console property when receiving token for the first time. add_action( 'googlesitekit_authorize_user', diff --git a/stories/dashboard-details.stories.js b/stories/dashboard-details.stories.js deleted file mode 100644 index 442887a956a..00000000000 --- a/stories/dashboard-details.stories.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Dashboard Details page 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. - */ - -/** - * External dependencies - */ -import { storiesOf } from '@storybook/react'; - -/** - * Internal dependencies - */ -import { - provideSiteInfo, - provideUserAuthentication, - WithTestRegistry, -} from '../tests/js/utils'; -import { CORE_SITE } from '../assets/js/googlesitekit/datastore/site/constants'; -import DashboardDetailsApp from '../assets/js/components/dashboard-details/DashboardDetailsApp'; - -storiesOf( 'Dashboard Details', module ) - .add( - 'Existing Entity', - () => { - const setupRegistry = ( registry ) => { - provideUserAuthentication( registry ); - provideSiteInfo( registry, { - currentEntityTitle: 'Test Page', - currentEntityURL: 'https://example.com/test-page', - currentEntityType: 'post', - currentEntityID: 5, - } ); - }; - - return ( - - - - ); - }, - { - padding: 0, - } - ) - .add( - 'Not Found Entity', - () => { - const setupRegistry = ( registry ) => { - provideUserAuthentication( registry ); - // By default, the current entity info is all `null` as needed here. - provideSiteInfo( registry ); - registry - .dispatch( CORE_SITE ) - .receivePermaLinkParam( - 'https://example.com/invalid-page' - ); - }; - - return ( - - - - ); - }, - { - padding: 0, - } - ); diff --git a/stories/module-adsense-components.stories.js b/stories/module-adsense-components.stories.js index 1c1da914b4e..24439e73d0f 100644 --- a/stories/module-adsense-components.stories.js +++ b/stories/module-adsense-components.stories.js @@ -23,9 +23,7 @@ import { generateReportBasedWidgetStories, makeReportDataGenerator, } from './utils/generate-widget-stories'; -import DashboardSummaryWidget from '../assets/js/modules/adsense/components/dashboard/DashboardSummaryWidget'; import DashboardTopEarningPagesWidget from '../assets/js/modules/adsense/components/dashboard/DashboardTopEarningPagesWidget'; -import ModuleTopEarningPagesWidget from '../assets/js/modules/adsense/components/module/ModuleTopEarningPagesWidget'; import ModuleOverviewWidget from '../assets/js/modules/adsense/components/module/ModuleOverviewWidget'; import { MODULES_ADSENSE } from '../assets/js/modules/adsense/datastore/constants'; import { MODULES_ANALYTICS } from '../assets/js/modules/analytics/datastore/constants'; @@ -40,49 +38,6 @@ const generateAnalyticsData = makeReportDataGenerator( ); const generateAdSenseData = makeReportDataGenerator( getAdSenseMockResponse ); -const dashboardSummaryOptions = [ - { - // Custom start and end date for this widget to match data range: 'previousPeriod', - startDate: '2020-07-18', - endDate: '2020-08-14', - metrics: [ 'ESTIMATED_EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS' ], - }, - { - // getDateRangeDates( { offsetDays: 1 }) for 'last-28-days' and '2020-09-12'. - startDate: '2020-08-15', - endDate: '2020-09-11', - metrics: [ 'ESTIMATED_EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS' ], - }, - { - // Custom start and end date for this widget to match data range: 'this-month', - startDate: '2020-08-15', - endDate: '2020-09-11', - metrics: [ 'ESTIMATED_EARNINGS', 'PAGE_VIEWS_RPM', 'IMPRESSIONS' ], - dimensions: [ 'DATE' ], - }, -]; -generateReportBasedWidgetStories( { - moduleSlugs: [ 'adsense', 'analytics' ], - datastore: MODULES_ADSENSE, - group: 'AdSense Module/Components/Dashboard/Summary Widget', - referenceDate: '2020-09-12', - setup: ( { dispatch }, variantName ) => { - dispatch( MODULES_ANALYTICS ).setAdsenseLinked( true ); - dispatch( MODULES_ADSENSE ).receiveIsAdBlockerActive( - variantName === 'Ad Blocker Active' - ); - }, - ...generateAdSenseData( dashboardSummaryOptions ), - Component: DashboardSummaryWidget, - wrapWidget: false, - additionalVariants: { - 'Ad Blocker Active': { - data: [], - options: [], - }, - }, -} ); - const topEarningPagesArgs = { startDate: '2020-08-15', endDate: '2020-09-11', @@ -140,36 +95,6 @@ generateReportBasedWidgetStories( { }, } ); -const moduleTopEarningPagesWidgetOptions = { - ...topEarningPagesArgs, - limit: 10, -}; - -generateReportBasedWidgetStories( { - moduleSlugs: [ 'adsense', 'analytics' ], - datastore: MODULES_ANALYTICS, - setup: ( registry, variantName ) => { - registry - .dispatch( MODULES_ANALYTICS ) - .setAdsenseLinked( variantName !== 'AdSense Not Linked' ); - provideAdSenseMockReport( registry, getCurrencyFromReportOptions ); - registry - .dispatch( MODULES_ADSENSE ) - .finishResolution( 'getReport', [ getCurrencyFromReportOptions ] ); - }, - group: 'AdSense Module/Components/Module/Top Earning Pages Widget', - referenceDate: '2020-09-12', - ...generateAnalyticsData( moduleTopEarningPagesWidgetOptions ), - Component: ModuleTopEarningPagesWidget, - wrapWidget: false, - additionalVariants: { - 'AdSense Not Linked': { - data: [], - options: moduleTopEarningPagesWidgetOptions, - }, - }, -} ); - generateReportBasedWidgetStories( { moduleSlugs: [ 'adsense' ], datastore: MODULES_ADSENSE, diff --git a/stories/module-analytics-components.stories.js b/stories/module-analytics-components.stories.js index 0f897536e3a..c956c85bfa3 100644 --- a/stories/module-analytics-components.stories.js +++ b/stories/module-analytics-components.stories.js @@ -24,19 +24,11 @@ import { makeReportDataGenerator, } from './utils/generate-widget-stories'; import { replaceValuesInAnalyticsReportWithZeroData } from '../.storybook/utils/zeroReports'; -import { - ModulePopularPagesWidget, - ModuleOverviewWidget, - ModuleAcquisitionChannelsWidget, -} from '../assets/js/modules/analytics/components/module'; +import { ModulePopularPagesWidget } from '../assets/js/modules/analytics/components/module'; import { MODULES_ANALYTICS } from '../assets/js/modules/analytics/datastore/constants'; import { accountsPropertiesProfiles } from '../assets/js/modules/analytics/datastore/__fixtures__'; import { getAnalyticsMockResponse } from '../assets/js/modules/analytics/util/data-mock'; -import { - DashboardPopularPagesWidget, - DashboardAllTrafficWidget, - DashboardBounceRateWidget, -} from '../assets/js/modules/analytics/components/dashboard'; +import { DashboardAllTrafficWidget } from '../assets/js/modules/analytics/components/dashboard'; const generateData = makeReportDataGenerator( getAnalyticsMockResponse ); @@ -273,122 +265,6 @@ generateAnalyticsWidgetStories( { wrapWidget: false, } ); -generateAnalyticsWidgetStories( { - group: 'Analytics Module/Components/Page Dashboard/Bounce Rate Widget', - referenceDate: '2020-09-10', - ...generateData( [ - { - compareStartDate: '2020-07-16', - compareEndDate: '2020-08-12', - startDate: '2020-08-13', - endDate: '2020-09-09', - dimensions: 'ga:date', - metrics: [ - { - expression: 'ga:bounceRate', - alias: 'Bounce Rate', - }, - ], - url: 'https://www.sitekit.com/', - }, - { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-08-13', - endDate: '2020-09-09', - url: 'https://www.sitekit.com/', - }, - ] ), - Component: DashboardBounceRateWidget, -} ); - -generateAnalyticsWidgetStories( { - group: 'Analytics Module/Components/Dashboard/Popular Pages Widget', - referenceDate: '2020-09-10', - ...generateData( [ - { - startDate: '2020-08-13', - endDate: '2020-09-09', - dimensions: [ 'ga:pagePath' ], - metrics: [ - { - expression: 'ga:pageviews', - alias: 'Pageviews', - }, - ], - orderby: [ - { - fieldName: 'ga:pageviews', - sortOrder: 'DESCENDING', - }, - ], - limit: 10, - }, - { - startDate: '2020-08-13', - endDate: '2020-09-09', - dimensionFilters: { - 'ga:pagePath': new Array( 10 ) - .fill( '' ) - .map( ( _, i ) => `/test-post-${ i + 1 }/` ) - .sort(), - }, - dimensions: [ 'ga:pagePath', 'ga:pageTitle' ], - metrics: [ { expression: 'ga:pageviews', alias: 'Pageviews' } ], - orderby: [ { fieldName: 'ga:pageviews', sortOrder: 'DESCENDING' } ], - limit: 50, - }, - { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-08-13', - endDate: '2020-09-09', - }, - ] ), - Component: DashboardPopularPagesWidget, - wrapWidget: false, -} ); - -generateAnalyticsWidgetStories( { - group: 'Analytics Module/Components/Module Page/Overview Widget', - referenceDate: '2021-01-06', - ...generateData( [ - { - startDate: '2020-12-09', - endDate: '2021-01-05', - compareStartDate: '2020-11-11', - compareEndDate: '2020-12-08', - metrics: [ - 'ga:users', - 'ga:sessions', - 'ga:bounceRate', - 'ga:avgSessionDuration', - ], - }, - { - startDate: '2020-12-09', - endDate: '2021-01-05', - compareStartDate: '2020-11-11', - compareEndDate: '2020-12-08', - dimensions: 'ga:date', - metrics: [ - 'ga:users', - 'ga:sessions', - 'ga:bounceRate', - 'ga:avgSessionDuration', - ], - }, - { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-12-09', - endDate: '2021-01-05', - }, - ] ), - Component: ModuleOverviewWidget, - wrapWidget: false, -} ); - generateAnalyticsWidgetStories( { group: 'Analytics Module/Components/Module Page/Popular Pages Widget', referenceDate: '2021-01-06', @@ -443,45 +319,3 @@ generateAnalyticsWidgetStories( { Component: ModulePopularPagesWidget, wrapWidget: false, } ); - -generateAnalyticsWidgetStories( { - group: - 'Analytics Module/Components/Module Page/Acquisition Channels Widget', - referenceDate: '2021-01-06', - ...generateData( [ - { - dimensions: 'ga:channelGrouping', - metrics: [ - { - expression: 'ga:sessions', - alias: 'Sessions', - }, - { - expression: 'ga:users', - alias: 'Users', - }, - { - expression: 'ga:newUsers', - alias: 'New Users', - }, - ], - orderby: [ - { - fieldName: 'ga:users', - sortOrder: 'DESCENDING', - }, - ], - limit: 10, - startDate: '2020-12-09', - endDate: '2021-01-05', - }, - { - dimensions: [ 'ga:date' ], - metrics: [ { expression: 'ga:users' } ], - startDate: '2020-12-09', - endDate: '2021-01-05', - }, - ] ), - Component: ModuleAcquisitionChannelsWidget, - wrapWidget: false, -} ); diff --git a/stories/module-search-console-components.stories.js b/stories/module-search-console-components.stories.js index 067add9e579..cecbe6ba0d5 100644 --- a/stories/module-search-console-components.stories.js +++ b/stories/module-search-console-components.stories.js @@ -19,11 +19,7 @@ /** * Internal dependencies */ -import DashboardClicksWidget from '../assets/js/modules/search-console/components/dashboard/DashboardClicksWidget'; -import DashboardImpressionsWidget from '../assets/js/modules/search-console/components/dashboard/DashboardImpressionsWidget'; import DashboardPopularKeywordsWidget from '../assets/js/modules/search-console/components/dashboard/DashboardPopularKeywordsWidget'; -import ModulePopularKeywordsWidget from '../assets/js/modules/search-console/components/module/ModulePopularKeywordsWidget'; -import ModuleOverviewWidget from '../assets/js/modules/search-console/components/module/ModuleOverviewWidget'; import { MODULES_SEARCH_CONSOLE } from '../assets/js/modules/search-console/datastore/constants'; import { getSearchConsoleMockResponse } from '../assets/js/modules/search-console/util/data-mock'; import { @@ -70,52 +66,6 @@ function generateSearchConsoleWidgetStories( args ) { } ); } -generateSearchConsoleWidgetStories( { - group: 'Search Console Module/Components/Dashboard/Clicks Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - } ), - Component: DashboardClicksWidget, -} ); - -generateSearchConsoleWidgetStories( { - group: 'Search Console Module/Components/Page Dashboard/Clicks Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - url: 'https://example.com/example-page/', - } ), - Component: DashboardClicksWidget, -} ); - -generateSearchConsoleWidgetStories( { - group: 'Search Console Module/Components/Dashboard/Impressions Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - } ), - Component: DashboardImpressionsWidget, -} ); - -generateSearchConsoleWidgetStories( { - group: 'Search Console Module/Components/Page Dashboard/Impressions Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - url: 'https://example.com/example-page/', - } ), - Component: DashboardImpressionsWidget, -} ); - generateSearchConsoleWidgetStories( { group: 'Search Console Module/Components/Dashboard/Popular Keywords Widget', referenceDate: '2020-08-26', @@ -158,36 +108,3 @@ generateSearchConsoleWidgetStories( { Component: DashboardPopularKeywordsWidget, wrapWidget: false, } ); - -generateSearchConsoleWidgetStories( { - group: 'Search Console Module/Components/Module Page/Overview Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - } ), - Component: ModuleOverviewWidget, - wrapWidget: false, -} ); - -generateSearchConsoleWidgetStories( { - group: - 'Search Console Module/Components/Module Page/Popular Keywords Widget', - referenceDate: '2020-08-26', - ...generateSearchConsoleData( [ - { - startDate: '2020-07-29', - endDate: '2020-08-25', - dimensions: 'query', - limit: 10, - }, - { - dimensions: 'date', - startDate: '2020-07-01', - endDate: '2020-08-25', - }, - ] ), - Component: ModulePopularKeywordsWidget, - wrapWidget: false, -} ); diff --git a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_0_small.png b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_0_small.png index a99ab2e209d..763bac9388c 100644 Binary files a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_0_small.png and b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_0_small.png differ diff --git a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_1_medium.png b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_1_medium.png index 18be3ba81c7..ad6e04d5924 100644 Binary files a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_1_medium.png and b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_1_medium.png differ diff --git a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_2_large.png b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_2_large.png index a917efee024..1c95ced379b 100644 Binary files a/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_2_large.png and b/tests/backstop/reference/google-site-kit_AdSense_Module_Overview_Widget_0_document_2_large.png differ diff --git a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_1_medium.png b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_1_medium.png index 9ce35555b66..88dcf98c87d 100644 Binary files a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_1_medium.png and b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_1_medium.png differ diff --git a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_2_large.png b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_2_large.png index 5963d8893bb..36e057b0c40 100644 Binary files a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_2_large.png and b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_0_document_2_large.png differ diff --git a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_1_medium.png b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_1_medium.png index ec39aa99896..cb8420cdd59 100644 Binary files a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_1_medium.png and b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_1_medium.png differ diff --git a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_2_large.png b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_2_large.png index 35bcdd0e959..b33f3782b99 100644 Binary files a/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_2_large.png and b/tests/backstop/reference/google-site-kit_Global_Plugin_Header_with_Date_Selector_0_document_2_large.png differ diff --git a/tests/e2e/specs/dashboard/search.test.js b/tests/e2e/specs/dashboard/search.test.js index de0c3462aad..dc613e65d87 100644 --- a/tests/e2e/specs/dashboard/search.test.js +++ b/tests/e2e/specs/dashboard/search.test.js @@ -56,7 +56,9 @@ describe( 'Site Kit dashboard post search', () => { } ); it( 'displays results when searching with a post title, and loads the details page when clicking View Data', async () => { - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', 'hello' ); await page.waitForResponse( ( res ) => @@ -78,24 +80,24 @@ describe( 'Site Kit dashboard post search', () => { await expect( postSearcher ).toClick( '.autocomplete__option', { text: /hello world/i, } ); + + await page.waitForNavigation(); + // Search input becomes the post title + await page.waitForSelector( '.googlesitekit-entity-search' ); + const entitySearcher = await page.$( '.googlesitekit-entity-search' ); expect( - await postSearcher.$eval( 'input', ( el ) => el.value ) + await entitySearcher.$eval( 'input', ( el ) => el.value ) ).toEqual( 'Hello world!' ); - await Promise.all( [ - page.waitForNavigation(), - expect( postSearcher ).toClick( 'button', { text: /view data/i } ), - ] ); - await expect( page ).toMatchElement( - '.googlesitekit-page-header__title', + '.googlesitekit-entity-header__back', { - text: /detailed page stats/i, + text: /back to dashboard/i, } ); await expect( page ).toMatchElement( - '.googlesitekit-dashboard-single-url__title', + '.googlesitekit-entity-header__details p', { text: 'Hello world!', } @@ -103,7 +105,9 @@ describe( 'Site Kit dashboard post search', () => { } ); it( 'displays results when searching with a URL, and loads the details page when clicking View Data', async () => { - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', @@ -126,24 +130,25 @@ describe( 'Site Kit dashboard post search', () => { await expect( postSearcher ).toClick( '.autocomplete__option', { text: /hello world/i, } ); + + page.waitForNavigation(); + + await page.waitForSelector( '.googlesitekit-entity-search' ); + const entitySearcher = await page.$( '.googlesitekit-entity-search' ); + // Search input becomes the post title expect( - await postSearcher.$eval( 'input', ( el ) => el.value ) + await entitySearcher.$eval( 'input', ( el ) => el.value ) ).toEqual( 'Hello world!' ); - await Promise.all( [ - page.waitForNavigation(), - expect( postSearcher ).toClick( 'button', { text: /view data/i } ), - ] ); - await expect( page ).toMatchElement( - '.googlesitekit-page-header__title', + '.googlesitekit-entity-header__back', { - text: /detailed page stats/i, + text: /back to dashboard/i, } ); await expect( page ).toMatchElement( - '.googlesitekit-dashboard-single-url__title', + '.googlesitekit-entity-header__details p', { text: 'Hello world!', } @@ -151,7 +156,9 @@ describe( 'Site Kit dashboard post search', () => { } ); it( 'displays "No results found" when searching by title if no post is found', async () => { - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', 'non-existent title' ); await page.waitForResponse( ( res ) => @@ -169,7 +176,9 @@ describe( 'Site Kit dashboard post search', () => { } ); it( 'displays "No results found" when searching by URL if no post is found', async () => { - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', @@ -191,7 +200,9 @@ describe( 'Site Kit dashboard post search', () => { it( 'works with post titles containing special characters', async () => { const TITLE_SPECIAL_CHARACTERS = 'Hello Spéçïåł čhāràćtęrß!'; - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', 'Spéçïåł' ); await page.waitForResponse( ( res ) => @@ -211,24 +222,25 @@ describe( 'Site Kit dashboard post search', () => { await expect( postSearcher ).toClick( '.autocomplete__option', { text: TITLE_SPECIAL_CHARACTERS, } ); + + await page.waitForNavigation(); + + await page.waitForSelector( '.googlesitekit-entity-search' ); + const entitySearcher = await page.$( '.googlesitekit-entity-search' ); + // Search input becomes the post title expect( - await postSearcher.$eval( 'input', ( el ) => el.value ) + await entitySearcher.$eval( 'input', ( el ) => el.value ) ).toEqual( TITLE_SPECIAL_CHARACTERS ); - await Promise.all( [ - page.waitForNavigation(), - expect( postSearcher ).toClick( 'button', { text: /view data/i } ), - ] ); - await expect( page ).toMatchElement( - '.googlesitekit-page-header__title', + '.googlesitekit-entity-header__back', { - text: /detailed page stats/i, + text: /back to dashboard/i, } ); await expect( page ).toMatchElement( - '.googlesitekit-dashboard-single-url__title', + '.googlesitekit-entity-header__details p', { text: TITLE_SPECIAL_CHARACTERS, } diff --git a/tests/e2e/specs/dashboard/surveys.test.js b/tests/e2e/specs/dashboard/surveys.test.js index 2f2bf40ed2e..37e52639e5a 100644 --- a/tests/e2e/specs/dashboard/surveys.test.js +++ b/tests/e2e/specs/dashboard/surveys.test.js @@ -24,11 +24,7 @@ import { visitAdminPage } from '@wordpress/e2e-test-utils'; /** * Internal dependencies */ -import { - enableFeature, - setupSiteKit, - useRequestInterception, -} from '../../utils'; +import { setupSiteKit, useRequestInterception } from '../../utils'; import surveyResponse from '../../../../assets/js/components/surveys/__fixtures__/survey-single-question.json'; describe( 'dashboard surveys', () => { @@ -71,14 +67,4 @@ describe( 'dashboard surveys', () => { text: surveyResponse.survey_payload.question[ 0 ].question_text, } ); } ); - - it( 'shows a survey on the unified dashboard', async () => { - await enableFeature( 'unifiedDashboard' ); - - await visitAdminPage( 'admin.php', 'page=googlesitekit-dashboard' ); - - await expect( page ).toMatchElement( '.googlesitekit-survey', { - text: surveyResponse.survey_payload.question[ 0 ].question_text, - } ); - } ); } ); diff --git a/tests/e2e/specs/modules/analytics/dashboard-date-range.test.js b/tests/e2e/specs/modules/analytics/dashboard-date-range.test.js deleted file mode 100644 index dcd45174a01..00000000000 --- a/tests/e2e/specs/modules/analytics/dashboard-date-range.test.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Dashboard date range e2e tests. - * - * 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. - */ -/** - * WordPress dependencies - */ -import { activatePlugin, visitAdminPage } from '@wordpress/e2e-test-utils'; -import { getQueryArgs } from '@wordpress/url'; - -/** - * Internal dependencies - */ -import { - pageWait, - setSiteVerification, - setSearchConsoleProperty, - setupAnalytics, - switchDateRange, - useRequestInterception, -} from '../../../utils'; -import { getAnalyticsMockResponse } from '../../../../../assets/js/modules/analytics/util/data-mock'; - -const datapointSelector = - '.googlesitekit-data-block--sessions .googlesitekit-data-block__datapoint'; - -async function getTotalSessions() { - await expect( page ).toMatchElement( datapointSelector ); - return await page.$eval( datapointSelector, ( el ) => el.textContent ); -} - -describe( 'date range filtering on dashboard views', () => { - beforeAll( async () => { - await activatePlugin( 'e2e-tests-proxy-auth-plugin' ); - await setSiteVerification(); - await setSearchConsoleProperty(); - await setupAnalytics(); - - await page.setRequestInterception( true ); - useRequestInterception( ( request ) => { - const url = request.url(); - - if ( url.match( 'notifications' ) ) { - request.respond( { - status: 200, - body: JSON.stringify( [] ), - } ); - } else if ( url.match( 'google-site-kit/v1/modules/analytics' ) ) { - const query = getQueryArgs( url ); - // @TODO The total sessions can be the same even if different dates are selected, - // so we need another way for this test to establish whether the feature works. - // For now, we will force a new mock report to be generated if the url is different. - query.url = url; - const response = getAnalyticsMockResponse( query ); - response[ 0 ].data.rows[ 0 ].dimensions = [ '/' ]; // needed for valid isValidDimensionFilters - - request.respond( { - status: 200, - body: JSON.stringify( response ), - } ); - } else { - request.continue(); - } - } ); - } ); - - it( 'loads new data when the date range is changed on the module dashboard', async () => { - await visitAdminPage( - 'admin.php', - 'page=googlesitekit-module-analytics' - ); - - const TOTAL_SESSIONS_28_DAYS = await getTotalSessions(); - - await Promise.all( [ - switchDateRange( 'last 28 days', 'last 14 days' ), - page.waitForResponse( ( res ) => - res.url().match( 'google-site-kit/v1/modules/analytics' ) - ), - page.waitForSelector( '.googlesitekit-preview-block' ), - ] ); - - const TOTAL_SESSIONS_14_DAYS = await getTotalSessions(); - - expect( TOTAL_SESSIONS_14_DAYS ).not.toBe( TOTAL_SESSIONS_28_DAYS ); - // Switching back will not trigger a data request as it has been cached. - await switchDateRange( 'last 14 days', 'last 28 days' ); - // Need to wait for short time for UI to update, however no selectors/requests to listen for. - await pageWait(); - expect( await getTotalSessions() ).toBe( TOTAL_SESSIONS_28_DAYS ); - } ); -} ); diff --git a/tests/e2e/specs/modules/search-console/admin-bar.test.js b/tests/e2e/specs/modules/search-console/admin-bar.test.js index 3a92b3e0bac..d701ed38051 100644 --- a/tests/e2e/specs/modules/search-console/admin-bar.test.js +++ b/tests/e2e/specs/modules/search-console/admin-bar.test.js @@ -203,13 +203,13 @@ describe( 'Site Kit admin bar component display', () => { } ), // Waiting for navigation here does not work as expected as this is a JS navigation. - page.waitForSelector( '.googlesitekit-page-header__title' ), + page.waitForSelector( '.googlesitekit-entity-header' ), ] ); await expect( page ).toMatchElement( - '.googlesitekit-page-header__title', + '.googlesitekit-entity-header__back', { - title: /Detailed Page Stats/i, + text: /Back to dashboard/i, } ); } ); diff --git a/tests/e2e/specs/modules/search-console/dashboard-date-range.test.js b/tests/e2e/specs/modules/search-console/dashboard-date-range.test.js index e557883d1fe..8323772445a 100644 --- a/tests/e2e/specs/modules/search-console/dashboard-date-range.test.js +++ b/tests/e2e/specs/modules/search-console/dashboard-date-range.test.js @@ -34,7 +34,6 @@ import { } from '../../../utils'; import * as dashboardRequests from './fixtures/dashboard'; import * as dashboardDetailsRequests from './fixtures/dashboard-details'; -import * as modulePageRequests from './fixtures/module-page'; // As part of https://github.com/google/site-kit-wp/issues/2586, // this can be refactored to use the new getSearchConsoleMockResponse utility. @@ -135,7 +134,9 @@ describe( 'date range filtering on dashboard views', () => { const { last28Days, last14Days } = dashboardDetailsRequests; await visitAdminPage( 'admin.php', 'page=googlesitekit-dashboard' ); - const postSearcher = await page.$( '.googlesitekit-post-searcher' ); + const postSearcher = await page.$( '.googlesitekit-entity-search' ); + await page.click( '.googlesitekit-entity-search .mdc-button' ); + await page.waitForSelector( '.googlesitekit-entity-search__actions' ); await expect( postSearcher ).toFill( 'input', 'hello world' ); await page.waitForResponse( ( res ) => @@ -149,7 +150,6 @@ describe( 'date range filtering on dashboard views', () => { await Promise.all( [ page.waitForNavigation(), - expect( postSearcher ).toClick( 'button', { text: /view data/i } ), page.waitForResponse( ( res ) => res .url() @@ -184,36 +184,4 @@ describe( 'date range filtering on dashboard views', () => { await pageWait(); expect( await getTotalImpressions() ).toBe( TOTAL_IMPRESSIONS_28_DAYS ); } ); - - it( 'loads new data when the date range is changed on the module dashboard page', async () => { - const { last28Days, last14Days } = modulePageRequests; - - mockResponse = last28Days; - await visitAdminPage( - 'admin.php', - 'page=googlesitekit-module-search-console' - ); - - const TOTAL_IMPRESSIONS_28_DAYS = await getTotalImpressions(); - - mockResponse = last14Days; - - await Promise.all( [ - page.waitForResponse( ( res ) => - res.url().match( 'google-site-kit/v1/modules/search-console' ) - ), - switchDateRange( 'last 28 days', 'last 14 days' ), - ] ); - - const TOTAL_IMPRESSIONS_14_DAYS = await getTotalImpressions(); - - expect( TOTAL_IMPRESSIONS_14_DAYS ).not.toBe( - TOTAL_IMPRESSIONS_28_DAYS - ); - // Switching back will not trigger a data request as it has been cached. - await switchDateRange( 'last 14 days', 'last 28 days' ); - // Need to wait for short time for UI to update, however no selectors/requests to listen for. - await pageWait(); - expect( await getTotalImpressions() ).toBe( TOTAL_IMPRESSIONS_28_DAYS ); - } ); } ); diff --git a/tests/phpunit/includes/Core/Modules/Module_With_Screen_ContractTests.php b/tests/phpunit/includes/Core/Modules/Module_With_Screen_ContractTests.php deleted file mode 100644 index 6154e568389..00000000000 --- a/tests/phpunit/includes/Core/Modules/Module_With_Screen_ContractTests.php +++ /dev/null @@ -1,39 +0,0 @@ -get_testcase(); - $module = $this->get_module_with_screen(); - - $screen = $module->get_screen(); - - $testcase->assertInstanceOf( 'Google\Site_Kit\Core\Admin\Screen', $screen ); - $testcase->assertEquals( Screens::PREFIX . 'module-' . $module->slug, $screen->get_slug() ); - } -} diff --git a/tests/phpunit/integration/Core/Modules/ModuleTest.php b/tests/phpunit/integration/Core/Modules/ModuleTest.php index bc802f2e145..0342d49f2ec 100644 --- a/tests/phpunit/integration/Core/Modules/ModuleTest.php +++ b/tests/phpunit/integration/Core/Modules/ModuleTest.php @@ -64,24 +64,6 @@ public function test_magic_methods() { $this->assertNull( $module->non_existent ); } - public function test_prepare_info_for_js() { - $module = new FakeModule( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - $keys = array( - 'slug', - 'name', - 'description', - 'sort', - 'homepage', - 'required', - 'autoActivate', - 'internal', - 'screenID', - 'settings', - ); - - $this->assertEqualSets( $keys, array_keys( $module->prepare_info_for_js() ) ); - } - public function test_is_connected() { $module = new FakeModule( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); diff --git a/tests/phpunit/integration/Core/Permissions/PermissionsTest.php b/tests/phpunit/integration/Core/Permissions/PermissionsTest.php index f9a2dd088f5..5699178a8cb 100644 --- a/tests/phpunit/integration/Core/Permissions/PermissionsTest.php +++ b/tests/phpunit/integration/Core/Permissions/PermissionsTest.php @@ -107,7 +107,6 @@ public function test_check_all_for_current_user__non_admins( $role ) { Permissions::SETUP => false, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => false, Permissions::VIEW_AUTHENTICATED_DASHBOARD => false, @@ -139,7 +138,6 @@ public function test_check_all_for_current_user__unauthenticated_admin() { Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => true, Permissions::VIEW_AUTHENTICATED_DASHBOARD => false, @@ -186,7 +184,6 @@ public function test_check_all_for_current_user__authenticated_admin() { Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => true, Permissions::VIEW_DASHBOARD => true, - Permissions::VIEW_MODULE_DETAILS => true, Permissions::MANAGE_OPTIONS => true, Permissions::VIEW_SPLASH => true, Permissions::VIEW_AUTHENTICATED_DASHBOARD => true, @@ -218,7 +215,6 @@ public function test_check_all_for_current_user__authenticated_admin_with_incomp Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => true, Permissions::VIEW_AUTHENTICATED_DASHBOARD => false, @@ -235,7 +231,6 @@ public function test_get_capabilities() { Permissions::SETUP, Permissions::VIEW_POSTS_INSIGHTS, Permissions::VIEW_DASHBOARD, - Permissions::VIEW_MODULE_DETAILS, Permissions::MANAGE_OPTIONS, Permissions::VIEW_SPLASH, Permissions::VIEW_AUTHENTICATED_DASHBOARD, @@ -252,7 +247,6 @@ public function test_get_capabilities() { Permissions::SETUP, Permissions::VIEW_POSTS_INSIGHTS, Permissions::VIEW_DASHBOARD, - Permissions::VIEW_MODULE_DETAILS, Permissions::MANAGE_OPTIONS, Permissions::VIEW_SPLASH, Permissions::VIEW_SHARED_DASHBOARD, @@ -398,7 +392,6 @@ public function test_check_all_for_current_user__non_admins_dashboard_sharing( $ Permissions::SETUP => false, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => false, Permissions::VIEW_SHARED_DASHBOARD => false, @@ -432,7 +425,6 @@ public function test_check_all_for_current_user__unauthenticated_admin_dashboard Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => true, Permissions::VIEW_SHARED_DASHBOARD => false, @@ -488,7 +480,6 @@ public function test_check_all_for_current_user__authenticated_admin_dashboard_s Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => true, Permissions::VIEW_DASHBOARD => true, - Permissions::VIEW_MODULE_DETAILS => true, Permissions::MANAGE_OPTIONS => true, Permissions::VIEW_SPLASH => true, Permissions::VIEW_SHARED_DASHBOARD => false, @@ -529,7 +520,6 @@ public function test_check_all_for_current_user__authenticated_admin_with_incomp Permissions::SETUP => true, Permissions::VIEW_POSTS_INSIGHTS => false, Permissions::VIEW_DASHBOARD => false, - Permissions::VIEW_MODULE_DETAILS => false, Permissions::MANAGE_OPTIONS => false, Permissions::VIEW_SPLASH => true, Permissions::VIEW_SHARED_DASHBOARD => false, diff --git a/tests/phpunit/integration/Modules/AdSenseTest.php b/tests/phpunit/integration/Modules/AdSenseTest.php index e1ce82282ca..44878d5c852 100644 --- a/tests/phpunit/integration/Modules/AdSenseTest.php +++ b/tests/phpunit/integration/Modules/AdSenseTest.php @@ -14,7 +14,6 @@ use Google\Site_Kit\Core\Modules\Module; use Google\Site_Kit\Core\Modules\Module_With_Owner; use Google\Site_Kit\Core\Modules\Module_With_Scopes; -use Google\Site_Kit\Core\Modules\Module_With_Screen; use Google\Site_Kit\Core\Modules\Module_With_Settings; use Google\Site_Kit\Core\Modules\Module_With_Service_Entity; use Google\Site_Kit\Core\Storage\Options; @@ -26,7 +25,6 @@ use Google\Site_Kit\Modules\AdSense\Settings; use Google\Site_Kit\Tests\Core\Modules\Module_With_Owner_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Scopes_ContractTests; -use Google\Site_Kit\Tests\Core\Modules\Module_With_Screen_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Service_Entity_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Settings_ContractTests; use Google\Site_Kit\Tests\TestCase; @@ -38,7 +36,6 @@ */ class AdSenseTest extends TestCase { use Module_With_Scopes_ContractTests; - use Module_With_Screen_ContractTests; use Module_With_Settings_ContractTests; use Module_With_Owner_ContractTests; use Module_With_Service_Entity_ContractTests; @@ -46,29 +43,12 @@ class AdSenseTest extends TestCase { public function test_register() { $adsense = new AdSense( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); remove_all_filters( 'googlesitekit_auth_scopes' ); - remove_all_filters( 'googlesitekit_module_screens' ); $this->assertEmpty( apply_filters( 'googlesitekit_auth_scopes', array() ) ); - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); $adsense->register(); $this->assertNotEmpty( apply_filters( 'googlesitekit_auth_scopes', array() ) ); - $this->assertContains( $adsense->get_screen(), apply_filters( 'googlesitekit_module_screens', array() ) ); - } - - public function test_register_unified_dashboard() { - $this->enable_feature( 'unifiedDashboard' ); - - $adsense = new AdSense( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - remove_all_filters( 'googlesitekit_module_screens' ); - - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); - - $adsense->register(); - - // Verify the screen is not registered. - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); } public function test_register_template_redirect_amp() { @@ -408,13 +388,6 @@ protected function get_module_with_scopes() { return new AdSense( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); } - /** - * @return Module|Module_With_Screen - */ - protected function get_module_with_screen() { - return new AdSense( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - } - /** * @return Module|Module_With_Settings */ diff --git a/tests/phpunit/integration/Modules/AnalyticsTest.php b/tests/phpunit/integration/Modules/AnalyticsTest.php index 0e097cf6182..777d9a66b94 100644 --- a/tests/phpunit/integration/Modules/AnalyticsTest.php +++ b/tests/phpunit/integration/Modules/AnalyticsTest.php @@ -13,7 +13,6 @@ use Google\Site_Kit\Context; use Google\Site_Kit\Core\Modules\Module_With_Owner; use Google\Site_Kit\Core\Modules\Module_With_Scopes; -use Google\Site_Kit\Core\Modules\Module_With_Screen; use Google\Site_Kit\Core\Modules\Module_With_Settings; use Google\Site_Kit\Core\Modules\Module_With_Service_Entity; use Google\Site_Kit\Core\Permissions\Permissions; @@ -22,7 +21,6 @@ use Google\Site_Kit\Modules\Analytics\Settings; use Google\Site_Kit\Tests\Core\Modules\Module_With_Owner_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Scopes_ContractTests; -use Google\Site_Kit\Tests\Core\Modules\Module_With_Screen_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Service_Entity_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Settings_ContractTests; use Google\Site_Kit\Tests\TestCase; @@ -40,7 +38,6 @@ */ class AnalyticsTest extends TestCase { use Module_With_Scopes_ContractTests; - use Module_With_Screen_ContractTests; use Module_With_Settings_ContractTests; use Module_With_Owner_ContractTests; use Module_With_Service_Entity_ContractTests; @@ -48,7 +45,6 @@ class AnalyticsTest extends TestCase { public function test_register() { $analytics = new Analytics( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); remove_all_filters( 'googlesitekit_auth_scopes' ); - remove_all_filters( 'googlesitekit_module_screens' ); remove_all_filters( 'googlesitekit_analytics_adsense_linked' ); remove_all_actions( 'wp_head' ); remove_all_actions( 'web_stories_story_head' ); @@ -61,12 +57,6 @@ public function test_register() { apply_filters( 'googlesitekit_auth_scopes', array() ) ); - // Test registers screen. - $this->assertContains( - $analytics->get_screen(), - apply_filters( 'googlesitekit_module_screens', array() ) - ); - $this->assertFalse( get_option( 'googlesitekit_analytics_adsense_linked' ) ); $this->assertFalse( $analytics->is_connected() ); @@ -75,20 +65,6 @@ public function test_register() { $this->assertTrue( has_action( 'web_stories_story_head' ) ); } - public function test_register_unified_dashboard() { - $this->enable_feature( 'unifiedDashboard' ); - - $analytics = new Analytics( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - remove_all_filters( 'googlesitekit_module_screens' ); - - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); - - $analytics->register(); - - // Verify the screen is not registered. - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); - } - public function test_register_template_redirect_amp() { $context = $this->get_amp_primary_context(); $analytics = new Analytics( $context ); @@ -603,13 +579,6 @@ protected function get_module_with_scopes() { return new Analytics( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); } - /** - * @return Module_With_Screen - */ - protected function get_module_with_screen() { - return new Analytics( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - } - /** * @return Module_With_Settings */ diff --git a/tests/phpunit/integration/Modules/Search_ConsoleTest.php b/tests/phpunit/integration/Modules/Search_ConsoleTest.php index 00d9fe75cf3..e679d4e6b58 100644 --- a/tests/phpunit/integration/Modules/Search_ConsoleTest.php +++ b/tests/phpunit/integration/Modules/Search_ConsoleTest.php @@ -12,13 +12,11 @@ use Google\Site_Kit\Context; use Google\Site_Kit\Core\Modules\Module_With_Scopes; -use Google\Site_Kit\Core\Modules\Module_With_Screen; use Google\Site_Kit\Core\Modules\Module_With_Settings; use Google\Site_Kit\Core\Modules\Module_With_Service_Entity; use Google\Site_Kit\Core\Storage\Options; use Google\Site_Kit\Modules\Search_Console; use Google\Site_Kit\Tests\Core\Modules\Module_With_Scopes_ContractTests; -use Google\Site_Kit\Tests\Core\Modules\Module_With_Screen_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Settings_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Owner_ContractTests; use Google\Site_Kit\Tests\Core\Modules\Module_With_Service_Entity_ContractTests; @@ -29,7 +27,6 @@ */ class Search_ConsoleTest extends TestCase { use Module_With_Scopes_ContractTests; - use Module_With_Screen_ContractTests; use Module_With_Settings_ContractTests; use Module_With_Owner_ContractTests; use Module_With_Service_Entity_ContractTests; @@ -47,11 +44,9 @@ public function test_register() { $property_url = 'https://example.com'; remove_all_filters( 'googlesitekit_auth_scopes' ); - remove_all_filters( 'googlesitekit_module_screens' ); remove_all_filters( 'googlesitekit_setup_complete' ); $this->assertEmpty( apply_filters( 'googlesitekit_auth_scopes', array() ) ); - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); $this->assertTrue( apply_filters( 'googlesitekit_setup_complete', true ) ); // Register search console. @@ -63,12 +58,6 @@ public function test_register() { apply_filters( 'googlesitekit_auth_scopes', array() ) ); - // Test registers screen. - $this->assertContains( - $search_console->get_screen(), - apply_filters( 'googlesitekit_module_screens', array() ) - ); - // Test sitekit setup complete requires property set. $this->assertFalse( apply_filters( 'googlesitekit_setup_complete', true ) ); $options = new Options( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); @@ -76,21 +65,6 @@ public function test_register() { $this->assertTrue( apply_filters( 'googlesitekit_setup_complete', true ) ); } - public function test_register_unified_dashboard() { - $this->enable_feature( 'unifiedDashboard' ); - - $search_console = new Search_Console( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - remove_all_filters( 'googlesitekit_module_screens' ); - - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); - - $search_console->register(); - - // Verify the screen is not registered. - $this->assertEmpty( apply_filters( 'googlesitekit_module_screens', array() ) ); - } - - public function test_get_datapoints() { $search_console = new Search_Console( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); @@ -123,13 +97,6 @@ protected function get_module_with_scopes() { return new Search_Console( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); } - /** - * @return Module_With_Screen - */ - protected function get_module_with_screen() { - return new Search_Console( new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ) ); - } - /** * @return Module_With_Settings */ diff --git a/webpack.config.js b/webpack.config.js index 4b0c6af0106..40c513ceea8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -302,7 +302,6 @@ function* webpackConfig( env, argv ) { 'googlesitekit-wp-dashboard': './assets/js/googlesitekit-wp-dashboard.js', 'googlesitekit-base': './assets/js/googlesitekit-base.js', - 'googlesitekit-module': './assets/js/googlesitekit-module.js', }, externals, output: {