|
1 | | -import _ from 'lodash'; |
2 | 1 | import React from 'react'; |
3 | 2 | import { CircularProgress } from '../../base'; |
4 | 3 | import { CopyIcon, KanvasIcon, PublishIcon } from '../../icons'; |
5 | 4 | import Download from '../../icons/Download/Download'; |
6 | 5 | import { charcoal } from '../../theme'; |
7 | 6 | import { Pattern } from '../CustomCatalog/CustomCard'; |
8 | | -import { downloadFilter, downloadYaml, slugify } from './helper'; |
9 | | -import { ActionButton, LinkUrl, StyledActionWrapper, UnpublishAction } from './style'; |
| 7 | +import { downloadFilter, downloadYaml } from './helper'; |
| 8 | +import { ActionButton, StyledActionWrapper, UnpublishAction } from './style'; |
10 | 9 | import { RESOURCE_TYPES } from './types'; |
11 | 10 |
|
12 | 11 | interface ActionButtonsProps { |
13 | 12 | actionItems: boolean; |
14 | 13 | details: Pattern; |
15 | 14 | type: string; |
16 | | - cardId: string; |
17 | 15 | isCloneLoading: boolean; |
18 | 16 | handleClone: (name: string, id: string) => void; |
19 | | - mode: string; |
20 | 17 | handleUnpublish: () => void; |
21 | 18 | isCloneDisabled: boolean; |
22 | | - showOpenPlaygroundButton: boolean; |
23 | 19 | showUnpublishAction: boolean; |
| 20 | + onOpenPlaygroundClick: (designId: string, name: string) => void; |
24 | 21 | } |
25 | 22 |
|
26 | 23 | const ActionButtons: React.FC<ActionButtonsProps> = ({ |
27 | 24 | actionItems, |
28 | 25 | details, |
29 | 26 | type, |
30 | | - cardId, |
31 | 27 | isCloneLoading, |
32 | 28 | handleClone, |
33 | | - mode, |
34 | 29 | isCloneDisabled, |
35 | | - showOpenPlaygroundButton, |
36 | 30 | showUnpublishAction, |
37 | | - handleUnpublish |
| 31 | + handleUnpublish, |
| 32 | + onOpenPlaygroundClick |
38 | 33 | }) => { |
39 | 34 | const cleanedType = type.replace('my-', '').replace(/s$/, ''); |
40 | | - const resourcePlaygroundType = Object.values({ |
41 | | - ..._.omit(RESOURCE_TYPES, ['FILTERS']), |
42 | | - CATALOG: 'catalog' |
43 | | - }).includes(cleanedType) |
44 | | - ? cleanedType |
45 | | - : 'design'; |
46 | 35 | return ( |
47 | 36 | <StyledActionWrapper> |
48 | 37 | {actionItems && ( |
@@ -93,29 +82,21 @@ const ActionButtons: React.FC<ActionButtonsProps> = ({ |
93 | 82 | )} |
94 | 83 | </div> |
95 | 84 | )} |
96 | | - {showOpenPlaygroundButton && ( |
97 | | - <LinkUrl |
98 | | - style={{ width: '100%' }} |
99 | | - href={`https://playground.meshery.io/extension/meshmap?mode=${mode}&type=${resourcePlaygroundType}&id=${cardId}&name=${slugify( |
100 | | - details.name |
101 | | - )}`} |
102 | | - target="_blank" |
103 | | - rel="noreferrer" |
104 | | - > |
105 | | - <ActionButton |
106 | | - sx={{ |
107 | | - borderRadius: '0.2rem', |
108 | | - backgroundColor: 'background.cta.default', |
109 | | - color: charcoal[10], |
110 | | - gap: '10px', |
111 | | - width: '100%' |
112 | | - }} |
113 | | - > |
114 | | - <KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} /> |
115 | | - Open in Playground |
116 | | - </ActionButton> |
117 | | - </LinkUrl> |
118 | | - )} |
| 85 | + |
| 86 | + <ActionButton |
| 87 | + sx={{ |
| 88 | + borderRadius: '0.2rem', |
| 89 | + backgroundColor: 'background.cta.default', |
| 90 | + color: charcoal[10], |
| 91 | + gap: '10px', |
| 92 | + width: '100%' |
| 93 | + }} |
| 94 | + onClick={() => onOpenPlaygroundClick(details.id, details.name)} |
| 95 | + > |
| 96 | + <KanvasIcon width={24} height={24} primaryFill={charcoal[10]} fill={charcoal[10]} /> |
| 97 | + Open in Playground |
| 98 | + </ActionButton> |
| 99 | + |
119 | 100 | {showUnpublishAction && ( |
120 | 101 | <UnpublishAction |
121 | 102 | sx={{ |
|
0 commit comments