mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 01:09:56 -05:00
Fix: Pass all Template Arguments on BugReporter
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
buildSettingsBlock,
|
buildSettingsBlock,
|
||||||
buildIssueUrl,
|
buildIssueUrl,
|
||||||
type ReportType,
|
type ReportType,
|
||||||
|
type BugFields,
|
||||||
|
type FeatureFields,
|
||||||
} from './lib/bugReport'
|
} from './lib/bugReport'
|
||||||
|
|
||||||
interface Props { onClose: () => void }
|
interface Props { onClose: () => void }
|
||||||
@@ -92,7 +94,10 @@
|
|||||||
|
|
||||||
async function handleOpen() {
|
async function handleOpen() {
|
||||||
const settingsBlock = buildSettingsBlock([...selectedKeys])
|
const settingsBlock = buildSettingsBlock([...selectedKeys])
|
||||||
const url = buildIssueUrl(reportType, settingsBlock, title, serverVersion)
|
const fields: BugFields | FeatureFields = reportType === 'bug'
|
||||||
|
? { description, steps, expected, actual }
|
||||||
|
: { problem, solution, alternatives }
|
||||||
|
const url = buildIssueUrl(reportType, settingsBlock, title, fields, serverVersion)
|
||||||
await platformService.openExternal(url)
|
await platformService.openExternal(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,13 +107,48 @@ export function buildSettingsBlock(keys: (keyof Settings)[]): string {
|
|||||||
.join('\n')
|
.join('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildIssueUrl(type: ReportType, settingsBlock: string, title: string, serverVersion?: string): string {
|
export interface BugFields {
|
||||||
const base = 'https://github.com/moku-project/Moku/issues/new'
|
description: string
|
||||||
const params = new URLSearchParams({
|
steps: string
|
||||||
|
expected: string
|
||||||
|
actual: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FeatureFields {
|
||||||
|
problem: string
|
||||||
|
solution: string
|
||||||
|
alternatives: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildIssueUrl(
|
||||||
|
type: ReportType,
|
||||||
|
settingsBlock: string,
|
||||||
|
title: string,
|
||||||
|
fields: BugFields | FeatureFields,
|
||||||
|
serverVersion?: string,
|
||||||
|
): string {
|
||||||
|
const base = 'https://github.com/moku-project/Moku/issues/new'
|
||||||
|
|
||||||
|
const common = {
|
||||||
template: type === 'bug' ? 'bug_report.yml' : 'feature_request.yml',
|
template: type === 'bug' ? 'bug_report.yml' : 'feature_request.yml',
|
||||||
title,
|
title,
|
||||||
environment: buildEnvironmentBlock(serverVersion),
|
environment: buildEnvironmentBlock(serverVersion),
|
||||||
settings: settingsBlock,
|
}
|
||||||
})
|
|
||||||
|
const specific = type === 'bug'
|
||||||
|
? {
|
||||||
|
description: (fields as BugFields).description,
|
||||||
|
steps: (fields as BugFields).steps,
|
||||||
|
expected: (fields as BugFields).expected,
|
||||||
|
actual: (fields as BugFields).actual,
|
||||||
|
settings: settingsBlock,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
problem: (fields as FeatureFields).problem,
|
||||||
|
solution: (fields as FeatureFields).solution,
|
||||||
|
alternatives: (fields as FeatureFields).alternatives,
|
||||||
|
}
|
||||||
|
|
||||||
|
const params = new URLSearchParams({ ...common, ...specific })
|
||||||
return `${base}?${params.toString()}`
|
return `${base}?${params.toString()}`
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user