mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(jira): jira project and issue auto loading (#324)
Co-authored-by: Adam Gough <adamgough@Adams-MacBook-Pro.local>
This commit is contained in:
@@ -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 = {
|
||||
|
||||
+10
-1
@@ -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])
|
||||
|
||||
+6
-2
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user