Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getRedirectUrl } from '@automattic/jetpack-components';
import { __, _x } from '@wordpress/i18n';
import { _x } from '@wordpress/i18n';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { Component } from 'react';
Expand All @@ -8,13 +7,12 @@ import Button from 'components/button';
import Card from 'components/card';
import { withModuleSettingsFormHelpers } from 'components/module-settings/with-module-settings-form-helpers';
import { ModuleToggle } from 'components/module-toggle';
import SimpleNotice from 'components/notice';
import SectionHeader from 'components/section-header';
import SupportInfo from 'components/support-info';
import analytics from 'lib/analytics';
import ProStatus from 'pro-status';
import { isOfflineMode } from 'state/connection';
import { getSiteRawUrl, getSiteAdminUrl, userCanManageModules } from 'state/initial-state';
import { getSiteAdminUrl, userCanManageModules } from 'state/initial-state';
import { getModule as _getModule } from 'state/modules';

export class DashItem extends Component {
Expand Down Expand Up @@ -79,9 +77,7 @@ export class DashItem extends Component {
'videopress',
].includes( this.props.module ) &&
this.props.isOfflineMode ) ||
this.props.noToggle ||
// Avoid toggle for manage as it's no longer a module
'manage' === this.props.module ? (
this.props.noToggle ? (
''
) : (
<ModuleToggle
Expand All @@ -93,29 +89,6 @@ export class DashItem extends Component {
/>
);

if ( 'manage' === this.props.module ) {
if ( 'is-warning' === this.props.status ) {
toggle = (
<a
href={
this.props.isOfflineMode
? this.props.siteAdminUrl + 'update-core.php'
: getRedirectUrl( 'calypso-plugins-manage', { site: this.props.siteRawUrl } )
}
>
<SimpleNotice showDismiss={ false } status={ this.props.status } isCompact={ true }>
{ _x( 'Updates needed', 'Short warning message', 'jetpack' ) }
</SimpleNotice>
</a>
);
}
if ( 'is-working' === this.props.status ) {
toggle = (
<span className="jp-dash-item__active-label">{ __( 'Active', 'jetpack' ) }</span>
);
}
}

if ( 'rewind' === this.props.module ) {
toggle = null;
}
Expand Down Expand Up @@ -170,7 +143,6 @@ export default connect( state => {
getModule: module_name => _getModule( state, module_name ),
isOfflineMode: isOfflineMode( state ),
userCanToggle: userCanManageModules( state ),
siteRawUrl: getSiteRawUrl( state ),
siteAdminUrl: getSiteAdminUrl( state ),
};
} )( withModuleSettingsFormHelpers( DashItem ) );
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@use "sass:color";
@use "../../scss/functions/rem";
@use "../../scss/calypso-colors";
@use "../../scss/mixins/ui";
Expand Down Expand Up @@ -136,15 +135,6 @@
}
}

.jp-dash-item__active-label {
display: inline-block;
color: color.adjust(colors.$gray, $lightness: -10%);
color: colors.$gray;
font-size: rem.convert(12px);
font-weight: 400;
text-transform: uppercase;
}

// conditional styles for content when items are inactive
.jp-dash-item__is-inactive {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe( 'DashItem', () => {
href: getRedirectUrl( 'jetpack' ),
userCanToggle: true,
siteAdminUrl: 'https://example.org/wp-admin/',
siteRawUrl: 'example.org',
getOptionValue: () => true,
isUpdating: () => false,
};
Expand Down Expand Up @@ -171,50 +170,6 @@ describe( 'DashItem', () => {
} );
} );

describe( 'if this is the DashItem for Manage module', () => {
const manageProps = {
label: 'Manage',
module: 'manage',
status: 'is-warning',
pro: false,
isOfflineMode: false,
userCanToggle: true,
siteAdminUrl: 'https://example.org/wp-admin/',
siteRawUrl: 'example.org',
getOptionValue: () => true,
isUpdating: () => false,
};

it( "shows a warning badge when status is 'is-warning'", () => {
const { container } = render( <DashItem { ...manageProps } />, {
initialState: buildInitialState(),
} );
// eslint-disable-next-line testing-library/no-container
expect( container.querySelector( '.dops-notice.is-warning' ) ).toBeInTheDocument();
} );

it( 'when it is activated, the warning badge is linked to Plugins screen in WordPress.com', () => {
const { container } = render( <DashItem { ...manageProps } />, {
initialState: buildInitialState(),
} );
// eslint-disable-next-line testing-library/no-container
const node = container.querySelector( '.dops-notice.is-warning' ).closest( 'a' );
expect( node ).toBeInTheDocument();
expect( node ).toHaveAttribute(
'href',
getRedirectUrl( 'calypso-plugins-manage', { site: manageProps.siteRawUrl } )
);
} );

it( "when status is 'is-working', the warning badge has an 'active' label", () => {
const { container } = render( <DashItem { ...manageProps } status="is-working" />, {
initialState: buildInitialState(),
} );
// eslint-disable-next-line testing-library/no-container
expect( container.querySelector( '.jp-dash-item__active-label' ) ).toBeInTheDocument();
} );
} );

describe( 'if this is the DashItem for Monitor module', () => {
const monitorProps = {
module: 'monitor',
Expand All @@ -224,7 +179,6 @@ describe( 'DashItem', () => {
isOfflineMode: false,
userCanToggle: true,
siteAdminUrl: 'https://example.org/wp-admin/',
siteRawUrl: 'example.org',
getOptionValue: () => true,
isUpdating: () => false,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Removes unreachable code; no user-facing change.


Loading