-
Notifications
You must be signed in to change notification settings - Fork 65
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
Conversation
this.reset() | ||
}) | ||
this.props.onSend(recipients, sharingType) | ||
this.reset() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- we execute
onSend
by passingrecipients
andsharingType
- we execute the asynchronous fetch that creates the sharing
- we reset the field
- 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.
So far so good! |
Awaiting cozy/cozy-stack#1130 |
There was a problem hiding this 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.
src/drive/locales/en.json
Outdated
@@ -55,7 +55,7 @@ | |||
"revoked": "Error" | |||
}, | |||
"type": { | |||
"one-way": "Can View", | |||
"one-way": "Can View (coming soon)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@y-lohse don't forget to update https://www.transifex.com/cozy/cozy-drive/translate/#fr/global/130398143?key=one-way
src/sharing/share.styl
Outdated
@@ -11,6 +11,9 @@ | |||
cursor pointer | |||
|
|||
:local | |||
.share-modal | |||
max-width 33rem !important // waiting for modal size presets in cozy-ui |
There was a problem hiding this comment.
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 🍆
src/sharing/share.styl
Outdated
padding 1rem 0 | ||
|
||
select | ||
flex 0 0 49% |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() | ||
// }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should remove a43e28e#diff-e56633f72ecc521128b3db6586074d2cR9.
event.key === 'Enter' || | ||
(event.keyCode === 13 && this.state.inputValue !== '') || | ||
(event.key === 'Space' || | ||
(event.keyCode === 32 && /^.+@.+/.test(this.state.inputValue))) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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`, { |
There was a problem hiding this comment.
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.
but still need a real implementation
like it is done on #652
generated from commit f2a77e5
Multiple changes to feat the new cozy-stack share API.