1
- import { Flex , Link , Text } from '@invoke-ai/ui-library' ;
1
+ import { Button , Flex , ListItem , Text , UnorderedList } from '@invoke-ai/ui-library' ;
2
2
import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
3
+ import { $installModelsTab } from 'features/modelManagerV2/subpanels/InstallModels' ;
3
4
import { tileControlnetModelChanged } from 'features/parameters/store/upscaleSlice' ;
4
- import { MODEL_TYPE_SHORT_MAP } from 'features/parameters/types/constants' ;
5
5
import { setActiveTab } from 'features/ui/store/uiSlice' ;
6
6
import { useCallback , useEffect , useMemo } from 'react' ;
7
- import { useTranslation } from 'react-i18next' ;
7
+ import { Trans , useTranslation } from 'react-i18next' ;
8
8
import { useControlNetModels } from 'services/api/hooks/modelsByType' ;
9
9
10
10
export const MultidiffusionWarning = ( ) => {
@@ -23,38 +23,46 @@ export const MultidiffusionWarning = () => {
23
23
dispatch ( tileControlnetModelChanged ( validModel || null ) ) ;
24
24
} , [ model ?. base , modelConfigs , dispatch ] ) ;
25
25
26
- const warningText = useMemo ( ( ) => {
26
+ const warnings = useMemo ( ( ) => {
27
+ const _warnings : string [ ] = [ ] ;
27
28
if ( ! model ) {
28
- return t ( 'upscaling.warningNoMainModel' ) ;
29
+ _warnings . push ( t ( 'upscaling.mainModelDesc' ) ) ;
29
30
}
30
- if ( ! upscaleModel && ! tileControlnetModel ) {
31
- return t ( 'upscaling.warningNoTileOrUpscaleModel' , { base_model : MODEL_TYPE_SHORT_MAP [ model . base ] } ) ;
31
+ if ( ! tileControlnetModel ) {
32
+ _warnings . push ( t ( 'upscaling.tileControlNetModelDesc' ) ) ;
32
33
}
33
34
if ( ! upscaleModel ) {
34
- return t ( 'upscaling.warningNoUpscaleModel' ) ;
35
- }
36
- if ( ! tileControlnetModel ) {
37
- return t ( 'upscaling.warningNoTile' , { base_model : MODEL_TYPE_SHORT_MAP [ model . base ] } ) ;
35
+ _warnings . push ( t ( 'upscaling.upscaleModelDesc' ) ) ;
38
36
}
37
+ return _warnings ;
39
38
} , [ model , upscaleModel , tileControlnetModel , t ] ) ;
40
39
41
40
const handleGoToModelManager = useCallback ( ( ) => {
42
41
dispatch ( setActiveTab ( 'models' ) ) ;
42
+ $installModelsTab . set ( 3 ) ;
43
43
} , [ dispatch ] ) ;
44
44
45
- if ( ! warningText || isLoading || ! shouldShowButton ) {
46
- return < > </ > ;
45
+ if ( ! warnings . length || isLoading || ! shouldShowButton ) {
46
+ return null ;
47
47
}
48
48
49
49
return (
50
- < Flex bg = "error.500" borderRadius = "base" padding = "2" direction = "column" >
51
- < Text fontSize = "xs" textAlign = "center" display = "inline-block" >
52
- { t ( 'upscaling.visit' ) } { ' ' }
53
- < Link fontWeight = "bold" onClick = { handleGoToModelManager } >
54
- { t ( 'modelManager.modelManager' ) }
55
- </ Link > { ' ' }
56
- { t ( 'upscaling.toInstall' ) } { warningText } .
50
+ < Flex bg = "error.500" borderRadius = "base" padding = { 4 } direction = "column" fontSize = "sm" gap = { 2 } >
51
+ < Text >
52
+ < Trans
53
+ i18nKey = "upscaling.missingModelsWarning"
54
+ components = { {
55
+ LinkComponent : (
56
+ < Button size = "sm" flexGrow = { 0 } variant = "link" color = "base.50" onClick = { handleGoToModelManager } />
57
+ ) ,
58
+ } }
59
+ />
57
60
</ Text >
61
+ < UnorderedList >
62
+ { warnings . map ( ( warning ) => (
63
+ < ListItem key = { warning } > { warning } </ ListItem >
64
+ ) ) }
65
+ </ UnorderedList >
58
66
</ Flex >
59
67
) ;
60
68
} ;
0 commit comments