Skip to content

Commit d06dada

Browse files
Merge pull request #183 from zenml-io/stack-config
added config popup while clicking on tile
2 parents 540c447 + 4b7cf6b commit d06dada

File tree

7 files changed

+224
-46
lines changed

7 files changed

+224
-46
lines changed

src/ui/layouts/stackComponents/Stacks/List/GetFlavorsListForLogo.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import { sessionSelectors } from '../../../../../redux/selectors';
55

66
export const GetFlavorsListForLogo = () => {
77
const authToken = useSelector(sessionSelectors.authenticationToken);
8-
8+
const [fetching, setFetching] = useState(false);
99
const [flavourList, setFlavourList] = useState([]);
1010
useEffect(() => {
1111
fetchFlavourList();
1212
// eslint-disable-next-line react-hooks/exhaustive-deps
1313
}, []);
1414

1515
const fetchFlavourList = async () => {
16+
setFetching(true);
1617
const response = await axios.get(
1718
`${process.env.REACT_APP_BASE_API_URL}/flavors?size=1000`,
1819
{
@@ -22,10 +23,13 @@ export const GetFlavorsListForLogo = () => {
2223
},
2324
);
2425

25-
setFlavourList(response?.data?.items); //Setting the response into state
26+
setFlavourList(response?.data?.items);
27+
setFetching(false);
28+
//Setting the response into state
2629
};
2730

2831
return {
32+
fetching,
2933
flavourList,
3034
};
3135
};

src/ui/layouts/stacks/CreateStack/ListForAll/SidePopup/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ import {
88
LinkBox,
99
Paragraph,
1010
H3,
11-
PrimaryButton,
11+
PrimaryButton,
1212
} from '../../../../../components';
1313

1414
import styles from './index.module.scss';
1515

1616
const Dimmer: React.FC = () => <Box className={styles.dimmer}></Box>;
1717

1818
export const SidePopup: React.FC<{
19+
isCreate?: boolean;
1920
onSeeExisting: () => void;
2021
onClose: () => void;
21-
registerStack: any;
22-
}> = ({ children, onClose, registerStack, onSeeExisting }) => (
22+
registerStack?: any;
23+
}> = ({ children, onClose, registerStack, onSeeExisting, isCreate = true }) => (
2324
<>
2425
<Dimmer />
2526
<FlexBox
@@ -36,9 +37,11 @@ export const SidePopup: React.FC<{
3637
<Box className={styles.sidePopup}>
3738
<OutsideClickHandler onOutsideClick={onClose}>
3839
<Box paddingVertical="lg" paddingHorizontal="xxxl">
39-
<H3 style={{ color: '#443E99', fontWeight: 'bold' }} >Configurations</H3>
40-
{children}
41-
</Box>
40+
<H3 style={{ color: '#443E99', fontWeight: 'bold' }}>
41+
Configurations
42+
</H3>
43+
{children}
44+
</Box>
4245

4346
<Box
4447
paddingVertical="lg"
@@ -51,9 +54,13 @@ export const SidePopup: React.FC<{
5154
<Paragraph>Edit Component</Paragraph>
5255
</LinkBox>
5356
</Box>
54-
<Box>
55-
<PrimaryButton onClick={registerStack}>Register Stack</PrimaryButton>
56-
</Box>
57+
{isCreate && (
58+
<Box>
59+
<PrimaryButton onClick={registerStack}>
60+
Register Stack
61+
</PrimaryButton>
62+
</Box>
63+
)}
5764
</FlexBox.Row>
5865
</Box>
5966
</OutsideClickHandler>

src/ui/layouts/stacks/StackDetail/Configuration/index.module.scss

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,67 @@
44
font-size: $fontSizeBody;
55
max-height: 75vh;
66
}
7+
.field {
8+
background: rgba(168, 168, 168, 0.1);
9+
border: 1px solid #C9CBD0;
10+
border-radius: 4px;
11+
}
12+
.switch {
13+
position: relative;
14+
display: inline-block;
15+
width: 38px;
16+
height: 20px;
17+
}
18+
19+
.switch input {
20+
opacity: 0;
21+
width: 0;
22+
height: 0;
23+
}
24+
25+
.slider {
26+
position: absolute;
27+
cursor: pointer;
28+
top: 0;
29+
left: 0;
30+
right: 0;
31+
bottom: 0;
32+
background-color: #ccc;
33+
-webkit-transition: .4s;
34+
transition: .4s;
35+
}
36+
37+
.slider:before {
38+
position: absolute;
39+
content: "";
40+
height: 17px;
41+
width: 17px;
42+
left: 1px;
43+
bottom: 2px;
44+
background-color: white;
45+
-webkit-transition: .4s;
46+
transition: .4s;
47+
}
48+
49+
input:checked + .slider {
50+
background-color: $primaryColor;
51+
}
52+
53+
input:focus + .slider {
54+
box-shadow: 0 0 1px $primaryColor;
55+
}
56+
57+
input:checked + .slider:before {
58+
-webkit-transform: translateX(19px);
59+
-ms-transform: translateX(19px);
60+
transform: translateX(19px);
61+
}
62+
63+
/* Rounded sliders */
64+
.slider.round {
65+
border-radius: 34px;
66+
}
67+
68+
.slider.round:before {
69+
border-radius: 50%;
70+
}

src/ui/layouts/stacks/StackDetail/Configuration/index.tsx

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ import React, { useState } from 'react';
22

33
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
44
import { okaidia } from 'react-syntax-highlighter/dist/esm/styles/prism';
5-
import { FlexBox, Box, H4, GhostButton, icons } from '../../../../components';
5+
import {
6+
FlexBox,
7+
Box,
8+
H4,
9+
GhostButton,
10+
icons,
11+
Row,
12+
FullWidthSpinner,
13+
// Container,
14+
EditField,
15+
Paragraph,
16+
} from '../../../../components';
617
import { iconColors, iconSizes } from '../../../../../constants';
718

819
import { useDispatch } from '../../../../hooks';
@@ -13,11 +24,21 @@ import { translate } from '../translate';
1324

1425
import styles from './index.module.scss';
1526
import { useService } from './useService';
27+
import { StackBox } from '../../../common/StackBox';
28+
import { SidePopup } from '../../CreateStack/ListForAll/SidePopup';
29+
import { NonEditableConfig } from '../../../NonEditableConfig';
30+
// import { SidePopup } from '../../../common/SidePopup';
1631

17-
export const Configuration: React.FC<{ stackId: TId }> = ({ stackId }) => {
32+
export const Configuration: React.FC<{
33+
stackId: TId;
34+
tiles?: any;
35+
fetching?: boolean;
36+
}> = ({ stackId, tiles, fetching = false }) => {
1837
const dispatch = useDispatch();
19-
const { downloadYamlFile, stackConfig } = useService({ stackId });
38+
const { downloadYamlFile, stackConfig, stack } = useService({ stackId });
2039
const [hover, setHover] = useState(false);
40+
const [showPopup, setShowPopup] = useState<boolean>(false);
41+
const [selectedStackBox, setSelectedStackBox] = useState<any>();
2142
const handleCopy = () => {
2243
navigator.clipboard.writeText(stackConfig);
2344
dispatch(
@@ -27,6 +48,9 @@ export const Configuration: React.FC<{ stackId: TId }> = ({ stackId }) => {
2748
}),
2849
);
2950
};
51+
if (fetching) {
52+
return <FullWidthSpinner color="black" size="md" />;
53+
}
3054

3155
return (
3256
<FlexBox.Column fullWidth>
@@ -59,6 +83,57 @@ export const Configuration: React.FC<{ stackId: TId }> = ({ stackId }) => {
5983
</GhostButton>
6084
</Box>
6185
</FlexBox>
86+
<FlexBox.Row marginLeft="md">
87+
{/* <Container> */}
88+
<Box style={{ width: '30%' }}>
89+
<EditField
90+
disabled
91+
onChangeText={() => console.log('')}
92+
label={'Stack Name'}
93+
optional={false}
94+
value={stack.name}
95+
placeholder=""
96+
hasError={false}
97+
className={styles.field}
98+
/>
99+
</Box>
100+
<FlexBox
101+
marginLeft="xxl2"
102+
justifyContent="space-between"
103+
style={{ width: '20%' }}
104+
>
105+
<Paragraph>Share Component with public</Paragraph>
106+
107+
<label className={styles.switch}>
108+
<input type="checkbox" checked={stack.isShared} />
109+
<span className={`${styles.slider} ${styles.round}`}></span>
110+
</label>
111+
</FlexBox>
112+
{/* </Container> */}
113+
</FlexBox.Row>
114+
<Box margin="md">
115+
<Row>
116+
{tiles &&
117+
tiles.map((tile: any, index: number) => (
118+
<Box
119+
key={index}
120+
className={styles.tile}
121+
marginTop="md"
122+
marginLeft="md"
123+
onClick={() => {
124+
setShowPopup(true);
125+
setSelectedStackBox(tile);
126+
}}
127+
>
128+
<StackBox
129+
image={tile.logo}
130+
stackName={tile.name}
131+
stackDesc={tile.type}
132+
/>
133+
</Box>
134+
))}
135+
</Row>
136+
</Box>
62137
<FlexBox className={styles.code}>
63138
<SyntaxHighlighter
64139
customStyle={{ width: '100%' }}
@@ -69,6 +144,24 @@ export const Configuration: React.FC<{ stackId: TId }> = ({ stackId }) => {
69144
{stackConfig}
70145
</SyntaxHighlighter>
71146
</FlexBox>
147+
148+
{showPopup && (
149+
<SidePopup
150+
// registerStack={() => {
151+
// onCreateStack();
152+
// }}
153+
isCreate={false}
154+
onSeeExisting={() => {}}
155+
onClose={() => {
156+
setShowPopup(false);
157+
setSelectedStackBox(null);
158+
}}
159+
>
160+
<Box marginTop="md" paddingBottom={'xxxl'}>
161+
<NonEditableConfig details={selectedStackBox}></NonEditableConfig>
162+
</Box>
163+
</SidePopup>
164+
)}
72165
</FlexBox.Column>
73166
);
74167
};

src/ui/layouts/stacks/StackDetail/Configuration/useService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import YAML from 'json2yaml';
66
interface ServiceInterface {
77
downloadYamlFile: () => void;
88
stackConfig: string;
9+
stack: any;
910
}
1011

1112
export const useService = ({ stackId }: { stackId: TId }): ServiceInterface => {
@@ -39,5 +40,5 @@ export const useService = ({ stackId }: { stackId: TId }): ServiceInterface => {
3940
element.click();
4041
};
4142

42-
return { downloadYamlFile, stackConfig };
43+
return { downloadYamlFile, stackConfig, stack };
4344
};

0 commit comments

Comments
 (0)