Skip to content

Commit 8a826f1

Browse files
committed
Merge branch 'dev' of https://github.com/zenml-io/zenml-dashboard into stack-creation-fixes
2 parents 915d92e + 049bfea commit 8a826f1

File tree

9 files changed

+110
-16
lines changed

9 files changed

+110
-16
lines changed
Lines changed: 5 additions & 0 deletions
Loading

src/ui/components/icons/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { ReactComponent as Search } from './assets/Search.svg';
4747
import { ReactComponent as Logs } from './assets/Logs.svg';
4848
import { ReactComponent as PlusCircle } from './assets/PlusCircle.svg';
4949
import { ReactComponent as MinusCircle } from './assets/MinusCircle.svg';
50+
import { ReactComponent as Config } from './assets/Config.svg';
5051
//icons for stackComponents
5152
// import { ReactComponent as PuzzlePiece } from './assets/PuzzlePiece.svg';
5253
import { ReactComponent as Folders } from './assets/Folders.svg';
@@ -176,7 +177,7 @@ const icons = {
176177
search: createIcon({ Component: Search }),
177178
run: createIcon({ Component: Run, useStroke: true }),
178179
logs: createIcon({ Component: Logs, useStroke: true }),
179-
180+
config: createIcon({ Component: Config, useStroke: true }),
180181
plusCircle: createIcon({ Component: PlusCircle, useStroke: true }),
181182
minusCircle: createIcon({ Component: MinusCircle, useStroke: true }),
182183
//icons for stackComponents

src/ui/layouts/NonEditableRunConfig/index.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
background: rgba(168, 168, 168, 0.1);
1616
border: 1px solid #C9CBD0;
1717
border-radius: 4px;
18+
position: relative;
1819

1920
}
21+
.copy{
22+
right: 10px;
23+
position: absolute;
24+
cursor: pointer;
25+
}
2026

2127
.switch {
2228
position: relative;

src/ui/layouts/NonEditableRunConfig/index.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import React from 'react';
2-
import { Box, EditField, Paragraph } from '../../components';
2+
import { Box, EditField, FlexBox, Paragraph, icons } from '../../components';
33
import styles from './index.module.scss';
44
import { titleCase } from '../../../utils';
55
import { ToggleField } from '../common/FormElement';
66
import JSONPretty from 'react-json-pretty';
7+
import { useDispatch } from '../../hooks';
8+
import { showToasterAction } from '../../../redux/actions';
9+
import { iconColors, iconSizes, toasterTypes } from '../../../constants';
710

811
export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
912
runConfiguration,
1013
}) => {
14+
const dispatch = useDispatch();
1115
const getFormElement: any = (elementName: any, elementSchema: any) => {
1216
if (typeof elementSchema === 'string') {
1317
return (
@@ -28,6 +32,16 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
2832
}
2933

3034
if (typeof elementSchema === 'object' && elementSchema !== null) {
35+
const handleCopy = () => {
36+
navigator.clipboard.writeText(JSON.stringify(elementSchema));
37+
38+
dispatch(
39+
showToasterAction({
40+
description: 'Config copied to clipboard',
41+
type: toasterTypes.success,
42+
}),
43+
);
44+
};
3145
return (
3246
<Box marginTop='lg' style={{ width: '40%' }}>
3347
<Paragraph size="body" style={{ color: 'black' }}>
@@ -38,6 +52,12 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
3852
// marginVertical={'md'}
3953
className={styles.JSONPretty}
4054
>
55+
<icons.copy
56+
className={styles.copy}
57+
onClick={handleCopy}
58+
color={iconColors.black}
59+
size={iconSizes.sm}
60+
/>
4161
<JSONPretty
4262
style={{ fontSize: '16px', fontFamily: 'Rubik' }}
4363
id="json-pretty"
@@ -64,11 +84,11 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
6484
<span className={`${styles.slider} ${styles.round}`}></span>
6585
</label>
6686
</FlexBox.Row> */}
67-
<ToggleField
68-
value={elementSchema}
69-
onHandleChange={() => {}}
70-
label={titleCase(elementName)}
71-
disabled={true}
87+
<ToggleField
88+
value={elementSchema}
89+
onHandleChange={() => {}}
90+
label={titleCase(elementName)}
91+
disabled={true}
7292
/>
7393
</Box>
7494
</Box>
@@ -77,12 +97,12 @@ export const NonEditableRunConfig: React.FC<{ runConfiguration: any }> = ({
7797
};
7898

7999
return (
80-
<>
100+
<FlexBox.Column marginLeft="md">
81101
{Object.keys(runConfiguration).map((key, ind) => (
82102
// <Col xs={6} key={ind}>
83103
<>{getFormElement(key, runConfiguration[key])}</>
84104
// </Col>
85105
))}
86-
</>
106+
</FlexBox.Column>
87107
);
88108
};

src/ui/layouts/common/CustomStackBox/index.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
position: absolute;
1818
}
1919

20+
.viewConfig {
21+
height: 18px;
22+
width: 18px;
23+
right:4px;
24+
accent-color: $primaryColor;
25+
position: absolute;
26+
}
27+
2028

2129
.imageWrapper {
2230
display: flex;

src/ui/layouts/common/CustomStackBox/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import React from 'react';
2-
import { Box, Paragraph } from '../../../components';
2+
import { Box, Paragraph, icons } from '../../../components';
33

44
import styles from './index.module.scss';
55
import { titleCase } from '../../../../utils/camelCase';
66
import ReactTooltip from 'react-tooltip';
7+
import { iconColors } from '../../../../constants';
78

89
export const CustomStackBox: React.FC<{
910
image: any;
1011
stackName: string;
1112
stackDesc: string;
1213
value?: any;
1314
onCheck: any;
14-
}> = ({ image, stackName, stackDesc, value, onCheck }) => {
15+
onViewConfig: any;
16+
}> = ({ image, stackName, stackDesc, value, onCheck, onViewConfig }) => {
1517
return (
1618
<Box
1719
paddingHorizontal="sm2"
@@ -24,6 +26,15 @@ export const CustomStackBox: React.FC<{
2426
checked={value}
2527
onClick={onCheck}
2628
/>
29+
30+
<icons.config
31+
onClick={onViewConfig}
32+
className={styles.viewConfig}
33+
// size={iconSizes.sm}
34+
// style={{ height: '18px', width: '18px' }}
35+
color={iconColors.primary}
36+
/>
37+
2738
<Box className={styles.imageWrapper}>
2839
<Box className={styles.imageContainer}>
2940
<img src={image} alt="by Zenml" />

src/ui/layouts/common/Table/index.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
.tableTd {
5454
vertical-align: middle;
55+
white-space: nowrap
5556
// height: 53px !important;
5657
}
5758

src/ui/layouts/stackComponents/ConfigureComponent/CreateComponent/index.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import axios from 'axios';
2323
import { routePaths } from '../../../../../routes/routePaths';
2424
import { SidePopup } from '../SidePopup';
2525
import { callActionForStackComponentsForPagination } from '../../Stacks/useService';
26+
// import { keys } from 'lodash';
2627

2728
export const CreateComponent: React.FC<{ flavor: any }> = ({ flavor }) => {
2829
const {
@@ -86,7 +87,7 @@ export const CreateComponent: React.FC<{ flavor: any }> = ({ flavor }) => {
8687

8788
const handleRemoveFields = (parentIndex: any, childIndex: any, name: any) => {
8889
const values = [...inputFields];
89-
debugger;
90+
// debugger;
9091
values[parentIndex][name].splice(childIndex, 1);
9192
setInputFields(values);
9293
};
@@ -322,15 +323,15 @@ export const CreateComponent: React.FC<{ flavor: any }> = ({ flavor }) => {
322323
const { id }: any = workspaces.find(
323324
(item) => item.name === selectedWorkspace,
324325
);
325-
326+
// debugger;
326327
const final: any = {};
327328
inputFields.forEach((ar: any) => {
328329
const keys = Object.keys(ar);
329330
keys.forEach((key) => {
330331
final[key] = {};
331332

332333
ar[key].forEach((nestedArr: any) => {
333-
if (nestedArr.key && nestedArr.value) {
334+
if (nestedArr.key || nestedArr.value) {
334335
final[key] = {
335336
...final[key],
336337
[nestedArr.key]: nestedArr.value,
@@ -343,7 +344,27 @@ export const CreateComponent: React.FC<{ flavor: any }> = ({ flavor }) => {
343344
});
344345
});
345346
});
346-
347+
for (const [key] of Object.entries(final)) {
348+
// console.log(`${key}: ${value}`);
349+
for (const [innerKey, innerValue] of Object.entries(final[key])) {
350+
if (!innerKey && innerValue) {
351+
return dispatch(
352+
showToasterAction({
353+
description: 'Key cannot be Empty.',
354+
type: toasterTypes.failure,
355+
}),
356+
);
357+
}
358+
if (!innerValue && innerKey) {
359+
return dispatch(
360+
showToasterAction({
361+
description: 'Value cannot be Empty.',
362+
type: toasterTypes.failure,
363+
}),
364+
);
365+
}
366+
}
367+
}
347368
const body = {
348369
user: user?.id,
349370
workspace: id,

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,36 @@ export const GetList: React.FC<Props> = ({
120120
marginLeft="md"
121121
style={{ cursor: 'pointer' }}
122122
onClick={() => {
123-
setShowPopup(true);
123+
// setShowPopup(true);
124124
setSelectedStackBox(item);
125+
var index = selectedStack.findIndex(function (s: any) {
126+
return s.id === item.id;
127+
});
128+
if (index !== -1) {
129+
selectedStack.splice(index, 1);
130+
setSelectedStack([...selectedStack]);
131+
} else {
132+
if (selectedStack.map((t: any) => t.type === item.type)) {
133+
let filterSelectedStack = selectedStack.filter(
134+
(st: any) => st.type !== item.type,
135+
);
136+
setSelectedStack([...filterSelectedStack, item]);
137+
} else {
138+
setSelectedStack([...selectedStack, item]);
139+
}
140+
}
125141
}}
126142
>
127143
{console.log(selectedStack, 'selectedStackselectedStack')}
128144
<CustomStackBox
129145
image={item?.logoUrl}
130146
stackName={item.name}
131147
stackDesc={item?.flavor}
148+
onViewConfig={(e: any) => {
149+
e.stopPropagation();
150+
setSelectedStackBox(item);
151+
setShowPopup(true);
152+
}}
132153
value={checkboxValue?.length > 0 ? true : false}
133154
onCheck={(e: any) => {
134155
e.stopPropagation();

0 commit comments

Comments
 (0)