Skip to content

Commit

Permalink
feat(xo-web): open github issue url with query params when clicking o…
Browse files Browse the repository at this point in the history
…n bug report button
  • Loading branch information
OlivierFL authored and julien-f committed Jan 4, 2024
1 parent 2781a56 commit 0d98573
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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”
Expand All @@ -32,5 +34,6 @@

- xo-cli patch
- xo-server patch
- xo-web minor

<!--packages-end-->
19 changes: 13 additions & 6 deletions packages/xo-web/src/common/report-bug-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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 } = {}) => {
Expand Down

0 comments on commit 0d98573

Please sign in to comment.