Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(document): improve document list layout + fix warnings #942

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions packages/web-app/src/components/common/DocumentsList/Document.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import {
Chip,
ListItem,
ListItemText,
ListItemIcon,
Typography,
ButtonGroup,
Tooltip,
Button
Expand All @@ -18,7 +18,7 @@ import { SnapshotButton } from '../../appli/Entry/Snapshots/UtilityFunction';
import Translate from '../Translate';
import StandardDialog from '../StandardDialog';

const StyledListItemText = styled(ListItemText)`
const StyledListItemContainer = styled.div`
width: 100%;
margin: 0;
`;
Expand All @@ -32,8 +32,9 @@ const StyledListItem = styled(ListItem)`
margin: 0;
`;

const DocumentDescription = styled.div`
white-space: pre;
const DocumentDescription = styled(Typography)`
margin: 0.5em 0;
white-space: break-spaces;
color: ${({ theme }) => theme.palette.text.primary};
`;

Expand All @@ -43,34 +44,27 @@ const Document = ({ document, hasSnapshotButton = false, onUnlink }) => {

return (
<StyledListItem>
<StyledListItemText
primary={
<>
<GCLink internal={false} href={`/ui/documents/${document.id}`}>
{document.title}
</GCLink>
<StyledChip
variant="outlined"
size="small"
color="primary"
label={
(document.type && formatMessage({ id: document.type })) ||
formatMessage({ id: 'unknown' })
}
/>
</>
}
secondary={
<>
{document.description ? (
<DocumentDescription>{document.description}</DocumentDescription>
) : (
false
)}
{document.files ? <Files files={document.files} /> : false}
</>
}
/>
<StyledListItemContainer>
<GCLink internal={false} href={`/ui/documents/${document.id}`}>
{document.title}
</GCLink>
<StyledChip
variant="outlined"
size="small"
color="primary"
label={
(document.type && formatMessage({ id: document.type })) ||
formatMessage({ id: 'unknown' })
}
/>
{document.description ? (
<DocumentDescription>{document.description}</DocumentDescription>
) : (
false
)}
{document.files ? <Files files={document.files} /> : false}
</StyledListItemContainer>

{hasSnapshotButton || onUnlink ? (
<ListItemIcon style={{ alignSelf: 'start' }}>
<ButtonGroup color="primary">
Expand Down Expand Up @@ -112,12 +106,14 @@ const Document = ({ document, hasSnapshotButton = false, onUnlink }) => {
title={formatMessage({ id: 'Unlink this document?' })}
actions={[
<Button
key="no"
onClick={() => setUnlinkDialogOpen(false)}
color="default"
disableElevation>
<Translate>No</Translate>
</Button>,
<Button
key="yes"
disableElevation
onClick={() => {
setUnlinkDialogOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const DocumentsList = ({
{documents && documents.length > 0 ? (
<List>
{documents.map((document, i) => (
<li key={document.id}>
<div key={document.id}>
<Document
document={document}
hasSnapshotButton={hasSnapshotButton}
onUnlink={onUnlink}
/>
{documents.length - 1 !== i && <DividerStyled variant="middle" />}
</li>
</div>
))}
</List>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Files = ({ files }) => {
if (files.length === 0) return false;

return files.map(file => (
<FileListItem key={`${file.fileName}`} dense>
<FileListItem key={`${file.fileName}`} dense component="div">
<ListItemText
primaryTypographyProps={{ display: 'inline' }}
primary={
Expand Down
Loading