feat(xo-web): open github issue url with query params when clicking on bug report button

This commit is contained in:
Olivier Floch 2024-01-03 17:34:12 +01:00 committed by Julien Fontanet
parent 6cd99c39f4
commit 046fa7282b
2 changed files with 16 additions and 6 deletions

View File

@ -7,6 +7,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [Settings/Logs] Use GitHub issue form with pre-filled fields when reporting a bug [#7142](https://github.com/vatesfr/xen-orchestra/issues/7142) (PR [#7274](https://github.com/vatesfr/xen-orchestra/pull/7274))
### Bug fixes
> Users must be able to say: “I had this issue, happy to know it's fixed”
@ -32,5 +34,6 @@
- xo-cli patch
- xo-server patch
- xo-web minor
<!--packages-end-->

View File

@ -22,7 +22,8 @@ const ADDITIONAL_FILES_FETCH_TIMEOUT = 5e3
const jsonStringify = json => JSON.stringify(json, null, 2)
const logger = createLogger('report-bug-button')
const GITHUB_URL = 'https://github.com/vatesfr/xen-orchestra/issues/new/choose'
const GITHUB_URL = 'https://github.com/vatesfr/xen-orchestra/issues/new'
const GITHUB_BUG_TEMPLATE = 'bug_report.yml'
const XO_SUPPORT_URL = 'https://xen-orchestra.com/#!/member/support'
const SUPPORT_PANEL_URL = './api/support/create/ticket'
@ -42,12 +43,18 @@ const ADDITIONAL_FILES = [
]
const reportInNewWindow = (url, { title, message, formatMessage = identity }) => {
// message is ignored for the moment
//
// see https://github.com/vatesfr/xen-orchestra/issues/7142
const encodedTitle = encodeURIComponent(title == null ? '' : title)
window.open(`${url}?title=${encodedTitle}`)
let _url = `${url}?title=${encodedTitle}`
if (url === GITHUB_URL) {
const encodedErrorMessage = encodeURIComponent(jsonStringify(message.error))
const encodedLabels = encodeURIComponent('type: bug :bug:,status: triaging :triangular_flag_on_post:')
_url += `&template=${GITHUB_BUG_TEMPLATE}&labels=${encodedLabels}&error-message=${encodedErrorMessage}`
}
window.open(_url)
}
export const reportOnSupportPanel = async ({ files = [], formatMessage = identity, message, title } = {}) => {