Skip to content

Conversation

@akshat-khosya
Copy link

Summary

This adds support for rendering tooltips for links from Enterprise GitHub installations by checking the configured Enterprise Base URL. It also adds unit tests to verify the URL parsing logic for both SaaS and Enterprise links.

Ticket Link

#367

This adds support for rendering tooltips for links from Enterprise GitHub installations by checking the configured Enterprise Base URL. It also adds unit tests to verify the URL parsing logic for both SaaS and Enterprise links.
@akshat-khosya akshat-khosya requested a review from a team as a code owner December 18, 2025 15:26
@mattermost-build
Copy link
Contributor

Hello @akshat-khosya,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

Copy link

@avasconcelos114 avasconcelos114 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! 🎊

I left a couple of comments with regards to one of the links in the tooltip as well as testing related to it. Let me know if you have any questions about them!

{'Opened by '}
<a
href={`https://github.com/${data.user.login}`}
href={`${enterpriseURL && enterpriseURL !== '' ? enterpriseURL : 'https://github.com'}/${data.user.login}`}

Choose a reason for hiding this comment

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

It seems that for enterprise installations we will end up with the Opened By link sending users directly to the enterpriseURL URL instead of what would be the user's profile

It feels like we could have a useMemo-wrapped function that attempts to first map to the user's html_url property, which both the Get issue and Get Pull Request endpoints should return. With a fallback values to each base URL for good measure

Something that would look like this

const openedByLink = useMemo(() => {
    if (!data?.user?.login) {
        return null;
    }
    // Immediately map the html_url value when present (which should work for both Enterprise and Cloud)
    if (data.user.html_url) {
        return data.user.html_url;
    }

    // Fallback to a generic enterprise URL when appropriate, handling possible trailing slashes
    if (enterpriseURL) {
        const entURL = enterpriseURL.endsWith('/') ? enterpriseURL : enterpriseURL + '/';
        return `${entURL}${data.user.login}`;
    }

    // Assume it's GitHub cloud and fallback to the original path (unlikely to ever run unless there are breaking changes in GitHub's API 
    return `https://github.com/${data.user.login}`;
}, [data, enterpriseURL]);

This way we can also safely render the link based on openedByLink's value in line 145 instead of data?.user?.login


jest.mock('react-markdown', () => () => <div/>);

describe('LinkTooltip', () => {

Choose a reason for hiding this comment

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

Great job with the tests! They are a much appreciated addition

Could we also have a couple of tests that confirm that the "Opened by" link's href attribute changes accordingly based on the mapped props and component state?

Comment on lines +40 to +43
// We need to use mount or wait for useEffect?
// shallow renders the component, useEffect is a hook.
// Enzyme shallow supports hooks in newer versions, but let's check if we need to manually trigger logic.
// The component uses useEffect to call initData.

Choose a reason for hiding this comment

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

The comments here aren't particularly necessary, they can be safely removed

@avasconcelos114 avasconcelos114 added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester Contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants