Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

address delete functionality #2128

Merged
merged 16 commits into from
Sep 19, 2016
Merged

address delete functionality #2128

merged 16 commits into from
Sep 19, 2016

Conversation

jacogr
Copy link
Contributor

@jacogr jacogr commented Sep 17, 2016

Functionality in action - https://www.youtube.com/watch?v=aQjHQsJFRso

Add the ability to delete (or rather mark addresses as deleted) for the address book. The same would and should apply for contracts (when we get there).

(We should be pulling in https://github.com/ethcore/parity/pull/2101 soon, since adding of addresses is completely broken atm, that branch fixes the functionality)

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. M-UI labels Sep 17, 2016
@parity-cla-bot
Copy link

It looks like this contributor signed our Contributor License Agreement. 👍

Many thanks,

Ethcore CLA Bot

@derhuerst
Copy link
Contributor

I'm not entirely happy with bf4b92c.

I get the idea of being able to easily switch between themes/ui frameworks. But is it really worth the abstraction? How often are we going to switch the UI theme? Does it make sense to abstract everything away into React components? I feel like this is making the code easier, but not simpler.

}
});
Object.keys(accountsInfo)
.map((address) => Object.assign({}, accountsInfo[address], { address }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Object.entries here? :)

.map((address) => Object.assign({}, accountsInfo[address], { address }))
.filter((account) => !account.meta.deleted)
.forEach((account) => {
if (account.uuid) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something here or does that not make sense? 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuid == null - it is an address
uuid != null - it is an account

We get one list of everything via personal_accountsInfo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering because the if and else blocks are the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lemme just check that again, they didn't used to be the same - I think I probably went only half-way with cleaning/simplifying things then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (account.uuid) {
          accounts[account.address] = account;
        } else {
          contacts[account.address] = account;
        }

One moves it to the accounts bucket, the others to the contacts bucket. (As soon as we have https://github.com/ethcore/parity/issues/2115 - there will probably be a contracts bucket as well)

return [
<Button
label={ labelNo || 'no' }
icon={ iconNo || <ContentClear /> }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor grumble here:

ContentClear will even get imported & bundled if never actually use it. Unfortunately having no default icon is not very consumer-friendly either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

export default from './confirmDialog';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too keep the code consistent and small pitfalls rare, I guess from './ConfirmDialog' is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are consistent everywhere here - have not been using uppercase names for class files. (Which is a slight departure from previous work, i.e. Signer/Status). Changing this one mens changing all.

]).isRequired,
visible: PropTypes.bool.isRequired,
onNo: PropTypes.func.isRequired,
onYes: PropTypes.func.isRequired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer onConfirm and something like onReject or onDeny here. It is more expressive than "yes" and "no". Same for labelYes and labelNo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

</div>
</div>
<div className={ styles.description }>
{ contact.meta.description || 'this is just some long description to make me feel happy about myself and to see what actually happens and just maybe we should throw some wrapping in here as well' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this fallback with something like "this contact has no description"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually removed that - it was for debug. Not sure why it is not in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

const { address } = this.props.params;
const contact = (contacts || {})[address];

this.toggleDeleteDialog();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this place, it always hides the delete dialog, so I'd prefer hideDeleteDialog & showDeleteDialog, as they're more expressive. Reading toggleDeleteDialog, I had to stop and actually figure out if it makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, can address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@derhuerst derhuerst added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 19, 2016
* js:
  use standard modal title functionality
  fix modal title size where no steps are available
  get adding addresses working again (context migration)
  fix merge conflict
  fix grumble
  use only one image for tokens, scale it (maps what is available when pulled form IMG meta in TokenReg)
  unknown image when none found for a token
  don't show tokens.value === 0 in transfer
  cater for the cases where the token doesn't have an image
  token images show up in Signer again
  with button images, trial header title updates
  add support for buttons
  fix calculation where transfer value is non-ETH
  IdentityIcon show up on the send button
  token icons show up in transaction list
  transaction list powered by

# Conflicts:
#	js/src/ui/ConfirmDialog/confirmDialog.css
#	js/src/ui/Modal/modal.js
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Sep 19, 2016
@derhuerst derhuerst added the A8-looksgood 🦄 Pull request is reviewed well. label Sep 19, 2016
@derhuerst derhuerst removed the A0-pleasereview 🤓 Pull request needs code review. label Sep 19, 2016
@jacogr jacogr merged commit 89cb76f into js Sep 19, 2016
}

if (different) {
if (JSON.stringify(this._lastInfo) !== JSON.stringify(info)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comparing to JSON.stringify()s is pretty dangerous. If the order of properties is different, this will fail. Also JSON.stringify is usually slower than deepStrictEqual implementations and it breaks with circular structures. JSON.stringify might also fail on objects with a prototype.

deep-equal is very lightweight.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will log an issue to swap.

@jacogr jacogr deleted the jg-address-delete branch September 19, 2016 13:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants