mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 12:37:20 +08:00
feat: add credential_id handling in CreateFormPipeline and OnlineDrive components
This commit is contained in:
parent
b21d991fdb
commit
ac7953a32c
@ -28,6 +28,7 @@ const OnlineDrive = ({
|
|||||||
isInPipeline = false,
|
isInPipeline = false,
|
||||||
onCredentialChange,
|
onCredentialChange,
|
||||||
}: OnlineDriveProps) => {
|
}: OnlineDriveProps) => {
|
||||||
|
const [isInitialMount, setIsInitialMount] = useState(true)
|
||||||
const pipelineId = useDatasetDetailContextWithSelector(s => s.dataset?.pipeline_id)
|
const pipelineId = useDatasetDetailContextWithSelector(s => s.dataset?.pipeline_id)
|
||||||
const setShowAccountSettingModal = useModalContextSelector(s => s.setShowAccountSettingModal)
|
const setShowAccountSettingModal = useModalContextSelector(s => s.setShowAccountSettingModal)
|
||||||
const {
|
const {
|
||||||
@ -97,7 +98,15 @@ const OnlineDrive = ({
|
|||||||
}, [datasourceNodeRunURL, dataSourceStore])
|
}, [datasourceNodeRunURL, dataSourceStore])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getOnlineDriveFiles()
|
if (isInitialMount) {
|
||||||
|
// Only fetch files on initial mount if fileList is empty
|
||||||
|
if (fileList.length === 0)
|
||||||
|
getOnlineDriveFiles()
|
||||||
|
setIsInitialMount(false)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getOnlineDriveFiles()
|
||||||
|
}
|
||||||
}, [startAfter, prefix, bucket, currentCredentialId])
|
}, [startAfter, prefix, bucket, currentCredentialId])
|
||||||
|
|
||||||
const onlineDriveFileList = useMemo(() => {
|
const onlineDriveFileList = useMemo(() => {
|
||||||
|
|||||||
@ -174,6 +174,7 @@ const CreateFormPipeline = () => {
|
|||||||
previewOnlineDocumentRef,
|
previewOnlineDocumentRef,
|
||||||
previewWebsitePageRef,
|
previewWebsitePageRef,
|
||||||
previewOnlineDriveFileRef,
|
previewOnlineDriveFileRef,
|
||||||
|
currentCredentialId,
|
||||||
} = dataSourceStore.getState()
|
} = dataSourceStore.getState()
|
||||||
const datasourceInfoList: Record<string, any>[] = []
|
const datasourceInfoList: Record<string, any>[] = []
|
||||||
if (datasourceType === DatasourceType.localFile) {
|
if (datasourceType === DatasourceType.localFile) {
|
||||||
@ -187,6 +188,7 @@ const CreateFormPipeline = () => {
|
|||||||
mime_type,
|
mime_type,
|
||||||
url: '',
|
url: '',
|
||||||
transfer_method: TransferMethod.local_file,
|
transfer_method: TransferMethod.local_file,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
}
|
}
|
||||||
datasourceInfoList.push(documentInfo)
|
datasourceInfoList.push(documentInfo)
|
||||||
}
|
}
|
||||||
@ -195,17 +197,23 @@ const CreateFormPipeline = () => {
|
|||||||
const documentInfo = {
|
const documentInfo = {
|
||||||
workspace_id,
|
workspace_id,
|
||||||
page: rest,
|
page: rest,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
}
|
}
|
||||||
datasourceInfoList.push(documentInfo)
|
datasourceInfoList.push(documentInfo)
|
||||||
}
|
}
|
||||||
if (datasourceType === DatasourceType.websiteCrawl)
|
if (datasourceType === DatasourceType.websiteCrawl) {
|
||||||
datasourceInfoList.push(previewWebsitePageRef.current!)
|
datasourceInfoList.push({
|
||||||
|
...previewWebsitePageRef.current!,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
|
})
|
||||||
|
}
|
||||||
if (datasourceType === DatasourceType.onlineDrive) {
|
if (datasourceType === DatasourceType.onlineDrive) {
|
||||||
const { bucket } = dataSourceStore.getState()
|
const { bucket } = dataSourceStore.getState()
|
||||||
const { key } = previewOnlineDriveFileRef.current!
|
const { key } = previewOnlineDriveFileRef.current!
|
||||||
datasourceInfoList.push({
|
datasourceInfoList.push({
|
||||||
bucket,
|
bucket,
|
||||||
key,
|
key,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
await runPublishedPipeline({
|
await runPublishedPipeline({
|
||||||
@ -225,6 +233,7 @@ const CreateFormPipeline = () => {
|
|||||||
const handleProcess = useCallback(async (data: Record<string, any>) => {
|
const handleProcess = useCallback(async (data: Record<string, any>) => {
|
||||||
if (!datasource)
|
if (!datasource)
|
||||||
return
|
return
|
||||||
|
const { bucket, currentCredentialId } = dataSourceStore.getState()
|
||||||
const datasourceInfoList: Record<string, any>[] = []
|
const datasourceInfoList: Record<string, any>[] = []
|
||||||
if (datasourceType === DatasourceType.localFile) {
|
if (datasourceType === DatasourceType.localFile) {
|
||||||
fileList.forEach((file) => {
|
fileList.forEach((file) => {
|
||||||
@ -238,6 +247,7 @@ const CreateFormPipeline = () => {
|
|||||||
mime_type,
|
mime_type,
|
||||||
url: '',
|
url: '',
|
||||||
transfer_method: TransferMethod.local_file,
|
transfer_method: TransferMethod.local_file,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
}
|
}
|
||||||
datasourceInfoList.push(documentInfo)
|
datasourceInfoList.push(documentInfo)
|
||||||
})
|
})
|
||||||
@ -248,22 +258,26 @@ const CreateFormPipeline = () => {
|
|||||||
const documentInfo = {
|
const documentInfo = {
|
||||||
workspace_id,
|
workspace_id,
|
||||||
page: rest,
|
page: rest,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
}
|
}
|
||||||
datasourceInfoList.push(documentInfo)
|
datasourceInfoList.push(documentInfo)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (datasourceType === DatasourceType.websiteCrawl) {
|
if (datasourceType === DatasourceType.websiteCrawl) {
|
||||||
websitePages.forEach((websitePage) => {
|
websitePages.forEach((websitePage) => {
|
||||||
datasourceInfoList.push(websitePage)
|
datasourceInfoList.push({
|
||||||
|
...websitePage,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (datasourceType === DatasourceType.onlineDrive) {
|
if (datasourceType === DatasourceType.onlineDrive) {
|
||||||
if (datasourceType === DatasourceType.onlineDrive) {
|
if (datasourceType === DatasourceType.onlineDrive) {
|
||||||
const { bucket } = dataSourceStore.getState()
|
|
||||||
selectedFileKeys.forEach((key) => {
|
selectedFileKeys.forEach((key) => {
|
||||||
datasourceInfoList.push({
|
datasourceInfoList.push({
|
||||||
bucket,
|
bucket,
|
||||||
key,
|
key,
|
||||||
|
credential_id: currentCredentialId,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user