[GH-730] Add link preview for PR and issue.#779
[GH-730] Add link preview for PR and issue.#779Sn-Kinos wants to merge 13 commits intomattermost:masterfrom
Conversation
It had use flex-related property without flex. so I added `display: flex`
There was a problem hiding this comment.
@Sn-Kinos We are trying to move away from javascript to now TypeScript. Will it be possible to convert these files to typescript if possible ?
There was a problem hiding this comment.
I want to convert it to TS from JS but It's hard because there are no fundamental types requiring domain knowledge (e.g. state type from Mattermost web app) and ESLint didn't works well (e.g. It can't import with relative path from baseUrl) I think It will need more best practices for contributors to convert to TS appropriately. There are only one TS file on webapp 🥲
There was a problem hiding this comment.
We are working on providing a template for converting files from js to ts.
cc: @mickmister
There was a problem hiding this comment.
@Sn-Kinos Can you please try to have the webapp/src/components/link_preview/link_preview.jsx file be typescript in particular?
There was a problem hiding this comment.
@mickmister Yes I can. But I think I will need some templates for it. I need more informations of types such as the data from Client, state from redux, etc.
|
@matthewbirtch I'm curious about your thoughts on this feature. It's essentially a clone of the link tooltip component in the form of a link embed preview. Do you think this duplication could be noisy or cause confusion? Note that the preview will only show for users that have their GitHub account connected. |
mickmister
left a comment
There was a problem hiding this comment.
Excellent work @Sn-Kinos! Mostly LGTM, I have a few suggestions and some comments for discussion
| res = await Client.getIssue(owner, repo, number); | ||
| break; | ||
| case 'pull': | ||
| res = await Client.getPullRequest(owner, repo, number); | ||
| break; |
There was a problem hiding this comment.
We'll want to inject these as props instead of accessing the client directly in this component
There was a problem hiding this comment.
Also I wonder what happens here if the user is connected, but doesn't have access to a private repo being linked here
There was a problem hiding this comment.
I'm not sure I understand how that works. It shows the fallback because this component returns null in that case?
There was a problem hiding this comment.
I meant the fact that the webapp handles this gracefully when the component ends up returning null. I don't think you can coordinate React components together like that
There was a problem hiding this comment.
@Sn-Kinos Can you please try to have the webapp/src/components/link_preview/link_preview.jsx file be typescript in particular?
|
|
||
| /* Labels */ | ||
| .github-tooltip .labels { | ||
| display: flex; |
There was a problem hiding this comment.
What effect does this have on the tooltip's styling?
There was a problem hiding this comment.
.labels is not flex element so the properties below doesn't working. So I added it and flex works.
@mickmister I definitely see this as redundant with the hover popover that's been added. In my mind we would need to choose one or the other. Or make it configurable which kind of preview to use in the workspace. |
Without this feature, We can watch the preview like below on private repository. I thought it is uncomfortable, so I added this feature. |
|
@Sn-Kinos @matthewbirtch We can make this feature configurable per-user so they can choose for themselves. We would want to make it obvious that the user can configure these two features separately. Also note that this feature will passively be making requests to GitHub potentially often compared to the link tooltip feature, which could have negative effects on the server in terms of performance. On our community server, we use the autolink plugin which with our configuration of the plugin makes it so GitHub PR links are shortened and hyperlinked, which makes it so the webapp does not use the "embed" feature that this PR relies on in that case. So if I were to opt for the embed feature and not the tooltip, I wouldn't have the chance to use this feature that often on our server. Just something to point out since this could be the case for other servers as well. |
mickmister
left a comment
There was a problem hiding this comment.
The current code LGTM, though I think we need to decide how feature is configured since it essentially clashes with the existing tooltip preview feature
webapp/src/components/link_embed_preview/link_embed_preview.jsx
Outdated
Show resolved
Hide resolved
| res = await Client.getIssue(owner, repo, number); | ||
| break; | ||
| case 'pull': | ||
| res = await Client.getPullRequest(owner, repo, number); | ||
| break; |
There was a problem hiding this comment.
I'm not sure I understand how that works. It shows the fallback because this component returns null in that case?
@mickmister Rather than adding a user setting and increasing that complexity, I would suggest we go with a system-level setting in the admin console. That way everyone on the server sees things the same way. That can be very beneficial to ensure everyone has the same context. |
@mickmister @matthewbirtch I don't think it's very essential to add setting. This link_embed_preview is necessary for private repository only. If the link is public repo, It shows embed preview in a normal way. I think we can handle it with the 'EnablePrivateRepo' setting because the reason for developing link_embed_preview is that the information of private repository is not shown in the existing embedded preview. |
|
@Sn-Kinos I discussed with @matthewbirtch offline, and we're thinking there should be a system console setting that allows the server to be configured for either the link tooltip or link embed. The rationale is that there is more functionality here than simply filling in the gaps for the missing open graph information for private repos, because here there's a rich display of information about the issue/PR with this feature, rather than the simple open graph preview that already shows for public repositories. To give the system admin a choice to enable one or the other, we can use a radio setting like this one being used in the Jira plugin: Please let me know your thoughts on this @Sn-Kinos |
I concerned Also note that this feature will passively be making requests to GitHub potentially often compared to the link tooltip feature, which could have negative effects on the server in terms of performance. on the comment. If It doesn't matter, It will be ok to add the settings. |
@Sn-Kinos The main reason we want to add the settings is the UX flow of toggling showing the issue/PR through tooltip or link embed preview. I'm not sure I understand the point you're making in your last comment here |
I worried 'negative effects on the server in terms of performance' on the comment. If It doesn't matter, I'll be ok :D |
|
@Sn-Kinos I think the piece I'm not understanding is "If It doesn't matter". Are you saying "if the performance issues don't matter"? Or if something else doesn't matter? Sorry about this The only blocker here is for the UX piece. I think the performance issue is probably not a real issue here |
Ahhhh You're right. I concerned about the performance issue. Now, I agree with you as you mentioned. Sorry about the miscommunication problem. the translator that I used didn't work properly I presume. |
|
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
|
I wonder if there's anything else I need to do 🏃♂️ |
|
@Sn-Kinos Sorry for the confusing conversation here. There is one remaining requirement here to implement a plugin setting to toggle this and the link tooltip feature, as discussed here #779 (comment). Does this make sense? |
|
@mickmister I understand. What are the options I need to make? |
|
@Sn-Kinos We can have these two boolean plugin settings:
|
hanzei
left a comment
There was a problem hiding this comment.
@ayusht2810 @Kshitij-Katiyar can you please review the PR?
|
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
|
@Sn-Kinos Thank you for the contribution! Will it be possible for you to convert the newly added Javascript files to Typescript? |
|
@Sn-Kinos Are you willing to work on this? |
Oh I'm really sorry I missed it 🥲🥲 I'm willing to but If there are new people comes to continue this PR. I'd be happy to let someone else take over and continue with this PR. As for me, I've had several issues in my life recently, so I don't think I'll have the time to spend on contributing 😭 |





Summary
display: flexon labels at link_tooltipScreenshots
Ticket Link