Skip to content

Commit

Permalink
Merge pull request #283 from flacoman91/remove-issues
Browse files Browse the repository at this point in the history
Remove Issues from Trends & Map
  • Loading branch information
sephcoster authored Jun 16, 2020
2 parents dcf3c8f + 85f06af commit a9e433b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 163 deletions.
12 changes: 2 additions & 10 deletions src/components/Map/MapPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ export class MapPanel extends React.Component {
data={this.props.productData.data}
title="Product by highest complaint volume"
total={ this.props.total }/>
<RowChart id="issue"
colorScheme={this.props.issueData.colorScheme}
data={this.props.issueData.data}
title="Issue by highest complaint volume"
total={ this.props.total }/>

<Loading isLoading={ this.props.isLoading || false }/>
</section>
Expand All @@ -71,16 +66,13 @@ const mapStateToProps = state => {

const {
enablePer1000,
issue: issueFilters,
mapWarningEnabled,
product: productFilters
mapWarningEnabled
} = query

return {
error,
isLoading,
issueData: processRows( issueFilters, results.issue, false ),
productData: processRows( productFilters, results.product, false ),
productData: processRows( results.product, false ),
showMobileFilters: state.view.width < 750,
showWarning: !enablePer1000 && mapWarningEnabled,
total: state.aggs.total
Expand Down
10 changes: 3 additions & 7 deletions src/components/Trends/LensTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import React from 'react'

const lensMaps = {
Company: {
tab1: { displayName: 'Products', filterName: 'product' },
tab2: { displayName: 'Issues', filterName: 'issue' }
},
Issue: {
tab1: { displayName: 'Sub-issues', filterName: 'sub_issue' },
tab2: { displayName: 'Products', filterName: 'product' }
tab1: { displayName: 'Products', filterName: 'product' }
},
Product: {
tab1: { displayName: 'Sub-products', filterName: 'sub_product' },
Expand Down Expand Up @@ -49,12 +44,13 @@ export class LensTabs extends React.Component {
onClick={ () => this._setTab( lensMaps[lens].tab1.filterName ) }>
{ lensMaps[lens].tab1.displayName }
</button>

{ lensMaps[lens].tab2 &&
<button
className={ this._getTabClass( lensMaps[lens].tab2.filterName ) }
onClick={ () => this._setTab( lensMaps[lens].tab2.filterName ) }>
{ lensMaps[lens].tab2.displayName }
</button>
}
</section>
</div>
)
Expand Down
34 changes: 11 additions & 23 deletions src/components/Trends/TrendsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { showCompanyOverLay } from '../../utils/trends'
import StackedAreaChart from '../Charts/StackedAreaChart'

const intervals = [ 'Day', 'Week', 'Month', 'Quarter', 'Year' ]
const lenses = [ 'Overview', 'Company', 'Product', 'Issue' ]
const lenses = [ 'Overview', 'Company', 'Product' ]
const subLensMap = {
sub_product: 'Sub-products',
sub_issue: 'Sub-issues',
Expand Down Expand Up @@ -56,20 +56,12 @@ export class TrendsPanel extends React.Component {

_phaseMap() {
if ( this.props.overview ) {
return [
<RowChart id="product"
colorScheme={ this.props.productData.colorScheme }
data={ this.props.productData.data }
title={ 'Product by highest complaint volume' }
total={ this.props.total }
key={ 'product-row' }/>,
<RowChart id="issue"
colorScheme={ this.props.issueData.colorScheme }
data={ this.props.issueData.data }
title={ 'Issue by highest complaint volume' }
total={ this.props.total }
key={ 'issue-row' }/>
]
return <RowChart id="product"
colorScheme={ this.props.productData.colorScheme }
data={ this.props.productData.data }
title={ 'Product by highest complaint volume' }
total={ this.props.total }
key={ 'product-row' }/>
}

if ( this.props.focus ) {
Expand Down Expand Up @@ -164,8 +156,6 @@ const mapStateToProps = state => {
const {
company: companyFilters,
dateInterval,
issue: issueFilters,
product: productFilters,
lens,
subLens
} = query
Expand All @@ -175,19 +165,17 @@ const mapStateToProps = state => {
} = trends

const lensKey = lens.toLowerCase()
const dataLensFilters = query[lensKey]
const focusKey = subLens.replace( '_', '-' )
return {
chartType,
companyData: processRows( companyFilters, results.company, false ),
companyData: processRows( results.company, false ),
companyOverlay: showCompanyOverLay( lens, companyFilters, isLoading ),
dateInterval,
focus,
focusData: processRows( issueFilters, results[focusKey], colorMap ),
focusData: processRows( results[focusKey], colorMap ),
isLoading,
issueData: processRows( issueFilters, results.issue, false ),
productData: processRows( productFilters, results.product, false ),
dataLensData: processRows( dataLensFilters, results[lensKey], colorMap ),
productData: processRows( results.product, false ),
dataLensData: processRows( results[lensKey], colorMap ),
lens,
overview: lens === 'Overview',
showMobileFilters: state.view.width < 750,
Expand Down
30 changes: 0 additions & 30 deletions src/components/__tests__/__snapshots__/MapPanel.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,6 @@ exports[`component:MapPanel renders Print without crashing 1`] = `
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
`;

Expand Down Expand Up @@ -408,16 +398,6 @@ exports[`component:MapPanel renders warning without crashing 1`] = `
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
`;

Expand Down Expand Up @@ -600,15 +580,5 @@ exports[`component:MapPanel renders without crashing 1`] = `
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
`;
25 changes: 0 additions & 25 deletions src/components/__tests__/__snapshots__/ResultsPanel.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -695,16 +695,6 @@ exports[`component:Results renders Map print mode without crashing 1`] = `
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
<section
className="print-info-footer"
Expand Down Expand Up @@ -1352,16 +1342,6 @@ exports[`component:Results renders map panel without crashing 1`] = `
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
</div>
`;
Expand Down Expand Up @@ -1480,11 +1460,6 @@ exports[`component:Results renders trends panel without crashing 1`] = `
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down
63 changes: 0 additions & 63 deletions src/components/__tests__/__snapshots__/TrendsPanel.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ exports[`component:TrendsPanel Snapshots renders Focus without crashing 1`] = `
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -497,11 +492,6 @@ exports[`component:TrendsPanel Snapshots renders area without crashing 1`] = `
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -853,11 +843,6 @@ exports[`component:TrendsPanel Snapshots renders company Overlay without crashin
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -1130,12 +1115,6 @@ exports[`component:TrendsPanel Snapshots renders company Overlay without crashin
>
Products
</button>
<button
className="tab issue"
onClick={[Function]}
>
Issues
</button>
</section>
</div>
<div
Expand Down Expand Up @@ -1262,11 +1241,6 @@ exports[`component:TrendsPanel Snapshots renders external Tooltip without crashi
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -1618,11 +1592,6 @@ exports[`component:TrendsPanel Snapshots renders lineChart Overview without cras
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -1739,16 +1708,6 @@ exports[`component:TrendsPanel Snapshots renders lineChart Overview without cras
id="row-chart-product"
/>
</div>
<div
className="row-chart-section"
>
<h3>
Issue by highest complaint volume
</h3>
<div
id="row-chart-issue"
/>
</div>
</section>
`;

Expand Down Expand Up @@ -1864,11 +1823,6 @@ exports[`component:TrendsPanel Snapshots renders mobile filters without crashing
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -2141,12 +2095,6 @@ exports[`component:TrendsPanel Snapshots renders mobile filters without crashing
>
Products
</button>
<button
className="tab issue"
onClick={[Function]}
>
Issues
</button>
</section>
</div>
<div
Expand Down Expand Up @@ -2273,11 +2221,6 @@ exports[`component:TrendsPanel Snapshots renders print mode without crashing 1`]
>
Product
</option>
<option
value="Issue"
>
Issue
</option>
</select>
</section>
<span
Expand Down Expand Up @@ -2550,12 +2493,6 @@ exports[`component:TrendsPanel Snapshots renders print mode without crashing 1`]
>
Products
</button>
<button
className="tab issue"
onClick={[Function]}
>
Issues
</button>
</section>
</div>
<div
Expand Down
6 changes: 2 additions & 4 deletions src/utils/__tests__/chart.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,21 @@ describe( 'getColorScheme', function () {

describe( 'processRows', () => {
it( 'handles empty rows / bad data', () => {
const filters = []
const res = sut.processRows( filters, false, false )
const res = sut.processRows( false, false )
expect( res ).toEqual( {
colorScheme: [],
data: []
} )
} )

it( 'returns only visible rows', () => {
const filters = []
const rows = [
{ name: 'abc', visible: true, value: 123 },
{ name: 'def', visible: true, value: 123 },
{ name: 'Complaint', visible: true, value: 123 },
{ name: 'Compla', parent: 'Complaint', visible: false, value: 123 },
{ name: 'de11f', parent: 'def', visible: false, value: 123 } ]
const res = sut.processRows( filters, rows, false )
const res = sut.processRows( rows, false )
expect( res ).toEqual( {
colorScheme: [ '#20aa3f', '#20aa3f', '#20aa3f' ],
data: [
Expand Down
2 changes: 1 addition & 1 deletion src/utils/chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const getColorScheme = ( rowNames, colorMap ) =>
return '#20aa3f'
} )

export const processRows = ( filters, rows, colorMap ) => {
export const processRows = ( rows, colorMap ) => {
let data = rows ? rows : []
data = data.filter( o => o.visible )
const colorScheme = getColorScheme( data, colorMap )
Expand Down

0 comments on commit a9e433b

Please sign in to comment.