Skip to content

Commit de88442

Browse files
authored
Merge pull request #42 from CSCfi/CSCFC4EMSCR-305-Show-Crosswalk-List
Crosswalk List in the content page
2 parents 542bcc2 + e4306f7 commit de88442

File tree

2 files changed

+40
-72
lines changed

2 files changed

+40
-72
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useTranslation } from 'next-i18next';
22
import { Button } from 'suomifi-ui-components';
33
import { List, ListItem } from './crosswalk-list.styles';
4-
import { Grid } from '@mui/material';
4+
import { Grid, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
55
import router from 'next/router';
66
import { Crosswalk } from '@app/common/interfaces/crosswalk.interface';
7+
import { getLanguageVersion } from '@app/common/utils/get-language-version';
78

89
export interface CrosswalkListProps {
910
items: Partial<Crosswalk>[];
@@ -13,90 +14,58 @@ export interface CrosswalkListProps {
1314
}
1415

1516
export default function CrosswalkList({
16-
items,
17-
handleRemoval,
18-
deleteDisabled,
17+
items
1918
}: CrosswalkListProps) {
2019
const { t } = useTranslation('admin');
2120

2221
if (items && items.length < 1) {
22+
items = [];
2323
return <div>{'There is no Crosswalks to show'}</div>;
2424
}
2525

2626
function handleClick(pid: string) {
2727
// will go the crosswalk detail page
28-
router.push('/crosswalk');
28+
router.push(`/crosswalk/${pid}`);
2929
}
3030

3131
return (
3232
//Creating Header row
3333
<div>
34-
<List className="header-list">
35-
<ListItem>
36-
<Grid container spacing={2} style={{ fontWeight: 'bold' }}>
37-
<Grid item xs={2}>
38-
{'Name'}
39-
</Grid>
40-
<Grid item xs={2}>
41-
{'Namespace'}
42-
</Grid>
43-
<Grid item xs={2}>
44-
{'Status'}
45-
</Grid>
46-
<Grid item xs={2}>
47-
{'Revision'}
48-
</Grid>
49-
<Grid item xs={2}>
50-
{'PID'}
51-
</Grid>
52-
<Grid item xs={2}></Grid>
53-
</Grid>
54-
</ListItem>
55-
</List>
56-
<List className="inline-list">
57-
{items &&
58-
items.map((item) => (
59-
<ListItem
60-
key={item.pid}
61-
onClick={() => handleClick(item.pid)}
62-
onMouseEnter={() => item.onMouseEnter && item.onMouseEnter()}
63-
onMouseLeave={() => item.onMouseLeave && item.onMouseLeave()}
64-
onKeyDown={(e) => e.key === 'Enter' && item.onClick()}
65-
>
66-
<Grid container spacing={2}>
67-
<Grid item xs={2}>
68-
{item.label}
69-
</Grid>
70-
<Grid item xs={2}>
71-
{item.namespace}
72-
</Grid>
73-
<Grid item xs={2}>
74-
{item.status}
75-
</Grid>
76-
<Grid item xs={2}>
77-
{item.versionLabel}
78-
</Grid>
79-
<Grid item xs={2}>
80-
{item.pid}
81-
</Grid>
82-
<Grid item xs={2}>
83-
{Array.isArray(deleteDisabled) &&
84-
deleteDisabled.includes(item.pid) ? (
85-
<></>
86-
) : (
87-
<Button
88-
variant="secondaryNoBorder"
89-
icon="remove"
90-
onClick={() => handleRemoval(item.pid)}
91-
>
92-
{t('remove')}
93-
</Button>
94-
)}
95-
</Grid>
96-
</Grid>
97-
</ListItem>
98-
))}
99-
</List>
34+
<TableContainer>
35+
<Table aria-label={'Schemas'}>
36+
<TableHead>
37+
<TableRow>
38+
<TableCell> {'Name'}</TableCell>
39+
<TableCell>{'Namespace'}</TableCell>
40+
<TableCell>{'Status'}</TableCell>
41+
<TableCell>{'Revision'}</TableCell>
42+
<TableCell>{'PID'}</TableCell>
43+
</TableRow>
44+
</TableHead>
45+
<TableBody>
46+
{/*TODO: Use the below template to create lines for files*/}
47+
{items &&
48+
items.map((item) => (
49+
<TableRow
50+
key={item.pid}
51+
hover={true}
52+
onClick={() => handleClick(item.pid)}
53+
sx={{ cursor: 'pointer' }}
54+
>
55+
<TableCell>
56+
{item.label?.en}
57+
{/*getLanguageVersion({ data: item.label, lang })*/}
58+
</TableCell>
59+
<TableCell>{item.namespace}</TableCell>
60+
<TableCell>{item.state}</TableCell>
61+
<TableCell>{item.versionLabel}</TableCell>
62+
<TableCell>{item.pid}</TableCell>
63+
</TableRow>
64+
))}
65+
</TableBody>
66+
</Table>
67+
</TableContainer>
10068
</div>
69+
10170
);
10271
}

mscr-ui/src/common/components/table/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default function BasicTable() {
5252
></SchemaList>
5353

5454
{'Crosswalks'}
55-
<Separator isLarge />
5655

5756
<CrosswalkList
5857
items={crosswalks ?? []}

0 commit comments

Comments
 (0)