Skip to content

Commit

Permalink
Plugins: Add Action Links to Plugin Detail View (#11718)
Browse files Browse the repository at this point in the history
* Adds plugin ‘action links’ buttons to the plugin detail view.

Fixes #82

* Add rel attribute for external link.
  • Loading branch information
roundhill authored Mar 10, 2017
1 parent eab8482 commit e0cce68
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/lib/plugins/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function filterNoticesBy( site, pluginSlug, log ) {
PluginUtils = {
whiteListPluginData: function( plugin ) {
return pick( plugin,
'action_links',
'active',
'author',
'author_url',
Expand Down
14 changes: 14 additions & 0 deletions client/my-sites/plugins/plugin-meta/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import i18n from 'i18n-calypso';
import some from 'lodash/some';
import get from 'lodash/get';
import { includes } from 'lodash';
import { isEmpty } from 'lodash';
import Gridicon from 'gridicons';

/**
Expand Down Expand Up @@ -330,6 +331,7 @@ const PluginMeta = React.createClass( {
} );

const plugin = this.props.selectedSite && this.props.sites[ 0 ] ? this.props.sites[ 0 ].plugin : this.props.plugin;
const actionLinks = get( plugin, 'action_links' );

return (
<div className="plugin-meta">
Expand All @@ -345,6 +347,18 @@ const PluginMeta = React.createClass( {
<div className="plugin-meta__meta">
{ this.renderAuthorUrl() }
</div>
{ ! isEmpty( actionLinks ) &&
<div className="plugin-meta__action-links">
{ Object.keys( actionLinks ).map( linkTitle => (
<Button compact icon
href={ actionLinks[ linkTitle ] }
target="_blank"
rel="noopener noreferrer">
{ linkTitle } <Gridicon icon="external" />
</Button>
) ) }
</div>
}
</div>
{ this.renderActions() }
</div>
Expand Down
16 changes: 15 additions & 1 deletion client/my-sites/plugins/plugin-meta/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@
}

@include breakpoint( '>480px' ) {
min-width: 22%;
border: none;
margin: 0;
padding: 0;
text-align: right;
justify-content: flex-end;
align-self: center;
align-self: flex-start;

.plugin-action {
margin-top: 16px;
Expand Down Expand Up @@ -149,6 +150,19 @@
color: $alert-green;
}

.plugin-meta__action-links {
display: flex;
flex-wrap: wrap;
clear: both;
padding-top: 12px;

.button {
margin-top: 12px;
flex-shrink: 0;
margin-right: 10px;
}
}

a.plugin-meta__settings-link {
color: $gray;
display: block;
Expand Down

0 comments on commit e0cce68

Please sign in to comment.