Skip to content

Commit 9ee0039

Browse files
committed
ui: upgrade to ant-design v4
* upgrades to antd to v4 * fixes UX problems with date range picker: INSPIR-3203 * reduces bundle size by removing unnecessary icons: INSPIR-3228 * upgrades to react@16.13.10 * upgrades to react-router to v5 Unresolved: * `componentWillReceiveProps` warnings from `react-vis` uber/react-vis#1253 * search name space truncates some options like `conferen...` ant-design/ant-design#21754 * `componentWillMount` warnings from `react-helmet` nfl/react-helmet#413 * `componentWillMount` warnings from `react-loadable` jamiebuilds/react-loadable#220 * `Cannot update a component from inside the function body of a different component.` worning from `antd` ant-design/ant-design#21800 * `componentWillReceiveProps` warnings from `react-quill` zenoamaro/react-quill#549
1 parent c0daa3d commit 9ee0039

File tree

153 files changed

+1061
-1399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+1061
-1399
lines changed

e2e/tests/submissions/conference.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const moment = require('moment');
22
const { ResponseInterceptor } = require('../../utils/interceptors');
33
const { login } = require('../../utils/user');
4-
const { FormSubmitter } = require('../../utils/form');
4+
const { FormSubmitter, DATE_FORMAT } = require('../../utils/form');
55
const routes = require('../../utils/routes');
66

77
describe('conference submissions', () => {
@@ -49,7 +49,6 @@ describe('conference submissions', () => {
4949
additional_info: 'This is some additional info',
5050
keywords: ['keyword1', 'keyword2'],
5151
});
52-
5352
await formSubmitter.waitForSubmissionSuccess();
5453

5554
const submitResponse = interceptor.getFirstResponseByUrl(
@@ -70,8 +69,8 @@ describe('conference submissions', () => {
7069
country_code: 'CH',
7170
},
7271
],
73-
opening_date: startDateMoment.format('YYYY-MM-DD'),
74-
closing_date: endDateMoment.format('YYYY-MM-DD'),
72+
opening_date: startDateMoment.format(DATE_FORMAT),
73+
closing_date: endDateMoment.format(DATE_FORMAT),
7574
inspire_categories: [{ term: 'Accelerators' }],
7675
keywords: [{ value: 'keyword1' }, { value: 'keyword2' }],
7776
public_notes: [{ value: 'This is some additional info' }],
@@ -107,11 +106,11 @@ describe('conference submissions', () => {
107106

108107
await formSubmitter.fill({
109108
name: 'Please come to my conference',
110-
dates: [moment().add(20, 'day'), moment().add(24, 'day')],
109+
dates: [moment().add(10, 'day'), moment().add(11, 'day')],
111110
addresses: [
112111
{
113112
city: 'Stockholm',
114-
country: 'Sweden',
113+
country: 'Switzerland',
115114
},
116115
],
117116
field_of_interest: ['Computing'],

e2e/tests/submissions/job.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const moment = require('moment');
22
const { ResponseInterceptor } = require('../../utils/interceptors');
33
const { login } = require('../../utils/user');
4-
const { FormSubmitter } = require('../../utils/form');
4+
const { FormSubmitter, DATE_FORMAT } = require('../../utils/form');
55
const routes = require('../../utils/routes');
66

77
describe('job submissions', () => {
@@ -70,7 +70,7 @@ describe('job submissions', () => {
7070
urls: [{ value: 'https://someinfo.com' }],
7171
deadline_date: moment()
7272
.add(1, 'day')
73-
.format('YYYY-MM-DD'),
73+
.format(DATE_FORMAT),
7474
contact_details: [
7575
{
7676
name: 'John Doe',

e2e/utils/dom.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const TYPE_ATTRIBUTE = 'data-test-type';
44
async function selectFromSelectBox(page, selectId, value) {
55
const selectSelector = `[${ID_ATTRIBUTE}="${selectId}"]`;
66
const selectOptionSelector = `[${ID_ATTRIBUTE}="${selectId}-option-${value}"]`;
7+
const optionSearchSelector = `${selectSelector} input`;
78

8-
// click selecbox to render options into DOM incase not there
9-
await page.click(selectSelector);
9+
// type optio to selecbox to make sure it is rendered into DOM
10+
await page.type(optionSearchSelector, value);
1011
await page.waitFor(selectOptionSelector);
1112

1213
// close it because puppeteer sometimes clicks on other option accidentally

e2e/utils/form.js

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
/* eslint-disable no-await-in-loop, no-restricted-syntax */
22
const moment = require('moment');
3+
34
const routes = require('./routes');
45
const { selectFromSelectBox, ID_ATTRIBUTE, TYPE_ATTRIBUTE } = require('./dom');
56

7+
const SUBMIT_BUTTON_SELECTOR = 'button[type=submit]';
8+
const DATE_FORMAT = 'YYYY-MM-DD';
9+
610
function joinPaths(...paths) {
711
return paths.filter(path => path != null).join('.');
812
}
913

10-
const SUBMIT_BUTTON_SELECTOR = 'button[type=submit]';
14+
async function fillDateInputElement(element, dateValue) {
15+
const dateMoment = moment(dateValue);
16+
const formattedDate = dateMoment.format(DATE_FORMAT);
17+
await element.type(formattedDate);
18+
}
1119

1220
class FormSubmitter {
1321
constructor(page) {
@@ -43,6 +51,7 @@ class FormSubmitter {
4351
}
4452

4553
async fill(data) {
54+
await this.page.waitFor('form');
4655
await this.fillAnyField(null, data);
4756
await this.page.click('form');
4857
}
@@ -63,6 +72,9 @@ class FormSubmitter {
6372
case 'string':
6473
await this.fillNumberOrStringField(path, data);
6574
break;
75+
case 'suggester':
76+
await this.fillSuggesterField(path, data);
77+
break;
6678
case 'single-select':
6779
await this.fillSingleSelectField(path, data);
6880
break;
@@ -142,6 +154,12 @@ class FormSubmitter {
142154
}
143155
}
144156

157+
async fillSuggesterField(path, value) {
158+
const fieldSelector = `[${ID_ATTRIBUTE}="${path}"]`;
159+
const innerInputSelector = `${fieldSelector} input`;
160+
await this.page.type(innerInputSelector, value);
161+
}
162+
145163
async fillNumberOrStringField(path, value) {
146164
const fieldSelector = `[${ID_ATTRIBUTE}="${path}"]`;
147165
await this.page.type(fieldSelector, value);
@@ -157,23 +175,22 @@ class FormSubmitter {
157175
}
158176
}
159177

160-
async selectDateOnActivePicker(date) {
161-
const dateSelector = `[title="${moment(date).format('MMMM D, YYYY')}"]`;
162-
await this.page.waitFor(dateSelector);
163-
await this.page.click(dateSelector);
164-
}
165-
166178
async fillDateField(path, value) {
167179
const fieldSelector = `[${ID_ATTRIBUTE}="${path}"]`;
168-
await this.page.click(fieldSelector);
169-
await this.selectDateOnActivePicker(value);
180+
const fieldElement = await this.page.$(fieldSelector);
181+
await fillDateInputElement(fieldElement, value);
170182
}
171183

172184
async fillDateRangeField(path, [startDate, endDate]) {
173185
const fieldSelector = `[${ID_ATTRIBUTE}="${path}"]`;
174-
await this.page.click(fieldSelector);
175-
await this.selectDateOnActivePicker(startDate);
176-
await this.selectDateOnActivePicker(endDate);
186+
const inputsSelector = `${fieldSelector} input`;
187+
188+
const [startDateInputElement, endDateInputElement] = await this.page.$$(inputsSelector);
189+
190+
await fillDateInputElement(startDateInputElement, startDate);
191+
await fillDateInputElement(endDateInputElement, endDate);
192+
193+
await endDateInputElement.press('Enter');
177194
}
178195

179196
async fillRichTextField(path, value) {
@@ -185,4 +202,5 @@ class FormSubmitter {
185202
module.exports = {
186203
FormSubmitter,
187204
SUBMIT_BUTTON_SELECTOR,
205+
DATE_FORMAT,
188206
};

ui/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "inspire-next-react",
33
"license": "GPL-2.0",
44
"version": "0.1.19",
5-
"proxy": "localhost:8000",
5+
"proxy": "http://localhost:8000",
66
"bundlesize": [
77
{
88
"path": "./build/**/*.js",
@@ -23,10 +23,11 @@
2323
"./node_modules/eslint/bin/eslint.js ./src --ext .js,.jsx --config .eslintrc"
2424
},
2525
"dependencies": {
26+
"@ant-design/icons": "^4.0.0",
2627
"@babel/runtime": "7.0.0-beta.55",
2728
"@craco/craco": "^3.1.0",
2829
"@sentry/browser": "^4.3.0",
29-
"antd": "^3.4.1",
30+
"antd": "^4.0.0",
3031
"axios": "^0.18.0",
3132
"classnames": "^2.2.6",
3233
"connected-react-router": "^6.4.0",
@@ -58,7 +59,7 @@
5859
"react-piwik": "^1.6.0",
5960
"react-quill": "^1.3.3",
6061
"react-redux": "^6.0.0",
61-
"react-router-dom": "^4.2.2",
62+
"react-router-dom": "^5.1.0",
6263
"react-sanitized-html": "^2.0.0",
6364
"react-scripts": "2.0.3",
6465
"react-vis": "^1.9.2",

ui/src/App.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
}
4747
}
4848

49-
.mb4-important {
50-
margin-bottom: 4px !important;
51-
}
52-
5349
.secondary-color {
5450
color: $secondary-color;
5551
}
@@ -119,6 +115,10 @@
119115
}
120116
}
121117

118+
.mb2-important {
119+
margin-bottom: 0.5rem !important;
120+
}
121+
122122
.ant-drawer-body {
123123
@media (max-width: $screen-xs-max) {
124124
padding: $drawer-body-padding / 2 !important;

ui/src/authors/components/AuthorEmailsAction.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { List } from 'immutable';
4-
import { Menu, Icon, Tooltip } from 'antd';
4+
import { MailOutlined } from '@ant-design/icons';
5+
import { Menu, Tooltip } from 'antd';
56

67
import ExternalLink from '../../common/components/ExternalLink';
78
import ActionsDropdownOrAction from '../../common/components/ActionsDropdownOrAction';
@@ -26,7 +27,7 @@ function renderEmailAction(email, title) {
2627

2728
const ACTION_TITLE = (
2829
<Tooltip title="Contact author">
29-
<Icon type="mail" />
30+
<MailOutlined />
3031
</Tooltip>
3132
);
3233

ui/src/authors/components/AuthorLinkedinAction.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
3-
import { Icon, Tooltip } from 'antd';
3+
import { LinkedinOutlined } from '@ant-design/icons';
4+
import { Tooltip } from 'antd';
45

56
import ListItemAction from '../../common/components/ListItemAction';
67
import ExternalLink from '../../common/components/ExternalLink';
@@ -13,7 +14,7 @@ class AuthorLinkedinAction extends Component {
1314
<ListItemAction>
1415
<Tooltip title="LinkedIn">
1516
<ExternalLink href={href}>
16-
<Icon type="linkedin" />
17+
<LinkedinOutlined />
1718
</ExternalLink>
1819
</Tooltip>
1920
</ListItemAction>

ui/src/authors/components/AuthorOrcid/AuthorOrcid.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ class AuthorOrcid extends Component {
1010
render() {
1111
const { orcid } = this.props;
1212
return (
13-
<Tooltip title="ORCID">
14-
<OrcidProfileLink className="__AuthorOrcid__" orcid={orcid}>
13+
<OrcidProfileLink className="__AuthorOrcid__" orcid={orcid}>
14+
<Tooltip title="ORCID">
1515
<img src={orcidLogo} alt="ORCID" />
16-
</OrcidProfileLink>
17-
</Tooltip>
16+
</Tooltip>
17+
</OrcidProfileLink>
1818
);
1919
}
2020
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`AuthorOrcid renders with orcid 1`] = `
4-
<Tooltip
5-
arrowPointAtCenter={false}
6-
autoAdjustOverflow={true}
7-
mouseEnterDelay={0.1}
8-
mouseLeaveDelay={0.1}
9-
placement="top"
10-
title="ORCID"
11-
transitionName="zoom-big-fast"
4+
<OrcidProfileLink
5+
className="__AuthorOrcid__"
6+
orcid="0000-0001-8058-0014"
127
>
13-
<OrcidProfileLink
14-
className="__AuthorOrcid__"
15-
orcid="0000-0001-8058-0014"
8+
<Tooltip
9+
arrowPointAtCenter={false}
10+
autoAdjustOverflow={true}
11+
mouseEnterDelay={0.1}
12+
mouseLeaveDelay={0.1}
13+
placement="top"
14+
title="ORCID"
15+
transitionName="zoom-big-fast"
1616
>
1717
<img
1818
alt="ORCID"
1919
src="orcid.svg"
2020
/>
21-
</OrcidProfileLink>
22-
</Tooltip>
21+
</Tooltip>
22+
</OrcidProfileLink>
2323
`;

0 commit comments

Comments
 (0)