Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unifiedDashboard feature flag. #5227

Merged
merged 23 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions .storybook/storybook-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
21 changes: 1 addition & 20 deletions assets/js/components/DashboardEntryPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ModuleSetup moduleSlug={ setupModuleSlug } />;
}

if ( unifiedDashboardEnabled ) {
return <DashboardMainApp />;
}

return (
<Fragment>
<NotificationCounter />
<DashboardApp />
</Fragment>
);
return <DashboardMainApp />;
}

DashboardEntryPoint.propTypes = {
Expand Down
25 changes: 2 additions & 23 deletions assets/js/components/DashboardEntryPoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
);
Expand All @@ -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(
<DashboardEntryPoint />,
unifiedDashboardRenderOptions
);
expect( container ).toMatchSnapshot();
} );

it( 'should render the module setup component when unified dashboard is enabled and passed the setupModuleSlug prop', () => {
const { container } = render(
<DashboardEntryPoint setupModuleSlug="analytics" />,
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( <DashboardEntryPoint /> );
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(
<DashboardEntryPoint setupModuleSlug="analytics" />
);
Expand Down
8 changes: 1 addition & 7 deletions assets/js/components/DateRangeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 }
Expand Down
5 changes: 2 additions & 3 deletions assets/js/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -65,7 +64,7 @@ const Header = ( { children, subHeader, showNavigation } ) => {
<header
className={ classnames( 'googlesitekit-header', {
'googlesitekit-header--has-subheader': hasSubheader,
'googlesitekit-header--has-unified-dashboard': unifiedDashboardEnabled,
'googlesitekit-header--has-navigation': showNavigation,
} ) }
>
<Grid>
Expand Down Expand Up @@ -106,7 +105,7 @@ const Header = ( { children, subHeader, showNavigation } ) => {

{ showNavigation && <DashboardNavigation /> }

{ unifiedDashboardEnabled && <EntityHeader /> }
<EntityHeader />

<ErrorNotifications />

Expand Down
11 changes: 2 additions & 9 deletions assets/js/components/PostSearcherAutoSuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
);
Expand Down Expand Up @@ -226,10 +223,6 @@ export default function PostSearcherAutoSuggest( {
break;
}

if ( ! unifiedDashboardEnabled ) {
return;
}

switch ( e.keyCode ) {
case ESCAPE:
return onClose();
Expand All @@ -239,7 +232,7 @@ export default function PostSearcherAutoSuggest( {
break;
}
},
[ onClose, onSelectCallback, searchTerm, unifiedDashboardEnabled ]
[ onClose, onSelectCallback, searchTerm ]
);

return (
Expand All @@ -262,7 +255,7 @@ export default function PostSearcherAutoSuggest( {
autoFocus={ autoFocus }
/>

{ ( ! unifiedDashboardEnabled || ! isLoading ) &&
{ ! isLoading &&
showDropdown &&
debouncedValue !== currentEntityTitle &&
debouncedValue !== '' &&
Expand Down
26 changes: 5 additions & 21 deletions assets/js/components/UserMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/**
* External dependencies
*/
import classnames from 'classnames';
import { useClickAway } from 'react-use';

/**
Expand All @@ -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';
Expand All @@ -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()
);
Expand Down Expand Up @@ -152,7 +149,7 @@ export default function UserMenu() {
navigateTo( postDisconnectURL );
}, [ postDisconnectURL, navigateTo, viewContext ] );

if ( ! unifiedDashboardEnabled && ! userEmail ) {
if ( ! userEmail ) {
return null;
}

Expand All @@ -163,25 +160,13 @@ export default function UserMenu() {
className="googlesitekit-user-selector googlesitekit-dropdown-menu googlesitekit-dropdown-menu__icon-menu mdc-menu-surface--anchor"
>
<Button
className={ classnames(
'googlesitekit-header__dropdown',
'mdc-button--dropdown',
// Adds circle background to the non-unified dashboard tablet + mobile view
'googlesitekit-border-radius-round--tablet',
'googlesitekit-border-radius-round--phone',
{
'googlesitekit-border-radius-round': unifiedDashboardEnabled,
'googlesitekit-button-icon': unifiedDashboardEnabled,
}
) }
className="googlesitekit-header__dropdown mdc-button--dropdown googlesitekit-border-radius-round--tablet googlesitekit-border-radius-round--phone googlesitekit-border-radius-round googlesitekit-button-icon"
text
onClick={ handleMenu }
icon={
!! userPicture && (
<i
className={ classnames( 'mdc-button__icon', {
'mdc-button__account': unifiedDashboardEnabled,
} ) }
className="mdc-button__icon mdc-button__account"
aria-hidden="true"
>
<img
Expand All @@ -200,9 +185,8 @@ export default function UserMenu() {
aria-controls="user-menu"
aria-label={ __( 'Account', 'google-site-kit' ) }
tooltip
>
{ unifiedDashboardEnabled ? undefined : userEmail }
</Button>
/>

<Menu
className="googlesitekit-width-auto"
menuOpen={ menuOpen }
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/UserMenu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe( 'UserMenu', () => {
container = render( <UserMenu />, { registry } ).container;
fireEvent.click(
container.querySelector(
'.googlesitekit-header__dropdown span'
'.googlesitekit-user-selector .googlesitekit-header__dropdown'
)
);
menu = container.querySelector( '#user-menu' );
Expand Down
Original file line number Diff line number Diff line change
@@ -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`] = `
<div>
<div>
ModuleSetup
Expand All @@ -9,29 +9,7 @@ exports[`DashboardEntryPoint should render the module setup component when unifi
</div>
`;

exports[`DashboardEntryPoint should render the module setup component when unified dashboard is not enabled and passed the setupModuleSlug prop 1`] = `
<div>
<div>
ModuleSetup
{"moduleSlug":"analytics"}
</div>
</div>
`;

exports[`DashboardEntryPoint should render the non-unified dashboard when unified dashboard is not enabled 1`] = `
<div>
<div>
NotificationCounter
{}
</div>
<div>
DashboardApp
{}
</div>
</div>
`;

exports[`DashboardEntryPoint should render the unified dashboard when unified dashboard is enabled 1`] = `
exports[`DashboardEntryPoint should render the unified dashboard 1`] = `
<div>
<div>
DashboardMainApp
Expand Down
Loading