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

Add jira tickets auto conversion #555

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Conversation

sebastian-aranda
Copy link
Contributor

This PR extends the htmlToJiraMarkdown function to support auto conversion of jira tickets to hyperlinks, e.g. DM-41184 -> DM-41184.

Copy link

@wvreeven wvreeven left a comment

Choose a reason for hiding this comment

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

Looks good to me. I left a few comments for your consideration.

@@ -1853,6 +1853,8 @@ export function trimString(string, length = 100) {
/**
* Function to parse HTML, generated by react-quill, to Jira Markdown.
* Check https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all for more info
* This function also parse Jira tickets names that are not hyperlinks.
* Allowed projects are in AUTO_HYPERLINK_JIRA_PROJECTS.
* @param {string} html html to be parsed
Copy link

@wvreeven wvreeven Oct 30, 2023

Choose a reason for hiding this comment

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

Not related to your PR, but it the double html here correct?

Copy link
Contributor Author

@sebastian-aranda sebastian-aranda Oct 30, 2023

Choose a reason for hiding this comment

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

hey @wvreeven, thanks and good catch! So the first html is the name of the variable itself, although I will adjust the description for better readability. Here are some examples from the oficial docs: https://jsdoc.app/tags-param.html.

Choose a reason for hiding this comment

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

Thanks for the explanation. Perhaps place a hyphen - between both, as suggested by the docs link, so it is clear which is the variable name and where the description starts?

const expectedOutput =
'This is a string with mixed content\r\nh1. This is a heading.\r\nThis is an already formatted link [DM-41184|https://jira.lsstcorp.org/browse/DM-41184].\r\nThis is a ticket name not yet formatted [DM-41184|https://jira.lsstcorp.org/browse/DM-41184].\r\n';
expect(htmlToJiraMarkdown(input)).toEqual(expectedOutput);
});

Choose a reason for hiding this comment

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

Consider adding a third test case, where

[DM-41184|https://jira.lsstcorp.org/browse/DM-41184]

is already present to make sure that it remains formatted correctly.

…s to links

Also made `jiraMarkdownToHtml` hyperlinks parsing more robuts
Also update package.json
@sebastian-aranda sebastian-aranda merged commit 9bd96f0 into develop Oct 30, 2023
2 checks passed
@sebastian-aranda sebastian-aranda deleted the tickets/DM-41184 branch October 30, 2023 16:29
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