Skip to content

Commit

Permalink
Simple Payments: restrict image sources available in Media Library (A…
Browse files Browse the repository at this point in the history
…utomattic#24797)

This temoporarily removes Google Photos and Free Photo Library as
options from Simple Payments Media Library selection.
  • Loading branch information
vindl authored May 10, 2018
1 parent e45843d commit 1d0f682
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/components/dialog/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}

.dialog__backdrop.is-hidden {
background-color: rgba( white, 0 );
background-color: transparent;
}

.dialog.card {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ProductImagePicker extends Component {
role="button"
tabIndex={ 0 }
>
<ProductImage siteId={ siteId } imageId={ this.props.input.value } showEditIcon={ true } />
<ProductImage siteId={ siteId } imageId={ this.props.input.value } showEditIcon />
<RemoveButton onRemove={ this.removeCurrentImage } />
</div>
);
Expand All @@ -114,6 +114,7 @@ class ProductImagePicker extends Component {
enabledFilters={ [ 'images' ] }
visible={ isSelecting }
isBackdropVisible={ false }
disabledDataSources={ [ 'pexels', 'google_photos' ] }
labels={ {
confirm: translate( 'Add' ),
} }
Expand Down
10 changes: 8 additions & 2 deletions client/my-sites/media-library/filter-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React, { Component } from 'react';
import { localize } from 'i18n-calypso';
import { identity, includes, noop, pull } from 'lodash';
import { identity, includes, noop, pull, union } from 'lodash';
import PropTypes from 'prop-types';

/**
Expand Down Expand Up @@ -40,6 +40,7 @@ export class MediaLibraryFilterBar extends Component {
post: PropTypes.bool,
isConnected: PropTypes.bool,
disableLargeImageSources: PropTypes.bool,
disabledDataSources: PropTypes.arrayOf( PropTypes.string ),
};

static defaultProps = {
Expand All @@ -53,6 +54,7 @@ export class MediaLibraryFilterBar extends Component {
post: false,
isConnected: true,
disableLargeImageSources: false,
disabledDataSources: [],
};

getSearchPlaceholderText() {
Expand Down Expand Up @@ -175,13 +177,17 @@ export class MediaLibraryFilterBar extends Component {
}

render() {
const disabledSources = this.props.disableLargeImageSources
? union( this.props.disabledDataSources, largeImageSources )
: this.props.disabledDataSources;

// Dropdown is disabled when viewing any external data source
return (
<div className="media-library__filter-bar">
<DataSource
source={ this.props.source }
onSourceChange={ this.props.onSourceChange }
disabledSources={ this.props.disableLargeImageSources ? largeImageSources : [] }
disabledSources={ disabledSources }
/>

<SectionNav
Expand Down
3 changes: 3 additions & 0 deletions client/my-sites/media-library/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MediaLibrary extends Component {
scrollable: PropTypes.bool,
postId: PropTypes.number,
disableLargeImageSources: PropTypes.bool,
disabledDataSources: PropTypes.arrayOf( PropTypes.string ),
};

static defaultProps = {
Expand All @@ -72,6 +73,7 @@ class MediaLibrary extends Component {
scrollable: false,
source: '',
disableLargeImageSources: false,
disabledDataSources: [],
};

componentWillMount() {
Expand Down Expand Up @@ -209,6 +211,7 @@ class MediaLibrary extends Component {
isConnected={ isConnected( this.props ) }
post={ !! this.props.postId }
disableLargeImageSources={ this.props.disableLargeImageSources }
disabledDataSources={ this.props.disabledDataSources }
/>
{ content }
</div>
Expand Down
3 changes: 3 additions & 0 deletions client/post-editor/media-modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class EditorMediaModal extends Component {
resetView: PropTypes.func,
postId: PropTypes.number,
disableLargeImageSources: PropTypes.bool,
disabledDataSources: PropTypes.arrayOf( PropTypes.string ),
};

static defaultProps = {
Expand All @@ -98,6 +99,7 @@ export class EditorMediaModal extends Component {
imageEditorProps: {},
deleteMedia: () => {},
disableLargeImageSources: false,
disabledDataSources: [],
};

constructor( props ) {
Expand Down Expand Up @@ -610,6 +612,7 @@ export class EditorMediaModal extends Component {
mediaLibrarySelectedItems={ this.props.mediaLibrarySelectedItems }
postId={ this.props.postId }
disableLargeImageSources={ this.props.disableLargeImageSources }
disabledDataSources={ this.props.disabledDataSources }
scrollable
/>
);
Expand Down

0 comments on commit 1d0f682

Please sign in to comment.