Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sprint-10 -> staging (#201) #1908

Merged
merged 1 commit into from May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion config/jest/setupTests.js
Expand Up @@ -24,7 +24,10 @@ Object.values = (obj) => Object.keys(obj).map(key => obj[key])
// Avoid jest error: "Error: Not implemented: navigation (except hash changes)"
global.window.location.assign = () => {};

// mock sessionStorage - feature flags config
beforeEach(() => {
// mock sessionStorage - feature flags config
sessionStorage.setItem('config', JSON.stringify(config));

// mock querySelector
global.document.querySelector = () => ({ offsetParent: '50px', scrollIntoView: () => {} });
});
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -29,7 +29,6 @@
"rc-steps": "^3.1.0",
"react": "^15.6.2",
"react-autosuggest": "^9.3.2",
"react-csv": "^1.1.1",
"react-dom": "^15.6.2",
"react-fontawesome": "^1.6.1",
"react-helmet": "^5.2.0",
Expand Down Expand Up @@ -141,7 +140,8 @@
"!src/Components/**/index.js",
"!src/Components/StaticDevContent/*",
"!src/actions/showStaticContent.js",
"!src/reducers/showStaticContent.js"
"!src/reducers/showStaticContent.js",
"!src/Components/CSV/**/*.{js,jsx}"
],
"coverageReporters": [
"text-summary",
Expand Down
3 changes: 2 additions & 1 deletion public/config/config.json
Expand Up @@ -5,6 +5,7 @@
"flags": {
"bidding": true,
"projected_vacancy": true,
"static_content": true
"static_content": true,
"notifications": true
}
}
5 changes: 3 additions & 2 deletions public/config/config_dev.json
Expand Up @@ -3,8 +3,9 @@
"baseURL": "https://dev.talentmap.api.metaphasedev.com/api/v1"
},
"flags": {
"bidding": false,
"bidding": true,
"projected_vacancy": true,
"static_content": true
"static_content": true,
"notifications": true
}
}
8 changes: 4 additions & 4 deletions public/login.html
Expand Up @@ -15,16 +15,16 @@ <h2>Personas</h2>
<a OnClick="login('admin', 'admin');">Administrator</a>
</li>
<li>
<a OnClick="login('shadtrachl', 'password');">Leah Shadtrach</a>
<a OnClick="login('shadtrachl', 'password');">Leah Shadtrach (CDO)</a>
</li>
<li>
<a OnClick="login('townpostj', 'password');">Jenny Townpost</a>
<a OnClick="login('townpostj', 'password');">Jenny Townpost (Bidder)</a>
</li>
<li>
<a OnClick="login('rehmant', 'password');">Tarek Rehman</a>
<a OnClick="login('rehmant', 'password');">Tarek Rehman (Bidder)</a>
</li>
<li>
<a OnClick="login('woodwardw', 'password');">Wendy Woodward</a>
<a OnClick="login('woodwardw', 'password');">Wendy Woodward (AO)</a>
</li>
</ul>
</div>
Expand Down
Expand Up @@ -87,6 +87,14 @@ exports[`BidTrackerCardContainerComponent matches snapshot when priorityExists i
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down Expand Up @@ -267,6 +275,14 @@ exports[`BidTrackerCardContainerComponent matches snapshot when priorityExists i
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down
Expand Up @@ -86,6 +86,14 @@ exports[`BidTrackerCardListComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down Expand Up @@ -196,6 +204,14 @@ exports[`BidTrackerCardListComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down Expand Up @@ -306,6 +322,14 @@ exports[`BidTrackerCardListComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down
Expand Up @@ -268,6 +268,14 @@ exports[`BidTrackerComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down
Expand Up @@ -41,6 +41,14 @@ exports[`BidderPortfolioCardComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down Expand Up @@ -96,6 +104,14 @@ exports[`BidderPortfolioCardComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down
@@ -1,26 +1,30 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { BIDDER_LIST } from '../../../Constants/PropTypes';
import { scrollToTop } from '../../../utilities';
import { scrollToId } from '../../../utilities';
import BidderPortfolioCardList from '../BidderPortfolioCardList';
import BidderPortfolioGridList from '../BidderPortfolioGridList';
import PaginationWrapper from '../../PaginationWrapper/PaginationWrapper';
import Alert from '../../Alert/Alert';

const ID = 'bidder-portfolio-container';

class BidderPortfolioContainer extends Component {
constructor(props) {
super(props);
this.onPageChange = this.onPageChange.bind(this);
}
onPageChange(q) {
scrollToTop();
this.props.queryParamUpdate(q);
scrollToId({ el: '.bidder-portfolio-container', config: { duration: 400 } });
setTimeout(() => {
this.props.queryParamUpdate(q);
}, 600);
}
render() {
const { bidderPortfolio, pageSize, pageNumber, showListView, showEdit } = this.props;
const noResults = bidderPortfolio.results.length === 0;
return (
<div className="usa-grid-full user-dashboard">
<div className="usa-grid-full user-dashboard" id={ID}>
{
showListView ?
<BidderPortfolioGridList showEdit={showEdit} results={bidderPortfolio.results} />
Expand Down
Expand Up @@ -16,7 +16,7 @@ describe('BidderPortfolioContainerComponent', () => {
expect(wrapper).toBeDefined();
});

it('can call the onPageChange function', () => {
it('can call the onPageChange function', (done) => {
const spy = sinon.spy();
const wrapper = shallow(<BidderPortfolioContainer
bidderPortfolio={bidderListObject}
Expand All @@ -25,7 +25,10 @@ describe('BidderPortfolioContainerComponent', () => {
queryParamUpdate={spy}
/>);
wrapper.instance().onPageChange({});
sinon.assert.calledOnce(spy);
setTimeout(() => {
sinon.assert.calledOnce(spy);
done();
}, 700);
});

it('matches snapshot when the all property is greater than zero', () => {
Expand Down
Expand Up @@ -3,6 +3,7 @@
exports[`BidderPortfolioContainerComponent matches snapshot when the all property is greater than zero 1`] = `
<div
className="usa-grid-full user-dashboard"
id="bidder-portfolio-container"
>
<BidderPortfolioCardList
results={
Expand Down Expand Up @@ -223,6 +224,7 @@ exports[`BidderPortfolioContainerComponent matches snapshot when the all propert
exports[`BidderPortfolioContainerComponent matches snapshot when the all property is zero 1`] = `
<div
className="usa-grid-full user-dashboard"
id="bidder-portfolio-container"
>
<BidderPortfolioCardList
results={Array []}
Expand Down
Expand Up @@ -54,6 +54,14 @@ exports[`BidderPortfolioGridItemComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down Expand Up @@ -110,6 +118,14 @@ exports[`BidderPortfolioGridItemComponent matches snapshot 1`] = `
"representation": "[00180000] OMS (DCM) (Addis Ababa, Ethiopia)",
},
],
"favorite_positions_pv": Array [
Object {
"id": 10,
},
Object {
"id": 20,
},
],
"grade": "03",
"id": 1,
"initials": "JD",
Expand Down
19 changes: 15 additions & 4 deletions src/Components/BidderPortfolio/ExportLink/ExportLink.jsx
@@ -1,11 +1,12 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { CSVLink } from 'react-csv';
import { get } from 'lodash';
import { get, mapValues } from 'lodash';
import { CSVLink } from '../../CSV';
import { bidderPortfolioFetchDataFromLastQuery } from '../../../actions/bidderPortfolio';
import { EMPTY_FUNCTION } from '../../../Constants/PropTypes';
import ExportButton from '../../ExportButton';
import { getFormattedNumCSV, spliceStringForCSV } from '../../../utilities';

// Mapping columns to data fields
const HEADERS = [
Expand All @@ -23,7 +24,8 @@ const HEADERS = [
// Processes results before sending to the download component to allow for custom formatting.
const processData = data => (
data.map(entry => ({
...entry,
...mapValues(entry, x => !x ? '' : x), // eslint-disable-line no-confusing-arrow
grade: getFormattedNumCSV(entry.grade),
// any other processing we may want to do here
}))
);
Expand Down Expand Up @@ -74,7 +76,16 @@ export class ExportLink extends Component {
return (
<div className="export-button-container">
<ExportButton onClick={this.onClick} isLoading={isLoading} />
<CSVLink tabIndex="-1" ref={this.setCsvRef} target="_blank" filename={this.props.filename} data={data} headers={HEADERS} />
<CSVLink
transform={spliceStringForCSV}
tabIndex="-1"
ref={this.setCsvRef}
target="_blank"
filename={this.props.filename}
data={data}
headers={HEADERS}
uFEFF={false}
/>
</div>
);
}
Expand Down
Expand Up @@ -57,7 +57,8 @@ exports[`SearchResultsExportLink matches snapshot 1`] = `
separator=","
tabIndex="-1"
target="_blank"
uFEFF={true}
transform={[Function]}
uFEFF={false}
/>
</div>
`;
50 changes: 50 additions & 0 deletions src/Components/CSV/components/Download.js
@@ -0,0 +1,50 @@
/* eslint-disable */
import React from 'react';
import {buildURI} from '../core';
import {
defaultProps as commonDefaultProps,
propTypes as commonPropTypes} from '../metaProps';
const defaultProps = {
target: '_blank'
};

/**
*
* @example ../../sample-site/csvdownload.example.md
*/
class CSVDownload extends React.Component {

static defaultProps = Object.assign(
commonDefaultProps,
defaultProps
);

static propTypes = commonPropTypes;

constructor(props) {
super(props);
this.state={};
}

buildURI() {
return buildURI(...arguments);
}

componentDidMount(){
const {data, headers, separator, enclosingCharacter, uFEFF, target, specs, replace, transform} = this.props;
this.state.page = window.open(
this.buildURI(data, uFEFF, headers, separator, enclosingCharacter), target, specs, replace, transform
);
}

getWindow() {
return this.state.page;
}

render(){
return (null)
}
}

export default CSVDownload;
/* eslint-enable */