Skip to content

Commit f7f72f1

Browse files
committed
Adding date component.
1 parent 053bfee commit f7f72f1

File tree

7 files changed

+200
-40
lines changed

7 files changed

+200
-40
lines changed

app/components/Home.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ export default class Home extends Component {
1818
};
1919
}
2020

21-
onRevisionLoaded() {
22-
this.setState({ loading: false });
23-
console.log('state: ', this.state.loading);
21+
startRevisionLoading(isLoading: boolean) {
22+
this.setState({ loading: isLoading });
2423
}
2524

2625
render() {
@@ -30,7 +29,9 @@ export default class Home extends Component {
3029
<Loader type="pacman" active={this.state.loading} size="lg" />
3130
</div>
3231
<div className={styles.container} style={this.state.loading ? { display: 'none' } : { }} data-tid="container" key="home-container">
33-
<SvnRevisionList onRevisionLoaded={() => this.onRevisionLoaded()} />
32+
<SvnRevisionList
33+
startRevisionLoading={(isLoading) => this.startRevisionLoading(isLoading)}
34+
/>
3435
</div>
3536
</div>
3637
);

app/components/SvnRevisionList.js

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import path from 'path';
55
import util from 'util';
66
import _ from 'lodash';
77
import dateFormat from 'dateformat';
8-
import { func, array } from 'prop-types';
8+
import DatePicker from 'react-datepicker';
9+
import moment from 'moment';
10+
import { func, array, date } from 'prop-types';
911
import DiffSvn2Git from 'diffsvn2git';
12+
import 'react-datepicker/dist/react-datepicker.css';
1013
import styles from './SvnRevisionList.css';
1114

1215
const workingPath = path.resolve('tmp/repo');
@@ -15,36 +18,44 @@ const diffSvn2Git = new DiffSvn2Git({ cwd: workingPath });
1518
export default class SvnRevisionList extends Component {
1619

1720
propTypes: {
18-
onRevisionLoaded: func.isRequired
21+
startRevisionLoading: func.isRequired
1922
};
2023

2124
state: {
2225
revisions: array,
23-
onRevisionLoaded: func.isRequired
26+
revisionDate: date,
27+
onRevisionDateChanged: func.isRequired,
28+
startRevisionLoading: func.isRequired
2429
};
2530

2631
constructor(props) {
2732
super(props);
2833
this.state = {
29-
revisions: []
34+
revisions: [],
35+
revisionDate: moment('15/04/2011', 'DD/MM/YYYY')
3036
};
3137
}
3238

33-
componentDidUpdate() {
34-
39+
componentWillMount() {
40+
this.fetchRevisionList();
3541
}
3642

37-
componentWillMount() {
38-
const self = this;
43+
fetchRevisionList() {
44+
if (moment(this.state.revisionDate, 'DD/MM/YYYY').isValid()) {
45+
this.setState({ revisions: [] });
3946

40-
diffSvn2Git.listRevisionsByDate('2011-04-15').then((loadedRevisions) => {
47+
this.props.startRevisionLoading(true);
48+
const self = this;
49+
console.log('revisionDate: ', moment(this.state.revisionDate, 'DD/MM/YYYY'));
4150

42-
self.setState({
43-
revisions: loadedRevisions
51+
const revisionDateFormated = this.state.revisionDate.format('YYYY-MM-DD');
52+
console.log('revisionDateFormated: ', revisionDateFormated);
53+
54+
diffSvn2Git.listRevisionsByDate(revisionDateFormated).then((loadedRevisions) => {
55+
self.setState({ revisions: loadedRevisions });
56+
this.props.startRevisionLoading(false);
4457
});
45-
console.log('onRevisionLoaded');
46-
this.props.onRevisionLoaded();
47-
});
58+
}
4859
}
4960

5061
createItem(rows: Array<any>, revision: Object) {
@@ -73,6 +84,12 @@ export default class SvnRevisionList extends Component {
7384

7485
return (
7586
<div>
87+
<DatePicker
88+
todayButton={'Today'}
89+
dateFormat="DD/MM/YYYY"
90+
selected={this.state.revisionDate}
91+
onChange={this.fetchRevisionList.bind(this)}
92+
/>
7693
<ul className="video-list">
7794
{rows}
7895
</ul>

app/main.development.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,16 @@ app.on('ready', async () => {
6969

7070
mainWindow.on('minimize', (event) => {
7171
event.preventDefault();
72-
mainWindow.hide();
7372
});
7473

75-
mainWindow.on('close', (event) => {
76-
if (!app.isQuiting) {
77-
event.preventDefault();
78-
mainWindow.hide();
79-
} else {
80-
mainWindow = null;
81-
}
82-
return false;
74+
mainWindow.on('close', () => {
75+
mainWindow = null;
8376
});
8477

8578
const menuBuilder = new MenuBuilder(mainWindow);
8679
menuBuilder.buildMenu();
8780

88-
tray = new Tray(iconPath);
81+
/*tray = new Tray(iconPath);
8982
tray.setToolTip('Code Sentinel');
9083
tray.on('click', () => {
9184
mainWindow.show();
@@ -100,5 +93,5 @@ app.on('ready', async () => {
10093
]);
10194
10295
this.popUpContextMenu(menuConfig);
103-
});
96+
});*/
10497
});

app/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
"dateformat": "^2.0.0",
1818
"diffsvn2git": "^0.0.25",
1919
"loaders.css": "^0.1.2",
20+
"moment": "^2.18.1",
2021
"prop-types": "^15.5.10",
22+
"react-datepicker": "^0.47.0",
23+
"react-dom": "^15.6.1",
2124
"react-loaders": "^2.5.0",
2225
"svn-spawn": "^0.1.5"
2326
}

app/yarn.lock

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# yarn lockfile v1
33

44

5+
asap@~2.0.3:
6+
version "2.0.5"
7+
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"
8+
59
async@^2.4.1:
610
version "2.4.1"
711
resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7"
@@ -12,10 +16,26 @@ async@~0.2.9:
1216
version "0.2.10"
1317
resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1"
1418

19+
classnames@^2.2.3, classnames@^2.2.5:
20+
version "2.2.5"
21+
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
22+
1523
config-obj@0.0.1:
1624
version "0.0.1"
1725
resolved "https://registry.yarnpkg.com/config-obj/-/config-obj-0.0.1.tgz#bb5d665cb5284dd5781da2af95ad5c8e4da8b79e"
1826

27+
core-js@^1.0.0:
28+
version "1.2.7"
29+
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
30+
31+
create-react-class@^15.5.x, create-react-class@^15.6.0:
32+
version "15.6.0"
33+
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.0.tgz#ab448497c26566e1e29413e883207d57cfe7bed4"
34+
dependencies:
35+
fbjs "^0.8.9"
36+
loose-envify "^1.3.1"
37+
object-assign "^4.1.1"
38+
1939
dateformat@^2.0.0:
2040
version "2.0.0"
2141
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17"
@@ -36,10 +56,128 @@ easy-spawn@0.0.2:
3656
dependencies:
3757
config-obj "0.0.1"
3858

59+
encoding@^0.1.11:
60+
version "0.1.12"
61+
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
62+
dependencies:
63+
iconv-lite "~0.4.13"
64+
65+
fbjs@^0.8.9:
66+
version "0.8.12"
67+
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04"
68+
dependencies:
69+
core-js "^1.0.0"
70+
isomorphic-fetch "^2.1.1"
71+
loose-envify "^1.0.0"
72+
object-assign "^4.1.0"
73+
promise "^7.1.1"
74+
setimmediate "^1.0.5"
75+
ua-parser-js "^0.7.9"
76+
77+
iconv-lite@~0.4.13:
78+
version "0.4.18"
79+
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2"
80+
81+
is-stream@^1.0.1:
82+
version "1.1.0"
83+
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
84+
85+
isomorphic-fetch@^2.1.1:
86+
version "2.2.1"
87+
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
88+
dependencies:
89+
node-fetch "^1.0.1"
90+
whatwg-fetch ">=0.10.0"
91+
92+
js-tokens@^3.0.0:
93+
version "3.0.1"
94+
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
95+
96+
loaders.css@^0.1.2:
97+
version "0.1.2"
98+
resolved "https://registry.yarnpkg.com/loaders.css/-/loaders.css-0.1.2.tgz#3a9fb43726c73334a38142af9d0629019b658743"
99+
39100
lodash@^4.0.0, lodash@^4.14.0:
40101
version "4.17.4"
41102
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
42103

104+
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
105+
version "1.3.1"
106+
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
107+
dependencies:
108+
js-tokens "^3.0.0"
109+
110+
moment@^2.17.1, moment@^2.18.1:
111+
version "2.18.1"
112+
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
113+
114+
node-fetch@^1.0.1:
115+
version "1.7.1"
116+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5"
117+
dependencies:
118+
encoding "^0.1.11"
119+
is-stream "^1.0.1"
120+
121+
object-assign@^4.1.0, object-assign@^4.1.1:
122+
version "4.1.1"
123+
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
124+
125+
promise@^7.1.1:
126+
version "7.1.1"
127+
resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf"
128+
dependencies:
129+
asap "~2.0.3"
130+
131+
prop-types@^15.5.10, prop-types@^15.5.8:
132+
version "15.5.10"
133+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
134+
dependencies:
135+
fbjs "^0.8.9"
136+
loose-envify "^1.3.1"
137+
138+
react-datepicker@^0.47.0:
139+
version "0.47.0"
140+
resolved "https://registry.yarnpkg.com/react-datepicker/-/react-datepicker-0.47.0.tgz#bb002929e870e6bd7c9a92f95d5cd7c95051f629"
141+
dependencies:
142+
classnames "^2.2.5"
143+
moment "^2.17.1"
144+
prop-types "^15.5.8"
145+
react-onclickoutside "^5.11.1"
146+
tether "^1.4.0"
147+
148+
react-dom@^15.6.1:
149+
version "15.6.1"
150+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470"
151+
dependencies:
152+
fbjs "^0.8.9"
153+
loose-envify "^1.1.0"
154+
object-assign "^4.1.0"
155+
prop-types "^15.5.10"
156+
157+
react-loaders@^2.5.0:
158+
version "2.5.0"
159+
resolved "https://registry.yarnpkg.com/react-loaders/-/react-loaders-2.5.0.tgz#fb23e9545995a403f8214e893037549aae5088c8"
160+
dependencies:
161+
classnames "^2.2.3"
162+
prop-types "^15.5.8"
163+
react "^15.4.2"
164+
165+
react-onclickoutside@^5.11.1:
166+
version "5.11.1"
167+
resolved "https://registry.yarnpkg.com/react-onclickoutside/-/react-onclickoutside-5.11.1.tgz#00314e52567cf55faba94cabbacd119619070623"
168+
dependencies:
169+
create-react-class "^15.5.x"
170+
171+
react@^15.4.2:
172+
version "15.6.1"
173+
resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df"
174+
dependencies:
175+
create-react-class "^15.6.0"
176+
fbjs "^0.8.9"
177+
loose-envify "^1.1.0"
178+
object-assign "^4.1.0"
179+
prop-types "^15.5.10"
180+
43181
sax@0.5.x:
44182
version "0.5.8"
45183
resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1"
@@ -48,6 +186,10 @@ sax@>=0.6.0:
48186
version "1.2.2"
49187
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828"
50188

189+
setimmediate@^1.0.5:
190+
version "1.0.5"
191+
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
192+
51193
svn-spawn@^0.1.5:
52194
version "0.1.5"
53195
resolved "https://registry.yarnpkg.com/svn-spawn/-/svn-spawn-0.1.5.tgz#206b885447e1bb8d6ef2c785b6d182247c0422a5"
@@ -56,6 +198,18 @@ svn-spawn@^0.1.5:
56198
easy-spawn "0.0.2"
57199
xml2js "~0.2.7"
58200

201+
tether@^1.4.0:
202+
version "1.4.0"
203+
resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.0.tgz#0f9fa171f75bf58485d8149e94799d7ae74d1c1a"
204+
205+
ua-parser-js@^0.7.9:
206+
version "0.7.12"
207+
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
208+
209+
whatwg-fetch@>=0.10.0:
210+
version "2.0.3"
211+
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
212+
59213
xml2js@^0.4.17:
60214
version "0.4.17"
61215
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.17.tgz#17be93eaae3f3b779359c795b419705a8817e868"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
"font-awesome": "^4.7.0",
191191
"history": "^4.6.1",
192192
"react": "^15.5.4",
193+
"react-datepicker": "^0.47.0",
193194
"react-dom": "^15.5.4",
194195
"react-hot-loader": "3.0.0-beta.6",
195196
"react-redux": "^5.0.4",

webpack.config.base.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,8 @@ export default {
2525
{
2626
test: /\.scss$/,
2727
loaders: ['style', 'css', 'sass']
28-
} /*,
29-
{
30-
test: /\.scss$/,
31-
loader: ExtractTextPlugin.extract('css!sass')
32-
}*/
33-
] /*,
34-
plugins: [
35-
new ExtractTextPlugin('public/style.css', {
36-
allChunks: true
37-
})
38-
]*/
28+
}
29+
]
3930
},
4031

4132
output: {

0 commit comments

Comments
 (0)