Skip to content

Commit

Permalink
Settings: highlight credentials settings section when redirected from…
Browse files Browse the repository at this point in the history
… the site activity (#40018)

* Adds contextual popover menu item to add site credentials

* Update copy with the latest suggestions

* Adds tracking to new option

* Adds `is-highlighted` class if hash is "credentials”

* Adds hash “credentials” to links

* Adds highlight style

* Increase highlight around the section wrapper

* Fix the output of the function to always return a boolean

Co-Authored-By: Enej Bajgoric <enej.bajgoric@gmail.com>

* Return false as default as well

Co-Authored-By: Enej Bajgoric <enej.bajgoric@gmail.com>
  • Loading branch information
keoshi and enejb committed Mar 12, 2020
1 parent 4db7706 commit 815dc5f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
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
2 changes: 1 addition & 1 deletion client/my-sites/activity/activity-log-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class ActivityLogItem extends Component {
href={
canAutoconfigure
? `/start/rewind-auto-config/?blogid=${ siteId }&siteSlug=${ siteSlug }`
: `/settings/security/${ siteSlug }`
: `/settings/security/${ siteSlug }#credentials`
}
onClick={ trackAddCreds }
>
Expand Down
19 changes: 18 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,29 @@ import RewindCredentialsForm from 'components/rewind-credentials-form';
import './style.scss';

class JetpackCredentials extends Component {
isSectionHighlighted() {
if ( ! window.location.hash ) {
return false;
}

const hash = window.location.hash.substring( 1 );
if ( 'credentials' === hash ) {
return true;
}
return false;
}

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
8 changes: 8 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,13 @@
.jetpack-credentials {
margin-bottom: 15px;

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

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

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

0 comments on commit 815dc5f

Please sign in to comment.