Skip to content

[Bug Bash] Ca profile bug bash - round 3 #5904

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

Merged
merged 48 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c381f24
Enable Clear Date Input (#5809)
fikzzzy Nov 16, 2021
95e904b
Validate Non Valid Input Characters (#5810)
fikzzzy Nov 16, 2021
70dc4cf
ci:deploying
LieutenantRoger Nov 16, 2021
82552a8
fix: issue #5807 (#5811)
yoution Nov 17, 2021
665a385
fix: issue #5802 (#5812)
yoution Nov 17, 2021
b72fc3b
fix: issue #5796 (#5813)
yoution Nov 17, 2021
9f349ca
fix: #5798 (#5814)
shivam-51 Nov 18, 2021
2aa8c51
fix:5798-2
LieutenantRoger Nov 18, 2021
1d5a575
fix: test
LieutenantRoger Nov 18, 2021
d6c1225
fix: issue #5800 (#5816)
yoution Nov 18, 2021
8b4dc0b
fix: issue #5786 (#5815)
yoution Nov 18, 2021
aa9e173
fix: issue #5802 (#5823)
yoution Nov 19, 2021
55b5780
merge develop
LieutenantRoger Nov 19, 2021
33edc06
deploying ca-branch
LieutenantRoger Nov 19, 2021
a74ef92
revert ci
LieutenantRoger Nov 19, 2021
22885f3
revert device checking
LieutenantRoger Nov 22, 2021
7d1a129
merge develop
LieutenantRoger Nov 22, 2021
8f982db
patch: 5783
LieutenantRoger Nov 22, 2021
c4f60f4
Merge branch 'develop' into ca-profile-bug-bash
LieutenantRoger Nov 22, 2021
85d3cfd
Merge branch 'develop' into ca-profile-bug-bash
LieutenantRoger Nov 22, 2021
ceb5df6
fix: test
LieutenantRoger Nov 22, 2021
d51680d
fix: #5781 (#5824)
shivam-51 Nov 22, 2021
edba0cd
Merge branch 'develop' into ca-profile-bug-bash
LieutenantRoger Nov 23, 2021
529ade4
ci:deploying bug bash to test
LieutenantRoger Nov 23, 2021
3459429
fix: #5795 (#5837)
shivam-51 Nov 26, 2021
91da96b
refix
LieutenantRoger Nov 29, 2021
62c7f96
merge develop
LieutenantRoger Nov 29, 2021
7c72a2b
fix: safely parse input value for regex
CDharmateja Dec 1, 2021
044b68a
fix: issue #5885 (#5894)
gets0ul Dec 1, 2021
52fd7a6
update lint
LieutenantRoger Dec 1, 2021
55c3bb5
Merge branch 'review_5883' into ca-profile-bug-bash
LieutenantRoger Dec 1, 2021
5346e4d
fix: click on input down arrow (#5895)
CDharmateja Dec 1, 2021
9624b46
fix: issue #5874 - keep the order of existing languages after done ed…
gets0ul Dec 1, 2021
5aaf369
update: 5877
LieutenantRoger Dec 1, 2021
f4fca8c
update: 5875
LieutenantRoger Dec 1, 2021
978245e
Issue #5878 (#5893)
gets0ul Dec 1, 2021
36d36a7
update: 5899
LieutenantRoger Dec 1, 2021
4ee7fb5
update: 5868
LieutenantRoger Dec 1, 2021
a054043
update: 5867
LieutenantRoger Dec 1, 2021
9f6dbda
fix: make select clearable for spoken and written languages (#5898)
CDharmateja Dec 1, 2021
bfba9d7
Enable to Clear Date
fikzzzy Dec 2, 2021
8db9beb
Merge branch 'ca-profile-bug-bash' into review_5864
LieutenantRoger Dec 2, 2021
ce0eb0f
update lint
LieutenantRoger Dec 2, 2021
a1aac2e
Merge branch 'develop' into ca-profile-bug-bash
LieutenantRoger Dec 2, 2021
a80ecf3
fix: #5886 (#5901)
shivam-51 Dec 3, 2021
7f46f4b
refine
LieutenantRoger Dec 3, 2021
2fde8b7
update toggle item
LieutenantRoger Dec 4, 2021
fa2590f
debounce multiple switch
LieutenantRoger Dec 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/shared/components/InputSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class InputSelect extends Component {
let i = 0;
let node = e.target;
const REG = new RegExp(_id);
while (node && i < 5) {
while (node && i < 20) {
if (REG.test(node.className)) {
return true;
}
Expand All @@ -131,6 +131,7 @@ export default class InputSelect extends Component {
placeholder,
labelKey,
options,
onKeyPress,
} = this.props;

const {
Expand All @@ -139,9 +140,10 @@ export default class InputSelect extends Component {
filterVal,
} = this.state;

const escapeRegExp = stringToGoIntoTheRegex => stringToGoIntoTheRegex.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); /* eslint-disable-line no-useless-escape */
let fiterList = options;
if (filterVal) {
const REG = new RegExp(filterVal, 'i');
const REG = new RegExp(escapeRegExp(filterVal), 'i');
fiterList = filter(options, o => REG.test(o[labelKey]));
}
const list = map(fiterList, o => (
Expand Down Expand Up @@ -171,7 +173,7 @@ export default class InputSelect extends Component {
<div styleName="modal">
<div styleName="modal-input-container">

<input type="text" onChange={this.onFilterChange} placeholder="Search" />
<input type="text" onChange={this.onFilterChange} placeholder="Search" onKeyPress={onKeyPress} />
</div>
<div styleName="modal-list-container" onScroll={this.onLoadMore}>
{list}
Expand All @@ -195,6 +197,7 @@ InputSelect.defaultProps = {
isLoading: false,
onChange: () => {},
onLoadMore: () => {},
onKeyPress: () => {},
};

InputSelect.propTypes = {
Expand All @@ -205,6 +208,7 @@ InputSelect.propTypes = {
placeholder: PT.string,
onChange: PT.func,
onLoadMore: PT.func,
onKeyPress: PT.func,
hasMore: PT.bool,
isLoading: PT.bool,
disabled: PT.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export default class MyAccount extends ConsentComponent {
</div>
</div>
{
get(profileState, 'credential.hasPassword', false) === false && (
get(profileState, 'credential.hasPassword') === false && (
<div styleName="error-message">
Since you joined Topcoder using your &lt;SSO Service&gt; account,
any email updates will need to be handled by logging in to
Expand Down
28 changes: 19 additions & 9 deletions src/shared/components/Settings/Preferences/Email/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ const programs = [

export default class EmailPreferences extends React.Component {
saveEmailPreferences = debounce((id, checked) => {
// update local state
const { emailPreferences, status } = this.state;
emailPreferences[id] = checked;
this.setState({
emailPreferences,
status: checked ? 'subscribed' : status,
});
const { email, saveEmailPreferences } = this.props;
saveEmailPreferences(email, id, checked);
}, SAVE_DELAY);
Expand All @@ -93,19 +100,22 @@ export default class EmailPreferences extends React.Component {
}
const { emailPreferences, status } = this.state;
const { id, checked } = updated;
emailPreferences[id] = checked;
if (emailPreferences[id] !== checked) {
emailPreferences[id] = checked;

// eslint-disable-next-line react/no-did-update-set-state
this.setState({
emailPreferences,
status: updated.resubscribe ? 'subscribed' : status,
});
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
emailPreferences,
status: updated.resubscribe ? 'subscribed' : status,
});
}
toastrSuccess('Success! ', 'Your email preferences were updated.');
}
}

onChange(id, checked) {
document.querySelectorAll(`#pre-onoffswitch-${id}`).forEach((el) => { el.checked = checked; }); // eslint-disable-line no-param-reassign
// document.querySelectorAll(`#pre-onoffswitch-${id}`).forEach((el) => { el.checked = checked; }); // eslint-disable-line no-param-reassign
// update remote state
this.saveEmailPreferences(id, checked);
}

Expand Down Expand Up @@ -144,7 +154,7 @@ export default class EmailPreferences extends React.Component {
checked={checked}
primaryText={newsletter.name}
secondaryText={newsletter.desc}
onToggle={e => this.onChange(newsletter.id, e.target.checked)}
onToggle={c => this.onChange(newsletter.id, c)}
disabled={status !== 'subscribed'}
/>
);
Expand All @@ -164,7 +174,7 @@ export default class EmailPreferences extends React.Component {
checked={checked}
primaryText={program.name}
secondaryText={program.desc}
onToggle={e => this.onChange(program.id, e.target.checked)}
onToggle={c => this.onChange(program.id, c)}
disabled={status !== 'subscribed'}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
* Personalization component.
*/
import React from 'react';
import { debounce } from 'lodash';

import PT from 'prop-types';

import ToggleableItem from 'components/Settings/ToggleableItem';

import './styles.scss';

const SAVE_DELAY = 1000;

export default function Personalization({
addUserTrait,
handle,
Expand Down Expand Up @@ -51,6 +55,10 @@ export default function Personalization({
}
};

const debounceUpdateConsent = debounce(() => {
updateConsent();
}, SAVE_DELAY);

return (
<div styleName="Personalization">
<div styleName="user-consent-container">
Expand All @@ -60,7 +68,7 @@ export default function Personalization({
checked={getUserConsent()}
primaryText={primaryText}
secondaryText={secondaryText}
onToggle={updateConsent}
onToggle={debounceUpdateConsent}
/>
</div>
</div>
Expand Down
22 changes: 17 additions & 5 deletions src/shared/components/Settings/Profile/Language/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ export default class Language extends ConsentComponent {
const newLanguageTrait = _.cloneDeep(languageTrait);

if (isEdit) {
newLanguageTrait.traits.data.splice(indexNo, 1);
newLanguageTrait.traits.data.splice(indexNo, 1, language);
} else {
newLanguageTrait.traits.data.push(language);
}

newLanguageTrait.traits.data.push(language);

updateUserTrait(handle, 'languages', newLanguageTrait.traits.data, tokenV3);
} else {
const newLanguages = [];
Expand Down Expand Up @@ -441,7 +441,13 @@ export default class Language extends ConsentComponent {
<Select
name="spokenLevel"
options={dropdowns.spokenLevel}
onChange={this.onUpdateSelect}
onChange={(option) => {
if (option) {
this.onUpdateSelect(option);
} else {
this.onUpdateSelect({ key: 'spokenLevel', name: '' });
}
}}
value={newLanguage.spokenLevel}
placeholder="Spoken level"
labelKey="name"
Expand All @@ -461,7 +467,13 @@ export default class Language extends ConsentComponent {
<Select
name="writtenLevel"
options={dropdowns.writtenLevel}
onChange={this.onUpdateSelect}
onChange={(option) => {
if (option) {
this.onUpdateSelect(option);
} else {
this.onUpdateSelect({ key: 'writtenLevel', name: '' });
}
}}
value={newLanguage.writtenLevel}
placeholder="Written level"
labelKey="name"
Expand Down
28 changes: 22 additions & 6 deletions src/shared/components/Settings/Profile/Work/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ export default class Work extends ConsentComponent {
}

onUpdateDate(date, timePeriod) {
if (date) {
const { newWork: oldWork } = this.state;
const newWork = { ...oldWork };
newWork[timePeriod] = date;
this.setState({ newWork, isSubmit: false });
}
const { newWork: oldWork } = this.state;
const newWork = { ...oldWork };
newWork[timePeriod] = date;
this.setState({ newWork, isSubmit: false });
}

/**
Expand Down Expand Up @@ -174,6 +172,16 @@ export default class Work extends ConsentComponent {

this.setState({
showConfirmation: false,
newWork: {
company: '',
position: '',
cityTown: '',
timePeriodFrom: '',
timePeriodTo: '',
industry: '',
working: false,
},
isEdit: false,
indexNo: null,
isSubmit: false,
formInvalid: false,
Expand Down Expand Up @@ -482,11 +490,13 @@ export default class Work extends ConsentComponent {
<div styleName="field col-2">
<DatePicker
readOnly
showClearDate
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodFrom}
id="date-from1"
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')} // eslint-disable-line no-unused-vars
placeholder="dd/mm/yyyy"
/>
{
Expand All @@ -509,12 +519,14 @@ export default class Work extends ConsentComponent {
<div styleName="field col-2">
<DatePicker
readOnly
showClearDate
disabled={endDateDisabled}
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodTo}
id="date-to1"
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')} // eslint-disable-line no-unused-vars
placeholder="dd/mm/yyyy"
/>
{
Expand Down Expand Up @@ -633,11 +645,13 @@ export default class Work extends ConsentComponent {
</label>
<DatePicker
readOnly
showClearDate
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodFrom}
id="date-from2"
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')} // eslint-disable-line no-unused-vars
placeholder="dd/mm/yyyy"
/>
{
Expand All @@ -656,12 +670,14 @@ export default class Work extends ConsentComponent {
</label>
<DatePicker
readOnly
showClearDate
disabled={endDateDisabled}
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodTo}
id="date-to2"
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')} // eslint-disable-line no-unused-vars
placeholder="dd/mm/yyyy"
/>
{
Expand Down
14 changes: 14 additions & 0 deletions src/shared/components/Settings/Profile/Work/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,20 @@ label {
display: none;
}
}

:global {
.SingleDatePickerInput_clearDate {
height: 35px;
width: 35px;
display: flex;
align-items: center;
top: calc(50% - 5px);
}

.SingleDatePickerInput__showClearDate {
padding-right: 0;
}
}
}

.button-container {
Expand Down
22 changes: 19 additions & 3 deletions src/shared/components/Settings/ToggleableItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* text, a gray secondary text and a toggle that triggers a function
* passed via props.
*/
import React from 'react';
import React, { useRef } from 'react';
import PT from 'prop-types';
import ReactHtmlParser from 'react-html-parser';

Expand All @@ -20,6 +20,20 @@ export default function ToggleableItem({
value,
disabled,
}) {
const inputRef = useRef();
const inputMobileRef = useRef();

const onChange = () => {
if (inputRef.current) {
inputRef.current.checked = !inputRef.current.checked;
onToggle(inputRef.current.checked);
}
if (inputMobileRef.current) {
inputMobileRef.current.checked = !inputMobileRef.current.checked;
onToggle(inputMobileRef.current.checked);
}
};

return (
<div styleName="ToggleableItem">
<div styleName="body">
Expand All @@ -32,12 +46,13 @@ export default function ToggleableItem({
</div>
<div className="onoffswitch" styleName="onoffswitch-no-padding-right">
<input
ref={inputRef}
type="checkbox"
name="eprf-onoffswitch"
id={`pre-onoffswitch-${id}`}
value={value}
checked={checked}
onChange={onToggle}
onChange={onChange}
className="onoffswitch-checkbox"
disabled={disabled}
/>
Expand All @@ -49,12 +64,13 @@ export default function ToggleableItem({
</div>
<div className="onoffswitch-mobile" styleName="onoffswitch-no-padding-right">
<input
ref={inputMobileRef}
type="checkbox"
name="eprf-onoffswitch"
id={`pre-onoffswitch-${id}`}
value={value}
checked={checked}
onChange={onToggle}
onChange={onChange}
className="onoffswitch-checkbox"
disabled={disabled}
/>
Expand Down
Loading