getmeli / meli

Platform for deploying static sites and frontend applications easily. Automatic SSL, deploy previews, reverse proxy, and more.
Other
2.4k stars 97 forks source link

Display Invitation Link #247

Open mtiller opened 2 years ago

mtiller commented 2 years ago

I understand from #224 and various other tickets that there are issues with mailing out links and making sure you are authenticated before accepting the invitation. But another useful and related feature would be to display the link on the "Staff" page. This would eliminate the need to even have a mail server because the admin could add a person and then send them the link directly (e.g., via a Teams channel or something).

In one of the issues, they mention that if you don't have a mail server it will print the email or invite to stdout. I didn't see that.

Is there a reason not to display the invite link on that screen? It appears that the URL for the invite is a simple template involving the token. The token is stored in the database. But when a query is made for invitations, the payload doesn't include the link. Since only "admins or owners" can get a list of invites, why not return the url (or at least the token) in the serialized payload? Then, you could just include it here in the UI.

I'm trying to figure out if this was done deliberately or whether you would accept a PR for this functionality (since it seems like just a few lines of non-breaking changes to implement).

gempain commented 2 years ago

Yeah that one has been bothering me for a while, and your solution makes a lot of sense ! All that would be needed is to build that link in the frontend directly, since it's the same domain to accept and create invitations. It would solve the email problem in a quite elegant way, and all you'd have to do is share the invite link with the other user 😄

mtiller commented 2 years ago

OK. I made those changes at it worked pretty much as planned. I'll try to submit a PR tomorrow for this bit. Any suggestions for what tests you want? All it does is add a URL field the the invite list payload. I can try and dig around and find any tests that might be checking those payload.

The UI is identical except just before the email address of the person I include FontAwesome link icon that is a hyperlink to the invitation. Is that good for you or were you thinking of something else? I could also put the link at the end of the row, but there are already a couple of things going on there including the "delete" x and I hate to put the link too close to that.

Just let me know.

gempain commented 2 years ago

This is awesome! Do you have a screenshot of what you're describing ? Your change seems fine, I'd just suggest copying the invite URL to the clipboard when the user clicks the link icon. We already have a CopyToClipboard component that we use for copying API tokens. I would suggest updating the CopyToClipboard component to allow changing the initial label so you get set Copy invitation link instead of the default Copy to clipboard tooltip. What do you think ?

Regarding tests, if you haven't changed the payload returned by the backend, I'd just leave it as is, otherwise if you feel like adding a jest test for that endpoint, you're welcome to do so, I have no specific guidelines. I know the project lacks testing, that's certain.