Skip to content

Commit 37ead4b

Browse files
committed
Merge branch 'new-develop' into f2f-30069264-issue-894
2 parents 92e1eeb + fb7a9dc commit 37ead4b

File tree

49 files changed

+2556
-113
lines changed

Some content is hidden

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

49 files changed

+2556
-113
lines changed

__tests__/shared/components/Settings/Profile/ExternalLinks/__snapshots__/index.jsx.snap

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,39 @@ exports[`renders external links section of profile setting page correctly 1`] =
2626
</div>
2727
<AddWebLink
2828
addWebLink={[Function]}
29+
allLinks={
30+
Array [
31+
Object {
32+
"data": Object {
33+
"handle": "tcscoder",
34+
},
35+
"providerType": "github",
36+
"status": "pending",
37+
},
38+
Object {
39+
"data": Object {
40+
"handle": "1233342",
41+
},
42+
"providerType": "stackoverflow",
43+
"status": "pending",
44+
},
45+
Object {
46+
"URL": "https://www.google.com",
47+
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
48+
"entities": null,
49+
"handle": "tcscoder",
50+
"images": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png",
51+
"key": "4c7136cdbbf227274e49c475e7541abf",
52+
"keywords": null,
53+
"providerType": "weblink",
54+
"source": "embed.ly",
55+
"status": "linked",
56+
"synchronizedAt": 1525560141959,
57+
"title": "Google",
58+
"userId": 22655076,
59+
},
60+
]
61+
}
2962
deleteWebLink={[Function]}
3063
handle=""
3164
linkExternalAccount={[Function]}

__tests__/shared/components/__snapshots__/Content.jsx.snap

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,20 @@ exports[`Matches shallow shapshot 1`] = `
263263
/members/:handle
264264
</code>
265265
266-
endpoint. Valid link on dev
267-
266+
endpoint. Valid links on dev:
267+
<br />
268268
<Link
269269
replace={false}
270270
to="/members/TonyJ"
271271
>
272-
here.
272+
Profile 1.
273+
</Link>
274+
<br />
275+
<Link
276+
replace={false}
277+
to="/members/mess"
278+
>
279+
Profile 2.
273280
</Link>
274281
</li>
275282
<li>
Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading

src/shared/components/Content/index.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ Member Programs Page
250250
</code>
251251
{' '}
252252
endpoint.
253-
Valid link on dev
254-
{' '}
253+
Valid links on dev:
254+
<br />
255255
<Link to="/members/TonyJ">
256-
here.
256+
Profile 1.
257+
</Link>
258+
<br />
259+
<Link to="/members/mess">
260+
Profile 2.
257261
</Link>
258262
</li>
259263
<li>

src/shared/components/ProfilePage/Stats/DistributionGraph/index.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class DistributionGraph extends React.Component {
3737
constructor(props) {
3838
super(props);
3939
this.state = {};
40+
this.mobileWidth = 0;
4041
this.graphRef = React.createRef();
4142
}
4243

@@ -45,7 +46,9 @@ export default class DistributionGraph extends React.Component {
4546
$scope.desktop = window.innerWidth >= 900;
4647
this.draw();
4748
this.resizeHandle = () => {
48-
if (window.innerWidth < 900 && $scope.desktop) {
49+
if (window.innerWidth < 900
50+
&& ($scope.desktop
51+
|| (this.mobileWidth !== DistributionGraph.getMobileWidthGrapthMeasurements()))) {
4952
$scope.desktop = false;
5053
this.draw();
5154
} else if (window.innerWidth >= 900 && !$scope.desktop) {
@@ -67,6 +70,13 @@ export default class DistributionGraph extends React.Component {
6770
window.removeEventListener('resize', this.resizeHandle);
6871
}
6972

73+
static getMobileWidthGrapthMeasurements() {
74+
if (window.innerWidth < 400) {
75+
return 250;
76+
}
77+
return 370;
78+
}
79+
7080
draw() {
7181
const $scope = this;
7282
const { distribution: wrapper, rating } = this.props;
@@ -87,7 +97,7 @@ export default class DistributionGraph extends React.Component {
8797
};
8898

8999
const mobileMeasurements = {
90-
w: 370,
100+
w: 0,
91101
h: 200,
92102
padding: {
93103
top: 50,
@@ -98,7 +108,12 @@ export default class DistributionGraph extends React.Component {
98108
};
99109

100110
d3.select($scope.graphRef.current).select('svg').remove();
101-
const { w, h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
111+
let { w } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
112+
const { h, padding } = $scope.desktop ? desktopMeasurements : mobileMeasurements;
113+
if (!$scope.desktop) {
114+
w = DistributionGraph.getMobileWidthGrapthMeasurements();
115+
this.mobileWidth = w;
116+
}
102117
const totalW = w + padding.left + padding.right;
103118
const totalH = h + padding.top + padding.bottom;
104119

src/shared/components/Settings/Account/LinkedAccount/AddWebLink.jsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
/* eslint-disable jsx-a11y/label-has-for */
55
import React from 'react';
6+
import _ from 'lodash';
67
import PT from 'prop-types';
78

89
import './styles.scss';
@@ -17,6 +18,7 @@ export default class AddWebLink extends React.Component {
1718
this.onUpdateWebLink = this.onUpdateWebLink.bind(this);
1819
this.onAddWebLink = this.onAddWebLink.bind(this);
1920
this.isWebLinkValid = this.isWebLinkValid.bind(this);
21+
this.isWebLinkExist = this.isWebLinkExist.bind(this);
2022
}
2123

2224
componentWillReceiveProps(nextProps) {
@@ -43,7 +45,7 @@ export default class AddWebLink extends React.Component {
4345
tokenV3,
4446
} = this.props;
4547
const { webLink } = this.state;
46-
if (webLink && this.isWebLinkValid()) {
48+
if (webLink && this.isWebLinkValid() && !this.isWebLinkExist()) {
4749
addWebLink(handle, tokenV3, webLink);
4850
}
4951
}
@@ -54,10 +56,19 @@ export default class AddWebLink extends React.Component {
5456
return !webLink || ((webLink.split('.').length > 2) && /^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,15})+(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=]*)?$/.test(webLink)); /* eslint-disable-line no-useless-escape */
5557
}
5658

59+
isWebLinkExist() {
60+
const { webLink } = this.state;
61+
const {
62+
allLinks,
63+
} = this.props;
64+
return _.some(allLinks, link => link.URL.toLowerCase() === webLink.toLowerCase());
65+
}
66+
5767
render() {
5868
const { webLink } = this.state;
5969

6070
const webLinkValid = this.isWebLinkValid();
71+
const isWebLinkExist = this.isWebLinkExist();
6172

6273
return (
6374
<div styleName="external-web-link">
@@ -83,7 +94,7 @@ export default class AddWebLink extends React.Component {
8394
required
8495
/>
8596
{
86-
!webLinkValid
97+
!webLinkValid && !isWebLinkExist
8798
&& (
8899
<div styleName="form-input-error">
89100
<p>
@@ -92,6 +103,16 @@ Please enter a valid URL
92103
</div>
93104
)
94105
}
106+
{
107+
isWebLinkExist
108+
&& (
109+
<div styleName="form-input-error">
110+
<p>
111+
{`The URL ${webLink} already exists`}
112+
</p>
113+
</div>
114+
)
115+
}
95116
</div>
96117
</form>
97118
</div>
@@ -100,9 +121,14 @@ Please enter a valid URL
100121
}
101122
}
102123

124+
AddWebLink.defaultProps = {
125+
allLinks: [],
126+
};
127+
103128
AddWebLink.propTypes = {
104129
handle: PT.string.isRequired,
105130
tokenV3: PT.string.isRequired,
106131
profileState: PT.shape().isRequired,
107132
addWebLink: PT.func.isRequired,
133+
allLinks: PT.arrayOf(PT.shape),
108134
};

src/shared/components/Settings/Account/LinkedAccount/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export default function LinkedAccount(props) {
154154
</h1>
155155
<AddWebLink
156156
{...props}
157+
allLinks={allLinks}
157158
/>
158159
<LinkAccounts
159160
{...props}

src/shared/components/Settings/Account/LinkedAccount/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
form {
1313
display: flex;
1414
flex-direction: column;
15+
min-height: 60px;
1516

1617
label {
1718
@include roboto-medium;

src/shared/components/Settings/Profile/BasicInfo/Track/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default function Track({
3737
</div>
3838
</div>
3939
</div>
40-
<div className="onoffswitch" styleName="onoffswitch-no-padding-right">
40+
<div styleName="onoffswitch-no-padding-right">
4141
<input
4242
type="checkbox"
4343
name="eprf-onoffswitch"

src/shared/components/Settings/Profile/BasicInfo/Track/styles.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
@import "~styles/mixins";
22

3+
@mixin switch-transition {
4+
transition: all 0.15s ease-in-out;
5+
}
6+
7+
$switch-active-color: $tc-dark-blue-110;
8+
$switch-inactive-color: $tc-gray-20;
9+
$switch-width: 34px;
10+
$switch-height: 20px;
11+
312
.track-container {
413
display: flex;
514
flex-direction: row;
@@ -57,4 +66,17 @@
5766
.onoffswitch-no-padding-right {
5867
margin-right: 10px;
5968
margin-left: 30px;
69+
70+
@include switch-transition;
71+
72+
align-self: center;
73+
background-color: $switch-inactive-color;
74+
border-radius: $switch-height;
75+
box-sizing: border-box;
76+
height: $switch-height;
77+
width: $switch-width;
78+
position: relative;
79+
-webkit-user-select: none;
80+
-moz-user-select: none;
81+
-ms-user-select: none;
6082
}

0 commit comments

Comments
 (0)