Skip to content

issue 1355 fixed: Error displayed when user quickly deletes items fro… #1585

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 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export default function DeviceList(props) {
const {
deviceList,
onDeleteItem,
disabled,
} = props;

return (
<div styleName={`container ${deviceList.items.length > 0 ? 'active' : ''}`}>
<div styleName={`container ${deviceList.items.length > 0 ? 'active' : ''} ${disabled ? 'disabled' : ''}`}>
<ul>
{
deviceList.items.map((device, index) => (
Expand All @@ -34,4 +35,9 @@ export default function DeviceList(props) {
DeviceList.propTypes = {
deviceList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
disabled: PT.bool,
};

DeviceList.defaultProps = {
disabled: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
border-bottom: 1px solid $tc-gray-10;
}
}

&.disabled {
opacity: 0.7;
pointer-events: none;
user-select: none;
}
}
13 changes: 12 additions & 1 deletion src/shared/components/Settings/Tools/Devices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export default class Devices extends ConsentComponent {
const deviceItems = deviceTrait.traits
? deviceTrait.traits.data.slice() : [];
const { newDevice, formInvalid, errorMessage } = this.state;
const canModifyTrait = !this.props.traitRequestCount;

return (
<div styleName="devices-container">
Expand All @@ -290,7 +291,13 @@ export default class Devices extends ConsentComponent {
</div>
{
!isMobileView && deviceItems.length > 0
&& (<DeviceList deviceList={{ items: deviceItems }} onDeleteItem={this.onDeleteDevice} />)
&& (
<DeviceList
deviceList={{ items: deviceItems }}
onDeleteItem={this.onDeleteDevice}
disabled={!canModifyTrait}
/>
)
}
<div styleName={`sub-title ${deviceItems.length > 0 ? 'second' : 'first'}`}>
Add a new device
Expand Down Expand Up @@ -377,6 +384,7 @@ export default class Devices extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddDevice}
disabled={!canModifyTrait}
>
Add device to your list
</PrimaryButton>
Expand Down Expand Up @@ -445,6 +453,7 @@ export default class Devices extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddDevice}
disabled={!canModifyTrait}
>
Add Device
</PrimaryButton>
Expand All @@ -456,6 +465,7 @@ export default class Devices extends ConsentComponent {
<DeviceList
deviceList={{ items: deviceItems }}
onDeleteItem={this.onHandleDeleteDevice}
disabled={!canModifyTrait}
/>
)
}
Expand All @@ -467,6 +477,7 @@ export default class Devices extends ConsentComponent {
Devices.propTypes = {
tokenV3: PT.string.isRequired,
handle: PT.string.isRequired,
traitRequestCount: PT.number.isRequired,
userTraits: PT.array.isRequired,
addUserTrait: PT.func.isRequired,
updateUserTrait: PT.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export default function ServiceProviderList(props) {
const {
serviceProviderList,
onDeleteItem,
disabled,
} = props;

return (
<div styleName={`container ${serviceProviderList.items.length > 0 ? 'active' : ''}`}>
<div styleName={`container ${serviceProviderList.items.length > 0 ? 'active' : ''} ${disabled ? 'disabled' : ''}`}>
<ul>
{
serviceProviderList.items.map((serviceProvider, index) => (
Expand All @@ -31,4 +32,9 @@ export default function ServiceProviderList(props) {
ServiceProviderList.propTypes = {
serviceProviderList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
disabled: PT.bool,
};

ServiceProviderList.defaultProps = {
disabled: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
border-bottom: 1px solid $tc-gray-10;
}
}

&.disabled {
opacity: 0.7;
pointer-events: none;
user-select: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export default class ServiceProviders extends ConsentComponent {
const serviceProviderItems = serviceProviderTrait.traits
? serviceProviderTrait.traits.data.slice() : [];
const { newServiceProvider, formInvalid, errorMessage } = this.state;
const canModifyTrait = !this.props.traitRequestCount;

return (
<div styleName="service-provider-container">
Expand All @@ -261,6 +262,7 @@ export default class ServiceProviders extends ConsentComponent {
<ServiceProviderList
serviceProviderList={{ items: serviceProviderItems }}
onDeleteItem={this.onDeleteServiceProvider}
disabled={!canModifyTrait}
/>
)
}
Expand Down Expand Up @@ -305,6 +307,7 @@ export default class ServiceProviders extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddServiceProvider}
disabled={!canModifyTrait}
>
Add service provider to your list
</PrimaryButton>
Expand Down Expand Up @@ -345,6 +348,7 @@ export default class ServiceProviders extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddServiceProvider}
disabled={!canModifyTrait}
>
Add Provider
</PrimaryButton>
Expand All @@ -356,6 +360,7 @@ export default class ServiceProviders extends ConsentComponent {
<ServiceProviderList
serviceProviderList={{ items: serviceProviderItems }}
onDeleteItem={this.onHandleDeleteServiceProvider}
disabled={!canModifyTrait}
/>
)
}
Expand All @@ -367,6 +372,7 @@ export default class ServiceProviders extends ConsentComponent {
ServiceProviders.propTypes = {
tokenV3: PT.string.isRequired,
handle: PT.string.isRequired,
traitRequestCount: PT.number.isRequired,
userTraits: PT.array.isRequired,
addUserTrait: PT.func.isRequired,
updateUserTrait: PT.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export default function SoftwareList(props) {
const {
softwareList,
onDeleteItem,
disabled,
} = props;

return (
<div styleName={`container ${softwareList.items.length > 0 ? 'active' : ''}`}>
<div styleName={`container ${softwareList.items.length > 0 ? 'active' : ''} ${disabled ? 'disabled' : ''}`}>
<ul>
{
softwareList.items.map((software, index) => (
Expand All @@ -31,4 +32,9 @@ export default function SoftwareList(props) {
SoftwareList.propTypes = {
softwareList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
disabled: PT.bool,
};

SoftwareList.defaultProps = {
disabled: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
border-bottom: 1px solid $tc-gray-10;
}
}

&.disabled {
opacity: 0.7;
pointer-events: none;
user-select: none;
}
}
6 changes: 6 additions & 0 deletions src/shared/components/Settings/Tools/Software/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export default class Software extends ConsentComponent {
const softwareItems = softwareTrait.traits
? softwareTrait.traits.data.slice() : [];
const { newSoftware, formInvalid, errorMessage } = this.state;
const canModifyTrait = !this.props.traitRequestCount;

return (
<div styleName="software-container">
Expand All @@ -261,6 +262,7 @@ export default class Software extends ConsentComponent {
<SoftwareList
softwareList={{ items: softwareItems }}
onDeleteItem={this.onDeleteSoftware}
disabled={!canModifyTrait}
/>
)
}
Expand Down Expand Up @@ -305,6 +307,7 @@ export default class Software extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddSoftware}
disabled={!canModifyTrait}
>
Add software to your list
</PrimaryButton>
Expand Down Expand Up @@ -345,6 +348,7 @@ export default class Software extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddSoftware}
disabled={!canModifyTrait}
>
Add Software
</PrimaryButton>
Expand All @@ -356,6 +360,7 @@ export default class Software extends ConsentComponent {
<SoftwareList
softwareList={{ items: softwareItems }}
onDeleteItem={this.onHandleDeleteSoftware}
disabled={!canModifyTrait}
/>
)
}
Expand All @@ -367,6 +372,7 @@ export default class Software extends ConsentComponent {
Software.propTypes = {
tokenV3: PT.string.isRequired,
handle: PT.string.isRequired,
traitRequestCount: PT.number.isRequired,
userTraits: PT.array.isRequired,
addUserTrait: PT.func.isRequired,
updateUserTrait: PT.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export default function SubscriptionList(props) {
const {
subscriptionList,
onDeleteItem,
disabled,
} = props;

return (
<div styleName={`container ${subscriptionList.items.length > 0 ? 'active' : ''}`}>
<div styleName={`container ${subscriptionList.items.length > 0 ? 'active' : ''} ${disabled ? 'disabled' : ''}`}>
<ul>
{
subscriptionList.items.map((subscription, index) => (
Expand All @@ -31,4 +32,9 @@ export default function SubscriptionList(props) {
SubscriptionList.propTypes = {
subscriptionList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
disabled: PT.bool,
};

SubscriptionList.defaultProps = {
disabled: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
border-bottom: 1px solid $tc-gray-10;
}
}

&.disabled {
opacity: 0.7;
pointer-events: none;
user-select: none;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default class Subscription extends ConsentComponent {
const subscriptionItems = subscriptionTrait.traits
? subscriptionTrait.traits.data.slice() : [];
const { newSubscription, formInvalid, errorMessage } = this.state;
const canModifyTrait = !this.props.traitRequestCount;

return (
<div styleName="subscription-container">
Expand All @@ -251,6 +252,7 @@ export default class Subscription extends ConsentComponent {
<SubscriptionList
subscriptionList={{ items: subscriptionItems }}
onDeleteItem={this.onDeleteSubscription}
disabled={!canModifyTrait}
/>
)
}
Expand All @@ -275,6 +277,7 @@ export default class Subscription extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddSubscription}
disabled={!canModifyTrait}
>
Add subscription to your list
</PrimaryButton>
Expand All @@ -300,6 +303,7 @@ export default class Subscription extends ConsentComponent {
<PrimaryButton
styleName="complete"
onClick={this.onHandleAddSubscription}
disabled={!canModifyTrait}
>
Add Subscription
</PrimaryButton>
Expand All @@ -311,6 +315,7 @@ export default class Subscription extends ConsentComponent {
<SubscriptionList
subscriptionList={{ items: subscriptionItems }}
onDeleteItem={this.onHandleDeleteSubscription}
disabled={!canModifyTrait}
/>
)
}
Expand All @@ -322,6 +327,7 @@ export default class Subscription extends ConsentComponent {
Subscription.propTypes = {
tokenV3: PT.string.isRequired,
handle: PT.string.isRequired,
traitRequestCount: PT.number.isRequired,
userTraits: PT.array.isRequired,
addUserTrait: PT.func.isRequired,
updateUserTrait: PT.func.isRequired,
Expand Down
4 changes: 4 additions & 0 deletions src/shared/containers/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function mapStateToProps(state) {
loadingError: state.profile.loadingError,
settingsUI: state.page.ui.settings,
settings: state.settings,
traitRequestCount: state.settings.traitRequestCount,
userTraits: state.settings.userTraits,
skills: state.profile.skills,
};
Expand Down Expand Up @@ -215,16 +216,19 @@ function mapDispatchToProps(dispatch) {
dispatch(actions.settings.getAllUserTraits(handle, tokenV3));
},
addUserTrait: (handle, traitId, data, tokenV3) => {
dispatch(actions.settings.modifyUserTraitInit());
dispatch(actions.settings.addUserTrait(handle, traitId, data, tokenV3));
},
addUserSkill: (handle, skill, tokenV3) => {
dispatch(actions.profile.addSkillInit());
dispatch(actions.profile.addSkillDone(handle, tokenV3, _.assign(skill, { tagId: skill.id })));
},
updateUserTrait: (handle, traitId, data, tokenV3) => {
dispatch(actions.settings.modifyUserTraitInit());
dispatch(actions.settings.updateUserTrait(handle, traitId, data, tokenV3));
},
deleteUserTrait: (handle, traitId, tokenV3) => {
dispatch(actions.settings.modifyUserTraitInit());
dispatch(actions.settings.deleteUserTrait(handle, traitId, tokenV3));
},
deleteUserSkill: (handle, skill, tokenV3) => {
Expand Down