@@ -4,7 +4,7 @@ import { CopyIcon, DeleteIcon, EditIcon, KanvasIcon, PublishIcon } from '../../i
44import Download from '../../icons/Download/Download' ;
55import { charcoal , useTheme } from '../../theme' ;
66import { Pattern } from '../CustomCatalog/CustomCard' ;
7- import { downloadFilter , downloadYaml } from './helper' ;
7+ import { downloadPattern , downloadYaml , getValidSorceType } from './helper' ;
88import { ActionButton , StyledActionWrapper , UnpublishAction } from './style' ;
99import { RESOURCE_TYPES } from './types' ;
1010
@@ -13,6 +13,7 @@ interface ActionButtonsProps {
1313 details : Pattern ;
1414 type : string ;
1515 isCloneLoading : boolean ;
16+ getDownloadUrl : ( sorceType : string , id : string ) => string ;
1617 handleClone : ( name : string , id : string ) => void ;
1718 handleUnpublish : ( ) => void ;
1819 isCloneDisabled : boolean ;
@@ -34,6 +35,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
3435 isCloneDisabled,
3536 showUnpublishAction,
3637 handleUnpublish,
38+ getDownloadUrl,
3739 showOpenPlaygroundAction,
3840 onOpenPlaygroundClick,
3941 showInfoAction,
@@ -42,6 +44,7 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
4244 handleDelete
4345} ) => {
4446 const cleanedType = type . replace ( 'my-' , '' ) . replace ( / s $ / , '' ) ;
47+ const sorceType = getValidSorceType ( type ) ;
4548 const theme = useTheme ( ) ;
4649 return (
4750 < StyledActionWrapper >
@@ -83,9 +86,9 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({
8386 color : theme . palette . text . default
8487 } }
8588 onClick = { ( ) =>
86- cleanedType === RESOURCE_TYPES . FILTERS
87- ? downloadFilter ( details . id , details . name )
88- : downloadYaml ( details . pattern_file , details . name )
89+ cleanedType === RESOURCE_TYPES . VIEWS
90+ ? downloadYaml ( details . pattern_file , details . name )
91+ : downloadPattern ( details . id , details . name , sorceType , getDownloadUrl )
8992 }
9093 >
9194 < Download width = { 24 } height = { 24 } fill = { theme . palette . icon . default } />
0 commit comments