|
|
|
@@ -12,7 +12,8 @@ import ResourceSelectorModal, { |
|
|
|
} from '@/pages/Pipeline/components/ResourceSelectorModal'; |
|
|
|
import { openAntdModal } from '@/utils/modal'; |
|
|
|
import { Button } from 'antd'; |
|
|
|
import { useState } from 'react'; |
|
|
|
import { pick } from 'lodash'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
import ParameterInput, { type ParameterInputProps } from '../ParameterInput'; |
|
|
|
import './index.less'; |
|
|
|
|
|
|
|
@@ -33,6 +34,31 @@ function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSe |
|
|
|
undefined, |
|
|
|
); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if ( |
|
|
|
value && |
|
|
|
typeof value === 'object' && |
|
|
|
value.activeTab && |
|
|
|
value.id && |
|
|
|
value.name && |
|
|
|
value.version && |
|
|
|
value.path && |
|
|
|
(type === ResourceSelectorType.Mirror || value.identifier) && |
|
|
|
(type === ResourceSelectorType.Mirror || value.owner) |
|
|
|
) { |
|
|
|
const originResource = pick(value, [ |
|
|
|
'activeTab', |
|
|
|
'id', |
|
|
|
'identifier', |
|
|
|
'name', |
|
|
|
'owner', |
|
|
|
'version', |
|
|
|
'path', |
|
|
|
]) as ResourceSelectorResponse; |
|
|
|
setSelectedResource(originResource); |
|
|
|
} |
|
|
|
}, [value]); |
|
|
|
|
|
|
|
const selectResource = () => { |
|
|
|
const resource = selectedResource; |
|
|
|
const { close } = openAntdModal(ResourceSelectorModal, { |
|
|
|
@@ -50,8 +76,10 @@ function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSe |
|
|
|
showValue: path, |
|
|
|
fromSelect: true, |
|
|
|
activeTab, |
|
|
|
expandedKeys: [`${id}`], |
|
|
|
checkedKeys: [`${id}-${version}`], |
|
|
|
id, |
|
|
|
name, |
|
|
|
version, |
|
|
|
path, |
|
|
|
}); |
|
|
|
} else { |
|
|
|
const jsonObj = { |
|
|
|
@@ -69,8 +97,6 @@ function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSe |
|
|
|
showValue, |
|
|
|
fromSelect: true, |
|
|
|
activeTab, |
|
|
|
expandedKeys: [`${id}`], |
|
|
|
checkedKeys: [`${id}-${version}`], |
|
|
|
...jsonObj, |
|
|
|
}); |
|
|
|
} |
|
|
|
@@ -80,8 +106,6 @@ function ResourceSelect({ type, value, onChange, disabled, ...rest }: ResourceSe |
|
|
|
showValue: undefined, |
|
|
|
fromSelect: false, |
|
|
|
activeTab: undefined, |
|
|
|
expandedKeys: [], |
|
|
|
checkedKeys: [], |
|
|
|
}); |
|
|
|
} |
|
|
|
close(); |
|
|
|
|