Use native Array.isArray() instead of lodash function (https://github.com/woocommerce/woocommerce-admin/pull/346)
This commit is contained in:
parent
71171ec80b
commit
e94ae40d4d
|
@ -5,7 +5,7 @@
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { Component } from '@wordpress/element';
|
import { Component } from '@wordpress/element';
|
||||||
import { IconButton, ToggleControl } from '@wordpress/components';
|
import { IconButton, ToggleControl } from '@wordpress/components';
|
||||||
import { fill, find, findIndex, first, isArray, noop } from 'lodash';
|
import { fill, find, findIndex, first, noop } from 'lodash';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ class TableCard extends Component {
|
||||||
filterCols( rows = [] ) {
|
filterCols( rows = [] ) {
|
||||||
const { showCols } = this.state;
|
const { showCols } = this.state;
|
||||||
// Header is a 1d array
|
// Header is a 1d array
|
||||||
if ( ! isArray( first( rows ) ) ) {
|
if ( ! Array.isArray( first( rows ) ) ) {
|
||||||
return rows.filter( ( col, i ) => showCols[ i ] );
|
return rows.filter( ( col, i ) => showCols[ i ] );
|
||||||
}
|
}
|
||||||
// Rows is a 2d array
|
// Rows is a 2d array
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { cloneElement, Component } from '@wordpress/element';
|
import { cloneElement, Component } from '@wordpress/element';
|
||||||
import Gridicon from 'gridicons';
|
import Gridicon from 'gridicons';
|
||||||
import { isArray } from 'lodash';
|
|
||||||
import { moment } from '@wordpress/date';
|
import { moment } from '@wordpress/date';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ class ActivityCard extends Component {
|
||||||
render() {
|
render() {
|
||||||
const { actions, className, children, date, icon, subtitle, title, unread } = this.props;
|
const { actions, className, children, date, icon, subtitle, title, unread } = this.props;
|
||||||
const cardClassName = classnames( 'woocommerce-activity-card', className );
|
const cardClassName = classnames( 'woocommerce-activity-card', className );
|
||||||
const actionsList = isArray( actions ) ? actions : [ actions ];
|
const actionsList = Array.isArray( actions ) ? actions : [ actions ];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={ cardClassName }>
|
<section className={ cardClassName }>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { Component } from '@wordpress/element';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { decodeEntities } from '@wordpress/html-entities';
|
import { decodeEntities } from '@wordpress/html-entities';
|
||||||
import { Fill } from 'react-slot-fill';
|
import { Fill } from 'react-slot-fill';
|
||||||
import { isArray } from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ReactDom from 'react-dom';
|
import ReactDom from 'react-dom';
|
||||||
|
|
||||||
|
@ -56,11 +55,11 @@ class Header extends Component {
|
||||||
render() {
|
render() {
|
||||||
const { sections, isEmbedded } = this.props;
|
const { sections, isEmbedded } = this.props;
|
||||||
const { isScrolled } = this.state;
|
const { isScrolled } = this.state;
|
||||||
const _sections = isArray( sections ) ? sections : [ sections ];
|
const _sections = Array.isArray( sections ) ? sections : [ sections ];
|
||||||
|
|
||||||
const documentTitle = _sections
|
const documentTitle = _sections
|
||||||
.map( section => {
|
.map( section => {
|
||||||
return isArray( section ) ? section[ 1 ] : section;
|
return Array.isArray( section ) ? section[ 1 ] : section;
|
||||||
} )
|
} )
|
||||||
.reverse()
|
.reverse()
|
||||||
.join( ' ‹ ' );
|
.join( ' ‹ ' );
|
||||||
|
@ -84,7 +83,7 @@ class Header extends Component {
|
||||||
<Link href="/">WooCommerce</Link>
|
<Link href="/">WooCommerce</Link>
|
||||||
</span>
|
</span>
|
||||||
{ _sections.map( ( section, i ) => {
|
{ _sections.map( ( section, i ) => {
|
||||||
const sectionPiece = isArray( section ) ? (
|
const sectionPiece = Array.isArray( section ) ? (
|
||||||
<Link href={ section[ 0 ] } type={ isEmbedded ? 'wp-admin' : 'wc-admin' }>
|
<Link href={ section[ 0 ] } type={ isEmbedded ? 'wp-admin' : 'wc-admin' }>
|
||||||
{ section[ 1 ] }
|
{ section[ 1 ] }
|
||||||
</Link>
|
</Link>
|
||||||
|
|
Loading…
Reference in New Issue