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

Settings: highlight credentials settings section when redirected from the site activity #40018

Merged
merged 10 commits into from
Mar 12, 2020
2 changes: 1 addition & 1 deletion client/blocks/jetpack-backup-creds-banner/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class JetpackBackupCredsBanner extends Component {
href={
rewindState.canAutoconfigure
? `/start/rewind-auto-config/?blogid=${ siteId }&siteSlug=${ siteSlug }`
: `/settings/security/${ siteSlug }`
: `/settings/security/${ siteSlug }#credentials`
}
title={ translate( 'Add your server credentials' ) }
description={ translate(
Expand Down
21 changes: 20 additions & 1 deletion client/my-sites/activity/activity-log-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,15 @@ class ActivityLogItem extends Component {

renderRewindAction() {
const {
activity,
canAutoconfigure,
createBackup,
createRewind,
disableRestore,
disableBackup,
activity,
siteId,
siteSlug,
trackAddCreds,
translate,
} = this.props;

Expand All @@ -255,6 +259,20 @@ class ActivityLogItem extends Component {
{ translate( 'Restore to this point' ) }
</PopoverMenuItem>

{ disableRestore && (
<PopoverMenuItem
icon="plus"
href={
canAutoconfigure
? `/start/rewind-auto-config/?blogid=${ siteId }&siteSlug=${ siteSlug }`
: `/settings/security/${ siteSlug }#credentials`
}
onClick={ trackAddCreds }
>
{ translate( 'Add server credentials to enable restoring' ) }
</PopoverMenuItem>
) }

<PopoverMenuSeparator />

<PopoverMenuItem
Expand Down Expand Up @@ -471,6 +489,7 @@ const mapDispatchToProps = ( dispatch, { activity: { activityId }, siteId } ) =>
dispatch(
recordTracksEvent( 'calypso_activitylog_event_get_help', { activity_name: activityName } )
),
trackAddCreds: () => dispatch( recordTracksEvent( 'calypso_activitylog_event_add_credentials' ) ),
trackFixCreds: () => dispatch( recordTracksEvent( 'calypso_activitylog_event_fix_credentials' ) ),
} );

Expand Down
18 changes: 17 additions & 1 deletion client/my-sites/site-settings/jetpack-credentials/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { Component } from 'react';
import { localize } from 'i18n-calypso';
import { connect } from 'react-redux';
import { some } from 'lodash';
import classNames from 'classnames';

/**
* Internal dependencies
Expand All @@ -25,13 +26,28 @@ import RewindCredentialsForm from 'components/rewind-credentials-form';
import './style.scss';

class JetpackCredentials extends Component {
isSectionHighlighted() {
if ( ! window.location.hash ) {
return null;
keoshi marked this conversation as resolved.
Show resolved Hide resolved
}

const hash = window.location.hash.substring( 1 );
if ( 'credentials' === hash ) {
return true;
}
keoshi marked this conversation as resolved.
Show resolved Hide resolved
}

render() {
const { credentials, rewindState, siteId, translate, siteSlug } = this.props;
const classes = classNames(
'jetpack-credentials',
this.isSectionHighlighted() && 'is-highlighted'
);
const hasAuthorized = rewindState === 'provisioning' || rewindState === 'active';
const hasCredentials = some( credentials, { role: 'main' } );

return (
<div className="jetpack-credentials">
<div className={ classes }>
<QueryRewindState siteId={ siteId } />
<SettingsSectionHeader title={ translate( 'Backups and security scans' ) }>
{ hasAuthorized && (
Expand Down
4 changes: 4 additions & 0 deletions client/my-sites/site-settings/jetpack-credentials/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.jetpack-credentials {
margin-bottom: 15px;

&.is-highlighted .card {
box-shadow: 0 0 0 1px var( --color-accent );
}
}

.jetpack-credentials .foldable-card.card.is-expanded {
Expand Down