Skip to content

Commit aa165d8

Browse files
committed
device page fixd some issues
1 parent 5d99620 commit aa165d8

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

src/shared/components/Settings/Tools/Devices/List/Item/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import _ from 'lodash';
55
import React from 'react';
66
import PT from 'prop-types';
77
import ReactSVG from 'react-svg';
8+
import cn from 'classnames';
89
import { isomorphy } from 'topcoder-react-utils';
910

1011
import './styles.scss';
@@ -18,6 +19,7 @@ export default function Item(props) {
1819
const {
1920
device,
2021
index,
22+
isEditing,
2123
onDeleteItem,
2224
onEditItem,
2325
} = props;
@@ -27,7 +29,7 @@ export default function Item(props) {
2729
+ (device.operatingSystem ? ` | ${device.operatingSystem}` : '');
2830

2931
return (
30-
<div styleName="container">
32+
<div styleName={cn('container', { isEditing })}>
3133
<div styleName="device-info">
3234
<div styleName="device-icon">
3335
{ assets && assets.keys().includes(`./${device.deviceType.toLowerCase()}.svg`) ? <ReactSVG path={assets(`./${device.deviceType.toLowerCase()}.svg`)} /> : '' }
@@ -76,6 +78,7 @@ export default function Item(props) {
7678
Item.propTypes = {
7779
device: PT.shape().isRequired,
7880
index: PT.number.isRequired,
81+
isEditing: PT.bool.isRequired,
7982
onDeleteItem: PT.func.isRequired,
8083
onEditItem: PT.func.isRequired,
8184
};

src/shared/components/Settings/Tools/Devices/List/Item/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
border: 1px solid $tc-gray-10;
1313
border-bottom: none;
1414
background-color: $tc-white;
15+
16+
&.isEditing {
17+
border: 1px solid $tc-gray-75;
18+
}
1519
}
1620

1721
.device-info {

src/shared/components/Settings/Tools/Devices/List/index.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default function DeviceList(props) {
1313
onDeleteItem,
1414
disabled,
1515
onEditItem,
16+
indexNo,
1617
} = props;
1718

1819
return (
@@ -24,6 +25,7 @@ export default function DeviceList(props) {
2425
? (
2526
<li key={`${device.deviceType}${index + 1}`}>
2627
<Item
28+
isEditing={indexNo === index}
2729
device={device}
2830
index={index}
2931
onDeleteItem={onDeleteItem}
@@ -43,8 +45,10 @@ DeviceList.propTypes = {
4345
onDeleteItem: PT.func.isRequired,
4446
onEditItem: PT.func.isRequired,
4547
disabled: PT.bool,
48+
indexNo: PT.number,
4649
};
4750

4851
DeviceList.defaultProps = {
4952
disabled: false,
53+
indexNo: null,
5054
};

src/shared/components/Settings/Tools/Devices/index.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export default class Devices extends ConsentComponent {
179179
tokenV3,
180180
updateUserTrait,
181181
addUserTrait,
182+
clearDeviceState,
182183
} = this.props;
183184
const {
184185
deviceTrait,
@@ -217,6 +218,7 @@ export default class Devices extends ConsentComponent {
217218
indexNo: null,
218219
isSubmit: false,
219220
});
221+
clearDeviceState();
220222
// save personalization
221223
if (_.isEmpty(personalizationTrait)) {
222224
const personalizationData = { userConsent: answer };
@@ -379,6 +381,7 @@ export default class Devices extends ConsentComponent {
379381
}
380382

381383
onCancelEditStatus() {
384+
const { clearDeviceState } = this.props;
382385
const { isEdit } = this.state;
383386
if (isEdit) {
384387
this.setState({
@@ -393,6 +396,7 @@ export default class Devices extends ConsentComponent {
393396
operatingSystem: '',
394397
},
395398
});
399+
clearDeviceState();
396400
}
397401
}
398402

@@ -443,6 +447,7 @@ export default class Devices extends ConsentComponent {
443447
<DeviceList
444448
deviceList={{ items: deviceItems }}
445449
onDeleteItem={this.onHandleDeleteDevice}
450+
indexNo={indexNo}
446451
disabled={!canModifyTrait}
447452
onEditItem={this.onEditDevice}
448453
/>
@@ -713,6 +718,7 @@ export default class Devices extends ConsentComponent {
713718
&& (
714719
<DeviceList
715720
deviceList={{ items: deviceItems }}
721+
indexNo={indexNo}
716722
onDeleteItem={this.onHandleDeleteDevice}
717723
disabled={!canModifyTrait}
718724
onEditItem={this.onEditDevice}

src/shared/containers/Settings.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ function mapDispatchToProps(dispatch) {
180180
dispatch(lookupActions.getTypesInit());
181181
dispatch(lookupActions.getTypesDone());
182182
},
183+
clearDeviceState: () => {
184+
// reset manufacturers, models, oses
185+
dispatch(lookupActions.getManufacturersInit());
186+
},
183187
getManufacturers: (type) => {
184188
dispatch(lookupActions.getManufacturersInit());
185189
dispatch(lookupActions.getManufacturersDone(type));

0 commit comments

Comments
 (0)