refactor(credential-icon, create-from-pipeline, test-run): improve component structure and enhance data handling for online drive files

This commit is contained in:
twwu 2025-08-19 15:24:14 +08:00
parent 95f60d89ab
commit be045a68ee
3 changed files with 22 additions and 13 deletions

View File

@ -26,13 +26,17 @@ export const CredentialIcon: React.FC<CredentialIconProps> = ({
if (avatar_url && avatar_url !== 'default') { if (avatar_url && avatar_url !== 'default') {
return ( return (
<img <div
src={avatar_url} className='flex shrink-0 items-center justify-center overflow-hidden rounded-md border border-divider-regular'
alt={`${name} logo`} style={{ width: `${size}px`, height: `${size}px` }}
width={size} >
height={size} <img
className={cn('shrink-0 rounded-md border border-divider-regular object-contain', className)} src={avatar_url}
/> width={size}
height={size}
className={cn('shrink-0 object-contain', className)}
/>
</div>
) )
} }

View File

@ -209,10 +209,11 @@ const CreateFormPipeline = () => {
} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
const { bucket } = dataSourceStore.getState() const { bucket } = dataSourceStore.getState()
const { id } = previewOnlineDriveFileRef.current! const { id, type } = previewOnlineDriveFileRef.current!
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
id, id,
type,
credential_id: currentCredentialId, credential_id: currentCredentialId,
}) })
} }
@ -233,7 +234,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 { bucket, currentCredentialId, fileList: onlineDriveFileList } = 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) => {
@ -273,10 +274,12 @@ const CreateFormPipeline = () => {
} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
selectedFileIds.forEach((key) => { selectedFileIds.forEach((id) => {
const file = onlineDriveFileList.find(file => file.id === id)
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
key, id: file?.id,
type: file?.type,
credential_id: currentCredentialId, credential_id: currentCredentialId,
}) })
}) })

View File

@ -107,10 +107,12 @@ const TestRunPanel = () => {
}) })
} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
const { bucket } = dataSourceStore.getState() const { bucket, fileList } = dataSourceStore.getState()
const file = fileList.find(file => file.id === selectedFileIds[0])
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
id: selectedFileIds[0], id: file?.id,
type: file?.type,
credential_id: credentialId, credential_id: credentialId,
}) })
} }