Skip to content
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

fix: adapt share process with new stack #653

Merged
merged 13 commits into from
Jan 9, 2018
Merged

fix: adapt share process with new stack #653

merged 13 commits into from
Jan 9, 2018

Conversation

enguerran
Copy link
Contributor

@enguerran enguerran commented Dec 22, 2017

Multiple changes to feat the new cozy-stack share API.
tir-sharemodal

@enguerran enguerran changed the title fix: adapt share process with new stack [WI] fix: adapt share process with new stack Dec 22, 2017
@enguerran enguerran changed the title [WI] fix: adapt share process with new stack [WIP] fix: adapt share process with new stack Dec 22, 2017
@enguerran
Copy link
Contributor Author

this.reset()
})
this.props.onSend(recipients, sharingType)
this.reset()
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you removed the catch here, isn't there a chance that this.props.onSend results in an exception and stops the execution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well seen.
If fact removing catch is not the only thing I removed. props.onSend is not a promise anymore. It executes share from whom I removed the return as it did not return anything but where used to return a empty promise that let this very function sendSharingLink executing this.reset() on then or on catch.

As reseting the input field is not related to the resolve of the promise (then or catch) and as the animation is not critical here, I simplify the code:

  1. we execute onSend by passing recipients and sharingType
  2. we execute the asynchronous fetch that creates the sharing
  3. we reset the field
  4. once the sharing fetch is terminated, the ShareByEmailWrapper will alert an info or an error.

Note: I will maybe merge those two components as I don't understand which one is responsible of what.

@y-lohse
Copy link
Contributor

y-lohse commented Dec 22, 2017

So far so good!

@enguerran
Copy link
Contributor Author

New share modal with no tabs but 2 sections:

Autosuggest contacts

Recipient chip

Special case 1

Special case 2

Special case 2 for file

@enguerran
Copy link
Contributor Author

Awaiting cozy/cozy-stack#1130

@enguerran
Copy link
Contributor Author

enguerran commented Dec 28, 2017

Un autre visuel quand on a beaucoup de destinataire

Copy link
Contributor Author

@enguerran enguerran left a comment

Choose a reason for hiding this comment

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

I will not request changes strictly speaking, but it will be very nice to take those below comments into account.

@@ -55,7 +55,7 @@
"revoked": "Error"
},
"type": {
"one-way": "Can View",
"one-way": "Can View (coming soon)",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -11,6 +11,9 @@
cursor pointer

:local
.share-modal
max-width 33rem !important // waiting for modal size presets in cozy-ui
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is not really clean.
I discussed with people about this and I told them that it is not third-app risponsibility.

There is a reason we build an UI library.
If this is important, then we should release a brand new version of the library with "size presets".

That said, the commit message is really fun 🍆

padding 1rem 0

select
flex 0 0 49%
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 am not sure 49% is the best way to add space between two elements.

@@ -1,6 +1,5 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

import { Button } from 'cozy-ui/react'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Must be git squashed or git fixed with the commit that inserts the lint error.

@@ -397,7 +397,7 @@ const getDocumentActiveSharings = (state, doctype, id) => {
perm => perm.attributes.permissions.files.values.indexOf(id) !== -1
),
...perms.withMe.filter(
perm => perm.attributes.permissions.files.values.indexOf(id) !== -1
perm => perm.attributes.permissions.rule0.values.indexOf(id) !== -1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rule0 is a very bad name we should change.

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 cannot understand if something is wrong when I read on line 397 perm.attributes.permissions.files.values and 3 lines after (line 400) in the exact same scope perm.attributes.permissions.rule0.values.

Same appears on line 412 p.attributes.permissions.rule0 with line 411 p.attributes.permissions.files and line 413 p.attributes.permissions[type]. It is very confusing.

// even with the `shippedProposals` option to babel-preset-env
// .finally(() => {
// this.reset()
// })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

event.key === 'Enter' ||
(event.keyCode === 13 && this.state.inputValue !== '') ||
(event.key === 'Space' ||
(event.keyCode === 32 && /^.+@.+/.test(this.state.inputValue)))
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 shall add , too as it is an enumeration.

/>
>
<Icon icon="cross" width="16" height="16" />
</button>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better this way. Thanks.

((event.key === 'Enter' || event.keyCode === 13) &&
this.state.inputValue !== '') ||
((event.key === 'Space' || event.keyCode === 32) &&
/^.+@.+/.test(this.state.inputValue))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shall be fixed or squashed with the previous commit, if not in the really first commit that implies this file.

email: recipients[0].id
? getPrimaryEmail(recipients[0])
: recipients[0].email
})
} else {
Alerter.info(`${documentType}.share.shareByEmail.genericSuccess`, {
Alerter.success(`${documentType}.share.shareByEmail.genericSuccess`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be squashed or fixed in the previous commit from this PR that introduces the alerter.

@enguerran enguerran changed the title [WIP] fix: adapt share process with new stack fix: adapt share process with new stack Jan 9, 2018
@enguerran enguerran merged commit f2a77e5 into cozy:master Jan 9, 2018
@enguerran enguerran deleted the feat.share branch January 9, 2018 09:29
cozycloud pushed a commit that referenced this pull request Jan 9, 2018
@enguerran enguerran mentioned this pull request Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants