Skip to content

Commit

Permalink
Merge pull request #603 from fedspendingtransparency/dev-stable
Browse files Browse the repository at this point in the history
Promote dev-stable to staging
  • Loading branch information
kim-minahm authored Jan 5, 2018
2 parents 78b2d71 + 09b4235 commit c84dfbb
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/js/components/award/contract/ContractDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default class ContractDetails extends React.Component {
}

componentWillReceiveProps(nextProps) {
this.prepareValues(nextProps.selectedAward);
if (!Object.is(nextProps.selectedAward, this.props.selectedAward)) {
this.prepareValues(nextProps.selectedAward);
}
}

parsePlaceOfPerformance(award) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ export default class FinancialAssistanceDetails extends React.Component {
};
}

componentWillReceiveProps() {
componentDidMount() {
this.prepareValues(this.props.selectedAward);
}

componentWillReceiveProps(nextProps) {
if (!Object.is(nextProps.selectedAward, this.props.selectedAward)) {
this.prepareValues(nextProps.selectedAward);
}
}

parsePlaceOfPerformance(award) {
// Location
let popPlace = '';
Expand Down Expand Up @@ -94,11 +100,10 @@ export default class FinancialAssistanceDetails extends React.Component {
return popPlace;
}

prepareValues() {
prepareValues(award) {
let yearRangeTotal = "";
let monthRangeTotal = "";
let description = null;
const award = this.props.selectedAward;
const latestTransaction = award.latest_transaction;

// Date Range
Expand Down
8 changes: 4 additions & 4 deletions src/js/components/search/SearchSidebarSubmit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const propTypes = {
requestsComplete: PropTypes.bool,
filtersChanged: PropTypes.bool,
applyStagedFilters: PropTypes.func,
resetStagedFilters: PropTypes.func
resetFilters: PropTypes.func
};

const SearchSidebarSubmit = (props) => {
Expand All @@ -33,10 +33,10 @@ const SearchSidebarSubmit = (props) => {
</button>
<button
className="reset-button"
aria-label="Reset filters"
aria-label="Reset search"
disabled={!props.requestsComplete}
onClick={props.resetStagedFilters}>
Reset filters
onClick={props.resetFilters}>
Reset search
</button>
</div>
);
Expand Down
11 changes: 9 additions & 2 deletions src/js/containers/search/SearchSidebarSubmitContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const propTypes = {
requestsComplete: PropTypes.bool,
applyStagedFilters: PropTypes.func,
clearStagedFilters: PropTypes.func,
setAppliedFilterCompletion: PropTypes.func
setAppliedFilterCompletion: PropTypes.func,
resetAppliedFilters: PropTypes.func
};

export class SearchSidebarSubmitContainer extends React.Component {
Expand All @@ -36,6 +37,7 @@ export class SearchSidebarSubmitContainer extends React.Component {
filtersChanged: false
};

this.resetFilters = this.resetFilters.bind(this);
this.applyStagedFilters = this.applyStagedFilters.bind(this);
}

Expand Down Expand Up @@ -93,13 +95,18 @@ export class SearchSidebarSubmitContainer extends React.Component {
});
}

resetFilters() {
this.props.clearStagedFilters();
this.props.resetAppliedFilters();
}

render() {
return (
<SearchSidebarSubmit
filtersChanged={this.state.filtersChanged}
requestsComplete={this.props.requestsComplete}
applyStagedFilters={this.applyStagedFilters}
resetStagedFilters={this.props.clearStagedFilters} />
resetFilters={this.resetFilters} />
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/redux/actions/search/appliedFilterActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const applyStagedFilters = (filters) => ({
});

export const resetAppliedFilters = () => ({
type: 'CLEAR_APPLIED_FILTER'
type: 'CLEAR_APPLIED_FILTERS'
});
30 changes: 30 additions & 0 deletions tests/containers/search/SearchSidebarSubmitContainer-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,34 @@ describe('SearchSidebarSubmitContainer', () => {
expect(container.state().filtersChanged).toBeFalsy();
});
});
describe('resetFilters', () => {
it('should reset all the staged filters to their initial states', () => {
const actions = Object.assign({}, mockActions, {
clearStagedFilters: jest.fn()
});

const container = shallow(
<SearchSidebarSubmitContainer
{...mockRedux}
{...actions} />
);

container.instance().resetFilters();
expect(actions.clearStagedFilters).toHaveBeenCalledTimes(1);
});
it('should reset all the applied filters to their initial states', () => {
const actions = Object.assign({}, mockActions, {
resetAppliedFilters: jest.fn()
});

const container = shallow(
<SearchSidebarSubmitContainer
{...mockRedux}
{...actions} />
);

container.instance().resetFilters();
expect(actions.resetAppliedFilters).toHaveBeenCalledTimes(1);
});
});
});
3 changes: 2 additions & 1 deletion tests/containers/search/mockSubmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const mockRedux = {
export const mockActions = {
applyStagedFilters: jest.fn(),
clearStagedFilters: jest.fn(),
setAppliedFilterCompletion: jest.fn()
setAppliedFilterCompletion: jest.fn(),
resetAppliedFilters: jest.fn()
};

0 comments on commit c84dfbb

Please sign in to comment.