@@ -44,7 +44,7 @@ import {
44
44
WORKFLOW_NAME_RESTRICTIONS ,
45
45
} from '../../../../common' ;
46
46
import { WORKFLOWS_TAB } from '../workflows' ;
47
- import { getDataSourceId } from '../../../utils/utils' ;
47
+ import { getDataSourceId , getEffectiveVersion , formatDisplayVersion } from '../../../utils/utils' ;
48
48
49
49
interface ImportWorkflowModalProps {
50
50
isImportModalOpen : boolean ;
@@ -62,6 +62,17 @@ interface ImportWorkflowModalProps {
62
62
export function ImportWorkflowModal ( props : ImportWorkflowModalProps ) {
63
63
const dispatch = useAppDispatch ( ) ;
64
64
const dataSourceId = getDataSourceId ( ) ;
65
+ const [ dataSourceVersion , setDataSourceVersion ] = useState <
66
+ string | undefined
67
+ > ( undefined ) ;
68
+ useEffect ( ( ) => {
69
+ async function getVersion ( ) {
70
+ if ( dataSourceId !== undefined ) {
71
+ setDataSourceVersion ( await getEffectiveVersion ( dataSourceId ) ) ;
72
+ }
73
+ }
74
+ getVersion ( ) ;
75
+ } , [ dataSourceId ] ) ;
65
76
const { workflows } = useSelector ( ( state : AppState ) => state . workflows ) ;
66
77
67
78
// workflow name state
@@ -87,10 +98,8 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) {
87
98
return description . length > MAX_DESCRIPTION_LENGTH ;
88
99
}
89
100
90
- // States for tracking workflow template compatibility with current data source version
101
+ // State for tracking workflow template compatibility with current data source version
91
102
const [ isCompatible , setIsCompatible ] = useState < boolean > ( true ) ;
92
- const [ inCompatibleDataSourceVersion , setInCompatibleDataSourceVersion ] = useState < string | undefined > ( ) ;
93
-
94
103
95
104
// transient importing state for button state
96
105
const [ isImporting , setIsImporting ] = useState < boolean > ( false ) ;
@@ -124,11 +133,8 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) {
124
133
useEffect ( ( ) => {
125
134
async function checkCompatibility ( ) {
126
135
if ( isValidWorkflow ( fileObj ) ) {
127
- const [ isCompatible , dataSourceVersion ] = await isCompatibleWorkflow ( fileObj , dataSourceId ) ;
136
+ const isCompatible = await isCompatibleWorkflow ( fileObj , dataSourceId ) ;
128
137
setIsCompatible ( isCompatible ) ;
129
- if ( dataSourceVersion ) {
130
- setInCompatibleDataSourceVersion ( dataSourceVersion ) ;
131
- }
132
138
}
133
139
}
134
140
checkCompatibility ( ) ;
@@ -161,11 +167,11 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) {
161
167
< EuiSpacer size = "m" />
162
168
</ >
163
169
) }
164
- { isValidWorkflow ( fileObj ) && ! isCompatible && inCompatibleDataSourceVersion && (
170
+ { isValidWorkflow ( fileObj ) && ! isCompatible && dataSourceVersion && (
165
171
< >
166
172
< EuiFlexItem >
167
173
< EuiCallOut
168
- title = { `The uploaded file is not compatible with the current data source version ${ inCompatibleDataSourceVersion } . Upload a compatible file or switch to another data source.` }
174
+ title = { `The uploaded file is not compatible with the current data source version ${ formatDisplayVersion ( dataSourceVersion ) } . Upload a compatible file or switch to another data source.` }
169
175
iconType = { 'alert' }
170
176
color = "danger"
171
177
/>
0 commit comments