mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-23 11:44:10 -05:00
* chore: mui v6 * chore: add react-is * chore: fix connection history * chore: skip some tests * chore: lint * fix: some tests * chore: get rid of v4 theme adapt * chore: revert bg color changes * chore: revert bg color changes
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import Remove from '@nebula.js/ui/icons/remove';
|
|
import { useNavigate } from 'react-router';
|
|
import { ListItemButton, ListItemText, List, Typography, Box, IconButton } from '@mui/material';
|
|
import { useRootContext } from '../../../contexts/RootContext';
|
|
import { checkIfHistoryConnectionDisabled } from '../../../utils';
|
|
|
|
const ConnectionHistory = () => {
|
|
const navigate = useNavigate();
|
|
const { info, setError, cachedConnectionsData } = useRootContext();
|
|
|
|
const handleHistoryItemClick = (item) => {
|
|
setError();
|
|
navigate(`/app-list?engine_url=${item.replace('?', '&')}`);
|
|
};
|
|
|
|
if (!cachedConnectionsData.cachedConnections.length) return null;
|
|
|
|
return (
|
|
<Box mb={2}>
|
|
<Typography variant="h6">Previous connections</Typography>
|
|
<List>
|
|
{cachedConnectionsData.cachedConnections.map((item) => (
|
|
<ListItemButton
|
|
key={item}
|
|
component="a"
|
|
onClick={() => handleHistoryItemClick(item)}
|
|
disabled={checkIfHistoryConnectionDisabled({ item, info })}
|
|
>
|
|
<ListItemText primary={item} />
|
|
<IconButton
|
|
onClick={() => cachedConnectionsData.removeCachedConnection(item)}
|
|
data-testid="close-btn"
|
|
size="large"
|
|
edge="end"
|
|
>
|
|
<Remove />
|
|
</IconButton>
|
|
</ListItemButton>
|
|
))}
|
|
</List>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default ConnectionHistory;
|