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,
|
||||
buildIssueUrl,
|
||||
type ReportType,
|
||||
type BugFields,
|
||||
type FeatureFields,
|
||||
} from './lib/bugReport'
|
||||
|
||||
interface Props { onClose: () => void }
|
||||
@@ -92,7 +94,10 @@
|
||||
|
||||
async function handleOpen() {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -107,13 +107,48 @@ export function buildSettingsBlock(keys: (keyof Settings)[]): string {
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
export function buildIssueUrl(type: ReportType, settingsBlock: string, title: string, serverVersion?: string): string {
|
||||
export interface BugFields {
|
||||
description: string
|
||||
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 params = new URLSearchParams({
|
||||
|
||||
const common = {
|
||||
template: type === 'bug' ? 'bug_report.yml' : 'feature_request.yml',
|
||||
title,
|
||||
environment: buildEnvironmentBlock(serverVersion),
|
||||
}
|
||||
|
||||
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()}`
|
||||
}
|
||||
Reference in New Issue
Block a user