Skip to content

Commit 6051eca

Browse files
authored
Merge pull request #94 from zenml-io/table-expand/collapse-flow
Table expand/collapse flow
2 parents 8df3605 + 7519b7a commit 6051eca

File tree

2 files changed

+86
-31
lines changed

2 files changed

+86
-31
lines changed

src/ui/layouts/stackComponents/StackDetail/index.tsx

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React, { useState } from 'react';
22

33
import { routePaths } from '../../../../routes/routePaths';
4-
import { Box, Paragraph, icons } from '../../../components';
5-
import { iconColors, iconSizes } from '../../../../constants';
6-
import {
7-
camelCaseToParagraph,
8-
formatDateToDisplayOnTable,
9-
} from '../../../../utils';
4+
import { Box } from '../../../components';
5+
// import { iconColors, iconSizes } from '../../../../constants';
6+
import { camelCaseToParagraph } from '../../../../utils';
7+
// import styles from './index.module.scss';
8+
// import cn from 'classnames';
109
import { translate } from './translate';
1110
import { Configuration } from './Configuration';
1211
import { Runs } from './Runs';
@@ -17,6 +16,7 @@ import FilterComponent, {
1716
getInitialFilterStateForRuns,
1817
} from '../../../components/Filters';
1918
import { projectSelectors } from '../../../../redux/selectors';
19+
import { List } from '../Stacks/List';
2020

2121
const FilterWrapperForRun = () => {
2222
const locationPath = useLocationPath();
@@ -119,16 +119,22 @@ export const StackDetail: React.FC = () => {
119119
selectedProject,
120120
);
121121

122-
const boxStyle = {
123-
backgroundColor: '#E9EAEC',
124-
padding: '10px 0',
125-
borderRadius: '8px',
126-
marginTop: '20px',
127-
display: 'flex',
128-
justifyContent: 'space-around',
129-
};
130-
const headStyle = { color: '#828282' };
131-
const paraStyle = { color: '#515151', marginTop: '10px' };
122+
// const boxStyle = {
123+
// backgroundColor: '#E9EAEC',
124+
// padding: '10px 0',
125+
// borderRadius: '8px',
126+
// marginTop: '20px',
127+
// display: 'flex',
128+
// justifyContent: 'space-around',
129+
// };
130+
// const headStyle = { color: '#828282' };
131+
// const paraStyle = { color: '#515151', marginTop: '10px' };
132+
// const data = [
133+
// { name: 'Anom', age: 19, gender: 'Male' },
134+
// { name: 'Megha', age: 19, gender: 'Female' },
135+
// { name: 'Subham', age: 25, gender: 'Male' },
136+
// ];
137+
// const history = useHistory();
132138

133139
return (
134140
<BasePage
@@ -140,7 +146,7 @@ export const StackDetail: React.FC = () => {
140146
)}
141147
breadcrumbs={breadcrumbs}
142148
>
143-
<Box style={boxStyle}>
149+
{/* <Box style={boxStyle}>
144150
<Box>
145151
<Paragraph style={headStyle}>ID</Paragraph>
146152
<Paragraph style={paraStyle}>{stackComponent.id}</Paragraph>
@@ -183,6 +189,36 @@ export const StackDetail: React.FC = () => {
183189
{formatDateToDisplayOnTable(stackComponent.created)}
184190
</Paragraph>
185191
</Box>
192+
</Box> */}
193+
<Box paddingTop={'xl'}>
194+
<List
195+
filter={[]}
196+
pagination={false}
197+
isExpended
198+
id={stackComponent.id}
199+
></List>
200+
{/* <>
201+
<table className={cn(styles.table)}>
202+
<tbody>
203+
<tr className={cn(styles.tableHeader)}>
204+
<th className={cn(styles.tableHeaderText)}>Id</th>
205+
<th className={cn(styles.tableHeaderText)}>Name</th>
206+
<th className={cn(styles.tableHeaderText)}>Flavor</th>
207+
<th className={cn(styles.tableHeaderText)}>Shared</th>
208+
<th className={cn(styles.tableHeaderText)}>Author</th>
209+
<th className={cn(styles.tableHeaderText)}>Created</th>
210+
</tr>
211+
<tr className={cn(styles.tableRow)}>
212+
<td>{stackComponent.id}</td>
213+
<td>{stackComponent.name}</td>
214+
<td>{stackComponent.flavor}</td>
215+
<td>{stackComponent.isShared}</td>
216+
<td>{stackComponent.user.name}</td>
217+
<td> {formatDateToDisplayOnTable(stackComponent.created)}</td>
218+
</tr>
219+
</tbody>
220+
</table>
221+
</> */}
186222
</Box>
187223
</BasePage>
188224
);

src/ui/layouts/stackComponents/Stacks/List/index.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@ import {
1717

1818
interface Props {
1919
filter: any;
20+
pagination?: boolean;
21+
id?: string;
22+
isExpended?: boolean;
2023
}
2124

22-
export const List: React.FC<Props> = ({ filter }: Props) => {
25+
export const List: React.FC<Props> = ({
26+
filter,
27+
pagination,
28+
isExpended,
29+
id,
30+
}: // isExpended = false,
31+
Props) => {
2332
const locationPath = useLocationPath();
2433
const selectedProject = useSelector(projectSelectors.selectedProject);
2534
const stackComponentsPaginated = useSelector(
2635
stackComponentSelectors.mystackComponentsPaginated,
2736
);
2837

38+
// const [selectedComponentId, setSelectedComponentId] = useState('');
39+
2940
const history = useHistory();
3041
const {
3142
openStackIds,
@@ -54,19 +65,25 @@ export const List: React.FC<Props> = ({ filter }: Props) => {
5465
const openDetailPage = (stackComponent: TStack) => {
5566
setSelectedRunIds([]);
5667

57-
history.push(
58-
routePaths.stackComponents.configuration(
59-
locationPath.split('/')[4],
60-
stackComponent.id,
61-
selectedProject,
62-
),
63-
);
68+
if (id) {
69+
history.push(
70+
routePaths.stackComponents.base(
71+
locationPath.split('/')[4],
72+
selectedProject,
73+
),
74+
);
75+
} else {
76+
history.push(
77+
routePaths.stackComponents.configuration(
78+
locationPath.split('/')[4],
79+
stackComponent.id,
80+
selectedProject,
81+
),
82+
);
83+
}
6484
};
6585

66-
// const url_string = window.location.href;
67-
// const url = new URL(url_string);
68-
// const projectName = url.searchParams.get('project');
69-
// const project = projectName ? projectName : DEFAULT_PROJECT_NAME;
86+
const expendedRow = filteredStacks.filter((item) => item.id === id);
7087

7188
return (
7289
<>
@@ -84,12 +101,13 @@ export const List: React.FC<Props> = ({ filter }: Props) => {
84101
? activeSorting
85102
: 'created'
86103
}
104+
pagination={pagination}
87105
paginated={stackComponentsPaginated}
88-
loading={fetching}
106+
loading={expendedRow.length > 0 ? false : fetching}
89107
showHeader={true}
90108
filters={filter}
91109
headerCols={headerCols}
92-
tableRows={filteredStacks}
110+
tableRows={expendedRow.length > 0 ? expendedRow : filteredStacks}
93111
emptyState={
94112
filter[0]?.value
95113
? {
@@ -103,6 +121,7 @@ export const List: React.FC<Props> = ({ filter }: Props) => {
103121
}
104122
trOnClick={openDetailPage}
105123
/>
124+
{/* {isExpend ? : <></>} */}
106125
</>
107126
);
108127
};

0 commit comments

Comments
 (0)