mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-26 09:52:14 +03:00
feat(frontend): show client comments on mobile cards (#5942)
* feat(frontend): show client comments on mobile cards * fix(frontend): bound mobile comment height --------- Co-authored-by: sanmaxdev <sanmaxdev@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
1cfd7b49b0
commit
658e6ab3d3
14
frontend/src/components/clients/ClientCardComment.tsx
Normal file
14
frontend/src/components/clients/ClientCardComment.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
type ClientCardCommentProps = {
|
||||||
|
comment?: string;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ClientCardComment({ comment, className = 'client-card-comment' }: ClientCardCommentProps) {
|
||||||
|
if (!comment) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={className} title={comment}>
|
||||||
|
{comment}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -162,6 +162,17 @@
|
|||||||
background: color-mix(in srgb, var(--ant-color-primary) 6%, transparent);
|
background: color-mix(in srgb, var(--ant-color-primary) 6%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.client-card-comment {
|
||||||
|
display: block;
|
||||||
|
margin-top: 6px;
|
||||||
|
color: var(--ant-color-text-secondary);
|
||||||
|
font-size: 12px;
|
||||||
|
max-height: 4.5em;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
.client-card-speed {
|
.client-card-speed {
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import { useDatepicker } from '@/hooks/useDatepicker';
|
|||||||
import type { ClientRecord, InboundOption, ExternalLink, ExternalLinkInput } from '@/hooks/useClients';
|
import type { ClientRecord, InboundOption, ExternalLink, ExternalLinkInput } from '@/hooks/useClients';
|
||||||
import ClientTrafficCell from '@/components/clients/ClientTrafficCell';
|
import ClientTrafficCell from '@/components/clients/ClientTrafficCell';
|
||||||
import ClientSpeedTag, { isActiveSpeed } from '@/components/clients/ClientSpeedTag';
|
import ClientSpeedTag, { isActiveSpeed } from '@/components/clients/ClientSpeedTag';
|
||||||
|
import ClientCardComment from '@/components/clients/ClientCardComment';
|
||||||
import AppSidebar from '@/layouts/AppSidebar';
|
import AppSidebar from '@/layouts/AppSidebar';
|
||||||
import { IntlUtil, SizeFormatter } from '@/utils';
|
import { IntlUtil, SizeFormatter } from '@/utils';
|
||||||
import { setMessageInstance } from '@/utils/messageBus';
|
import { setMessageInstance } from '@/utils/messageBus';
|
||||||
@@ -818,7 +819,7 @@ export default function ClientsPage() {
|
|||||||
<div className="email-cell">
|
<div className="email-cell">
|
||||||
<span className="email">{record.email}</span>
|
<span className="email">{record.email}</span>
|
||||||
{record.subId && <span className="sub" title={record.subId}>{record.subId}</span>}
|
{record.subId && <span className="sub" title={record.subId}>{record.subId}</span>}
|
||||||
{record.comment && <span className="sub" title={record.comment}>{record.comment}</span>}
|
<ClientCardComment comment={record.comment} className="sub" />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -1433,6 +1434,7 @@ export default function ClientsPage() {
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ClientCardComment comment={row.comment} />
|
||||||
<ClientTrafficCell
|
<ClientTrafficCell
|
||||||
compact
|
compact
|
||||||
up={row.traffic?.up}
|
up={row.traffic?.up}
|
||||||
|
|||||||
27
frontend/src/test/client-card-comment.test.tsx
Normal file
27
frontend/src/test/client-card-comment.test.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import ClientCardComment from '@/components/clients/ClientCardComment';
|
||||||
|
|
||||||
|
describe('ClientCardComment', () => {
|
||||||
|
it('renders a client comment in the card', () => {
|
||||||
|
render(<ClientCardComment comment={'Primary mobile client\nLine two'} />);
|
||||||
|
|
||||||
|
const comment = screen.getByText(/Primary mobile client/);
|
||||||
|
expect(comment.className).toContain('client-card-comment');
|
||||||
|
expect(comment.textContent).toBe('Primary mobile client\nLine two');
|
||||||
|
expect(comment.getAttribute('title')).toBe('Primary mobile client\nLine two');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports the compact desktop style', () => {
|
||||||
|
render(<ClientCardComment comment="Desktop comment" className="sub" />);
|
||||||
|
|
||||||
|
expect(screen.getByText('Desktop comment').className).toBe('sub');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders nothing when no comment is set', () => {
|
||||||
|
const { container } = render(<ClientCardComment comment="" />);
|
||||||
|
|
||||||
|
expect(container.childElementCount).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user