fix(jira): jira project and issue auto loading (#324)

Co-authored-by: Adam Gough <adamgough@Adams-MacBook-Pro.local>
This commit is contained in:
Adam Gough
2025-05-04 12:39:16 -07:00
committed by GitHub
co-authored by Adam Gough
parent 9f1e8e3de8
commit b646806786
3 changed files with 17 additions and 3 deletions
@@ -59,6 +59,7 @@ export async function POST(request: Request) {
}
const data = await response.json()
logger.info('Successfully fetched issue:', data.key)
// Transform the Jira issue data into our expected format
const issueInfo: any = {
@@ -207,16 +207,24 @@ export function JiraIssueSelector({
if (!response.ok) {
const errorData = await response.json()
logger.error('Failed to fetch issue info:', errorData)
throw new Error(errorData.error || 'Failed to fetch issue info')
}
const data = await response.json()
if (data.cloudId) {
logger.info('Using cloud ID:', data.cloudId)
setCloudId(data.cloudId)
}
if (data.issue) {
logger.info('Successfully fetched issue:', data.issue.name)
setSelectedIssue(data.issue)
onIssueInfoChange?.(data.issue)
} else {
logger.warn('No issue data received in response')
setSelectedIssue(null)
onIssueInfoChange?.(null)
}
} catch (error) {
logger.error('Error fetching issue info:', error)
@@ -363,6 +371,7 @@ export function JiraIssueSelector({
}
}, [fetchCredentials])
// Handle open change
const handleOpenChange = (isOpen: boolean) => {
setOpen(isOpen)
@@ -375,7 +384,7 @@ export function JiraIssueSelector({
// Fetch selected issue metadata once credentials are ready or changed
useEffect(() => {
if (value && selectedCredentialId && !selectedIssue && domain && domain.includes('.')) {
if (value && selectedCredentialId && domain && domain.includes('.') && (!selectedIssue || selectedIssue.id !== value)) {
fetchIssueInfo(value)
}
}, [value, selectedCredentialId, selectedIssue, domain, fetchIssueInfo])
@@ -33,9 +33,13 @@ export function FileSelectorInput({ blockId, subBlock, disabled = false }: FileS
useEffect(() => {
const value = getValue(blockId, subBlock.id)
if (value && typeof value === 'string') {
setSelectedFileId(value)
if (isJira) {
setSelectedIssueId(value)
} else {
setSelectedFileId(value)
}
}
}, [blockId, subBlock.id, getValue])
}, [blockId, subBlock.id, getValue, isJira])
// Handle file selection
const handleFileChange = (fileId: string, info?: any) => {