Skip to content

Commit 94d82bf

Browse files
[Bug Bash] Ca profile bug bash - 2 (#5838)
Second round of bug bash fixes
1 parent 64e3982 commit 94d82bf

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ workflows:
349349
filters:
350350
branches:
351351
only:
352-
- free
352+
- ca-profile-bug-bash
353353
# This is alternate dev env for parallel testing
354354
- "build-qa":
355355
context : org-global

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class ImageInput extends React.Component {
2525
this.state = {
2626
newBasicInfo: {},
2727
isImageOversize: false,
28+
isImageFile: true,
2829
};
2930
}
3031

@@ -72,6 +73,13 @@ export default class ImageInput extends React.Component {
7273
if (file === undefined) {
7374
return;
7475
}
76+
const allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
77+
if (!allowedTypes.includes(file.type)) {
78+
this.setState({
79+
isImageFile: false,
80+
});
81+
return;
82+
}
7583
if (file.size > 2 * 1024 * 1024) {
7684
// If file size is greater than 2 MB, show error message
7785
this.setState({
@@ -81,6 +89,7 @@ export default class ImageInput extends React.Component {
8189
}
8290
this.setState({
8391
isImageOversize: false,
92+
isImageFile: true,
8493
});
8594
uploadPhotoInit();
8695
loadImage.parseMetaData(file, (data) => {
@@ -126,7 +135,7 @@ export default class ImageInput extends React.Component {
126135
deletingPhoto,
127136
} = profileState;
128137

129-
const { newBasicInfo, isImageOversize } = this.state;
138+
const { newBasicInfo, isImageOversize, isImageFile } = this.state;
130139

131140
return (
132141
<div styleName="image">
@@ -157,7 +166,8 @@ export default class ImageInput extends React.Component {
157166
<input type="file" name="image" accept="image/*" onChange={this.onUploadPhoto} id="change-image-input" className="hidden" />
158167
</div>
159168
</div>
160-
{isImageOversize && <div styleName="error-message">Please select an image smaller than 2MB</div>}
169+
{!isImageFile && <div styleName="error-message">Please select jpg, jpeg or png image files only</div>}
170+
{isImageFile && isImageOversize && <div styleName="error-message">Please select an image smaller than 2MB</div>}
161171
</div>
162172
);
163173
}

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default class BasicInfo extends ConsentComponent {
4141

4242
const { userTraits } = props;
4343
this.state = {
44+
componentMounted: false,
4445
inputChanged: false,
4546
formInvalid: false,
4647
basicInfoTrait: this.loadBasicInfoTraits(userTraits),
@@ -81,6 +82,9 @@ export default class BasicInfo extends ConsentComponent {
8182
const { basicInfoTrait } = this.state;
8283
const basicInfo = basicInfoTrait.traits ? basicInfoTrait.traits.data[0] : {};
8384
this.processBasicInfo(basicInfo);
85+
this.setState({
86+
componentMounted: true,
87+
});
8488
}
8589

8690
componentWillReceiveProps(nextProps) {
@@ -461,6 +465,7 @@ export default class BasicInfo extends ConsentComponent {
461465
const {
462466
newBasicInfo,
463467
inputChanged,
468+
componentMounted,
464469
} = this.state;
465470

466471
const canModifyTrait = !this.props.traitRequestCount;
@@ -501,7 +506,7 @@ export default class BasicInfo extends ConsentComponent {
501506
<div styleName="field col-2">
502507
<span styleName="text-required">* Required</span>
503508
<input disabled={!canModifyTrait} id="firstName" name="firstName" type="text" placeholder="First Name" onChange={this.onUpdateInput} value={newBasicInfo.firstName} maxLength="64" required />
504-
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && inputChanged} message="First Name cannot be empty" />
509+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && componentMounted} message="First Name cannot be empty" />
505510
</div>
506511
</div>
507512
<div styleName="row">
@@ -514,7 +519,7 @@ export default class BasicInfo extends ConsentComponent {
514519
<div styleName="field col-2">
515520
<span styleName="text-required">* Required</span>
516521
<input disabled={!canModifyTrait} id="lastName" name="lastName" type="text" placeholder="Last Name" onChange={this.onUpdateInput} value={newBasicInfo.lastName} maxLength="64" required />
517-
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && inputChanged} message="Last Name cannot be empty" />
522+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && componentMounted} message="Last Name cannot be empty" />
518523
</div>
519524
</div>
520525
<div styleName="row">

0 commit comments

Comments
 (0)