Skip to content

Commit

Permalink
Fix lint errors for blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ajitbohra committed Aug 2, 2018
1 parent 681e162 commit 7285673
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"wpApiSettings": true,
"window": true,
"document": true,
"give_blocks_vars": true
"giveApiSettings": true
},
"plugins": ["react"],
"settings": {
Expand Down
13 changes: 6 additions & 7 deletions blocks/components/blank-slate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ const GiveBlankSlate = ( props ) => {
helpLink,
} = props;


// @todo: do not hard code wp content url that can be configure.
const giveLogo = '/wp-content/plugins/Give/assets/dist/images/give-icon-full-circle.svg';

const block_loading = (
const blockLoading = (
<PlaceholderContainerAnimation />
);

const block_loaded = (
const blockLoaded = (
<div className="block-loaded">
{ !! title && ( <h2 className="give-blank-slate__heading">{ title }</h2> ) }
{ !! description && ( <p className="give-blank-slate__message">{ description }</p> ) }
Expand All @@ -40,11 +39,11 @@ const GiveBlankSlate = ( props ) => {
return (
<div className="give-blank-slate">
{ ! noIcon && (
<img className="give-blank-slate__image"
src={ `${ wpApiSettings.schema.url }${ giveLogo }` }
alt={ __( 'Give Icon' ) } />
<img className="give-blank-slate__image"
src={ `${ wpApiSettings.schema.url }${ giveLogo }` }
alt={ __( 'Give Icon' ) } />
) }
{ !! isLoader ? block_loading : block_loaded }
{ !! isLoader ? blockLoading : blockLoaded }
</div>
);
};
Expand Down
8 changes: 2 additions & 6 deletions blocks/components/container-placeholder-animation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const PlaceholderContainerAnimation = () => {
</div>
<div className="layer-gap small"></div>


<div className="layer h2 layer-5">
<div className="layer-item"></div>
<div className="layer-item opaque"></div>
Expand All @@ -26,14 +25,12 @@ const PlaceholderContainerAnimation = () => {
</div>
<div className="layer-gap medium"></div>


<div className="layer label layer-6">
<div className="layer-item"></div>
<div className="layer-item opaque"></div>
</div>
<div className="layer-gap small"></div>


<div className="layer h2 layer-7">
<div className="layer-item"></div>
<div className="layer-item opaque"></div>
Expand All @@ -42,17 +39,16 @@ const PlaceholderContainerAnimation = () => {
<div className="layer-gap medium"></div>
<div className="layer-gap medium"></div>


<div className="layer h1 layer-8">
<div className="layer-item opaque"></div>
<div className="layer-item"></div>
<div className="layer-item opaque"></div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
};

export default PlaceholderContainerAnimation;
34 changes: 17 additions & 17 deletions blocks/components/edit-form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ import GiveBlankSlate from '../blank-slate/index';
/**
* Internal dependencies
*/
const {__} = wp.i18n;
const {Button} = wp.components;
const {Component} = wp.element;
const { __ } = wp.i18n;
const { Button } = wp.components;
const { Component } = wp.element;

/**
* Render No forms Found UI
*/

class EditForm extends Component {
constructor(props){
super(props);
constructor( props ) {
super( props );

this.changeForm = this.changeForm.bind(this);
this.changeForm = this.changeForm.bind( this );
}

changeForm() {
this.props.setAttributes({prevId: this.props.attributes.id});
this.props.setAttributes({id: 0});
this.props.setAttributes( { prevId: this.props.attributes.id } );
this.props.setAttributes( { id: 0 } );
}

render() {
return (
<GiveBlankSlate title={__('Edit Form.')}
description={__('You can not see donation form preview because there is something went wrong with donation form settings.')}>
<GiveBlankSlate title={ __( 'Edit Form.' ) }
description={ __( 'You can not see donation form preview because there is something went wrong with donation form settings.' ) }>
<Button isPrimary
isLarge
target="_blank"
href={`${ wpApiSettings.schema.url }/wp-admin/post.php?post=${this.props.formId}&action=edit`}>
{__('Edit Donation Form')}
isLarge
target="_blank"
href={ `${ wpApiSettings.schema.url }/wp-admin/post.php?post=${ this.props.formId }&action=edit` }>
{ __( 'Edit Donation Form' ) }
</Button>
&nbsp;&nbsp;
<Button isLarge
onClick={this.changeForm}>
{__('Change Form')}
onClick={ this.changeForm }>
{ __( 'Change Form' ) }
</Button>
</GiveBlankSlate>
);
}
};
}

export default EditForm;
40 changes: 20 additions & 20 deletions blocks/components/form-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ import isUndefined from 'lodash.isundefined';
/**
* Internal dependencies
*/
const {__} = wp.i18n;
const {SelectControl, Button} = wp.components;
const giveFormOptionsDefault = { value: '0', label: __( '-- Select Form --' ) };
const { __ } = wp.i18n;
const { SelectControl, Button } = wp.components;
const giveFormOptionsDefault = { value: '0', label: __( '-- Select Form --' ) };

/**
* Render form select UI
*/

const FormSelect = (props) => {
const FormSelect = ( props ) => {
// Event(s)
const getFormOptions = () => {
// Add API Data To Select Options

let formOptions = [];

if( ! isUndefined( props.forms.data ) ) {
if ( ! isUndefined( props.forms.data ) ) {
formOptions = props.forms.data.map(
(form) => {
( form ) => {
return {
value: form.id,
label: form.title.rendered === '' ? `${ form.id } : ${__( 'No form title' ) }` : form.title.rendered,
label: form.title.rendered === '' ? `${ form.id } : ${ __( 'No form title' ) }` : form.title.rendered,
};
}
);
Expand All @@ -39,34 +39,34 @@ const FormSelect = (props) => {
};

const setFormIdTo = id => {
props.setAttributes( {id} );
props.setAttributes( { id } );
};

const resetFormIdTo = () => {
props.setAttributes( {id: props.attributes.prevId} );
props.setAttributes( {prevId: 0} );
props.setAttributes( { id: props.attributes.prevId } );
props.setAttributes( { prevId: 0 } );
};

return (
<GiveBlankSlate title = {__( 'Give Donation form' )}>
<GiveBlankSlate title={ __( 'Give Donation form' ) }>
<SelectControl
options = {getFormOptions()}
onChange = {setFormIdTo}
options={ getFormOptions() }
onChange={ setFormIdTo }
/>

<Button isPrimary
isLarge href = {`${ wpApiSettings.schema.url }/wp-admin/post-new.php?post_type=give_forms`}>
{__( 'Add New Form' )}
</ Button>&nbsp;&nbsp;
isLarge href={ `${ wpApiSettings.schema.url }/wp-admin/post-new.php?post_type=give_forms` }>
{ __( 'Add New Form' ) }
</Button>&nbsp;&nbsp;

{
props.attributes.prevId &&
<Button isLarge
onClick = {resetFormIdTo}>
{__( 'Cancel' )}
</ Button>
onClick={ resetFormIdTo }>
{ __( 'Cancel' ) }
</Button>
}
</ GiveBlankSlate>
</GiveBlankSlate>
);
};

Expand Down
25 changes: 12 additions & 13 deletions blocks/components/select-control/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
/**
* Internal dependencies
*/
const {BaseControl} = wp.components,
{withInstanceId} = wp.compose,
{Component} = wp.element,
{isEmpty} = _;
const { BaseControl } = wp.components,
{ withInstanceId } = wp.compose,
{ Component } = wp.element,
{ isEmpty } = _;

class GiveSelectControl extends Component{
constructor(props){
super(props);
class GiveSelectControl extends Component {
constructor( props ) {
super( props );

this.onChangeHandler = this.onChangeHandler.bind( this );
}

onChangeHandler(event){
onChangeHandler( event ) {
if ( this.props.onChange ) {
this.props.onChange(event);
this.props.onChange( event );
}
}


// Disable reason: A select with an onchange throws a warning

render(){
const {label, help, instanceId, options = [], name, ...props } = this.props;
render() {
const { label, help, instanceId, options = [], name, ...props } = this.props;
const id = `give-inspector-select-control-${ instanceId }`;

/* eslint-disable jsx-a11y/no-onchange */
Expand All @@ -35,7 +34,7 @@ class GiveSelectControl extends Component{
className="blocks-select-control__input"
onChange={ this.onChangeHandler }
aria-describedby={ !! help ? id + '__help' : undefined }
{...props}
{ ...props }
>
{ options.map( ( option ) =>
<option
Expand Down
36 changes: 18 additions & 18 deletions blocks/components/text-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@
* Internal dependencies
*/

const {Component} = wp.element,
{BaseControl} = wp.components,
{withInstanceId} = wp.compose;
const { Component } = wp.element,
{ BaseControl } = wp.components,
{ withInstanceId } = wp.compose;

class GiveTextControl extends Component {
constructor(props){
constructor( props ) {
super( ...props );

this.onChangeHandler = this.onChangeHandler.bind( this );
}

onChangeHandler(event){
onChangeHandler( event ) {
if ( this.props.onChange ) {
this.props.onChange(event);
this.props.onChange( event );
}
}

onBlurHandler(event){
onBlurHandler( event ) {
if ( this.props.onBlur ) {
this.props.onBlur(event);
this.props.onBlur( event );
}
}

render(){
render() {
const { label, name, value, help, instanceId, type = 'text', ...props } = this.props,
id = `inspector-text-control-${ instanceId }`;
id = `inspector-text-control-${ instanceId }`;

return (
<BaseControl label={ label } id={ id } help={ help }>
<input className="blocks-text-control__input"
type={ type }
name={ name }
id={ id }
value={ value }
onChange={ this.onChangeHandler }
onBlur={ this.onBlurHandler }
aria-describedby={ !! help ? id + '__help' : undefined }
{ ...props }
type={ type }
name={ name }
id={ id }
value={ value }
onChange={ this.onChangeHandler }
onBlur={ this.onBlurHandler }
aria-describedby={ !! help ? id + '__help' : undefined }
{ ...props }
/>
</BaseControl>
);
Expand Down
10 changes: 5 additions & 5 deletions blocks/components/toggle-control/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Internal dependencies
*/
const {BaseControl, FormToggle} = wp.components,
{withInstanceId} = wp.compose,
{Component} = wp.element;
const { BaseControl, FormToggle } = wp.components,
{ withInstanceId } = wp.compose,
{ Component } = wp.element;

class GiveToggleControl extends Component {
constructor(props) {
constructor( props ) {
super( ...props );

this.onChange = this.onChange.bind( this );
}

onChange( event ) {
if ( this.props.onChange ) {
this.props.onChange(event);
this.props.onChange( event );
}
}

Expand Down
4 changes: 2 additions & 2 deletions blocks/donation-form-grid/data/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const blockAttributes = {
columns: {
type: 'string',
default:'4',
default: '4',
},
showExcerpt: {
type: 'boolean',
Expand All @@ -22,7 +22,7 @@ const blockAttributes = {
displayType: {
type: 'string',
default: 'redirect',
}
},
};

export default blockAttributes;
Loading

0 comments on commit 7285673

Please sign in to comment.