1+ // import React from 'react';
2+ // import { translate } from './translate';
3+ // import { Box, PrimaryButton } from '../../../components';
4+ // import { useService } from './useService';
5+
6+ // import { CommandPopup } from '../../common/CommandPopup';
7+
8+ // export const CreatePipelineButton: React.FC = () => {
9+ // const [createPipelinePopupOpen, setCreatePipelinePopupOpen] = React.useState<
10+ // boolean
11+ // >(false);
12+
13+ // const { currentWorkspace } = useService();
14+
15+ // const commandText = `zenml workspace set ${
16+ // currentWorkspace && currentWorkspace.id
17+ // }`;
18+
19+ // return (
20+ // <Box
21+ // style={{ position: 'relative' }}
22+ // paddingVertical="sm"
23+ // paddingHorizontal="sm"
24+ // >
25+ // <PrimaryButton onClick={() => setCreatePipelinePopupOpen(true)}>
26+ // {translate('createButton.text')}
27+ // </PrimaryButton>
28+ // <CommandPopup
29+ // commandText={commandText}
30+ // open={createPipelinePopupOpen}
31+ // setOpen={setCreatePipelinePopupOpen}
32+ // />
33+ // </Box>
34+ // );
35+ // };
36+
137import React from 'react' ;
2- import { translate } from './translate' ;
3- import { Box , PrimaryButton } from '../../../components' ;
4- import { useService } from './useService' ;
38+ import styles from './index.module.scss' ;
539
6- import { CommandPopup } from '../../common/CommandPopup' ;
40+ import { useDispatch } from '../../../hooks' ;
41+ import { showToasterAction } from '../../../../redux/actions' ;
42+ import { toasterTypes } from '../../../../constants' ;
43+
44+ import {
45+ Box ,
46+ PrimaryButton ,
47+ FlexBox ,
48+ H3 ,
49+ Paragraph ,
50+ icons ,
51+ } from '../../../components' ;
52+ import { iconSizes , iconColors } from '../../../../constants' ;
53+ import { Popup } from '../../common/Popup' ;
54+ import { DocumentationLink } from './DocumentationLink' ;
55+ import { CommandBoxWScroll } from '../../common/CommandBox' ;
56+ import { constantCommandsToCreatePipeline } from '../../../../constants/constantCommands' ;
757
858export const CreatePipelineButton : React . FC = ( ) => {
59+ const dispatch = useDispatch ( ) ;
960 const [ createPipelinePopupOpen , setCreatePipelinePopupOpen ] = React . useState <
1061 boolean
1162 > ( false ) ;
1263
13- const { currentWorkspace } = useService ( ) ;
64+ const codeString = '#!/bin/bash' ;
1465
15- const commandText = `zenml workspace set ${
16- currentWorkspace && currentWorkspace . id
17- } `;
66+ const handleCopy = ( ) => {
67+ navigator . clipboard . writeText ( codeString ) ;
68+ dispatch (
69+ showToasterAction ( {
70+ description : 'Command copied to clipboard' ,
71+ type : toasterTypes . success ,
72+ } ) ,
73+ ) ;
74+ } ;
1875
1976 return (
2077 < Box
@@ -23,13 +80,100 @@ export const CreatePipelineButton: React.FC = () => {
2380 paddingHorizontal = "sm"
2481 >
2582 < PrimaryButton onClick = { ( ) => setCreatePipelinePopupOpen ( true ) } >
26- { translate ( 'createButton.text' ) }
83+ Create Pipeline
2784 </ PrimaryButton >
28- < CommandPopup
29- commandText = { commandText }
30- open = { createPipelinePopupOpen }
31- setOpen = { setCreatePipelinePopupOpen }
32- />
85+
86+ { createPipelinePopupOpen && (
87+ < Popup onClose = { ( ) => setCreatePipelinePopupOpen ( false ) } >
88+ < FlexBox . Row >
89+ < H3 bold color = "darkGrey" >
90+ { constantCommandsToCreatePipeline . title }
91+ </ H3 >
92+ </ FlexBox . Row >
93+ { constantCommandsToCreatePipeline . body . map ( ( item ) : any =>
94+ item . isCode ? (
95+ < FlexBox alignItems = "center" marginTop = "md" >
96+ < CommandBoxWScroll command = { item . text } />
97+ < Box
98+ className = { styles . iconStyle }
99+ style = { { paddingTop : '7px' } }
100+ onClick = { handleCopy }
101+ >
102+ < icons . copy size = { iconSizes . sm } color = { iconColors . black } />
103+ </ Box >
104+ </ FlexBox >
105+ ) : (
106+ < FlexBox . Row >
107+ < Box marginTop = "md" >
108+ < Paragraph > { item . text } </ Paragraph >
109+ </ Box >
110+ </ FlexBox . Row >
111+ ) ,
112+ ) }
113+
114+ { /* <FlexBox.Row>
115+ <Box marginTop="md">
116+ <Paragraph>you can set it active</Paragraph>
117+ </Box>
118+ </FlexBox.Row>
119+
120+ <FlexBox alignItems="center" marginTop="md">
121+ <CommandBoxWScroll command={codeString} />
122+ <Box
123+ className={styles.iconStyle}
124+ style={{ paddingTop: '7px' }}
125+ onClick={handleCopy}
126+ >
127+ <icons.copy size={iconSizes.sm} color={iconColors.black} />
128+ </Box>
129+ </FlexBox> */ }
130+
131+ { /* <FlexBox alignItems="center" marginTop="sm">
132+ <CommandBoxWScroll command={codeString} />
133+ <Box
134+ className={styles.iconStyle}
135+ style={{ paddingTop: '7px' }}
136+ onClick={handleCopy}
137+ >
138+ <icons.copy size={iconSizes.sm} color={iconColors.black} />
139+ </Box>
140+ </FlexBox>
141+
142+ <FlexBox alignItems="center" marginTop="sm">
143+ <CommandBoxWScroll command={codeString} />
144+ <Box
145+ className={styles.iconStyle}
146+ style={{ paddingTop: '7px' }}
147+ onClick={handleCopy}
148+ >
149+ <icons.copy size={iconSizes.sm} color={iconColors.black} />
150+ </Box>
151+ </FlexBox> */ }
152+
153+ { /* <FlexBox.Row>
154+ <Box marginTop="md">
155+ <Paragraph>you can set it active</Paragraph>
156+ </Box>
157+ </FlexBox.Row> */ }
158+
159+ { /* <FlexBox alignItems="center" marginTop="sm">
160+ <CommandBoxWScroll command={codeString} />
161+ <Box
162+ className={styles.iconStyle}
163+ style={{ paddingTop: '7px' }}
164+ onClick={handleCopy}
165+ >
166+ <icons.copy size={iconSizes.sm} color={iconColors.black} />
167+ </Box>
168+ </FlexBox> */ }
169+
170+ < FlexBox justifyContent = "end" marginTop = "xl" flexWrap >
171+ < DocumentationLink
172+ text = { constantCommandsToCreatePipeline . documentation }
173+ />
174+ </ FlexBox >
175+ </ Popup >
176+ ) }
33177 </ Box >
34178 ) ;
35179} ;
0 commit comments