Skip to content
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
29 changes: 25 additions & 4 deletions client/src/components/TicketAttachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ export function TicketAttachments({
const isVideo = (type: string) => type.startsWith('video/');
const isPdf = (type: string) => type === 'application/pdf';

const normalizedCdnHost = config?.cdnDomain
? (() => {
const raw = config.cdnDomain.trim();
try {
const parsed = new URL(raw.startsWith('http') ? raw : `https://${raw}`);
return parsed.hostname.toLowerCase();
} catch {
return raw.replace(/^https?:\/\//i, '').split('/')[0].toLowerCase();
}
})()
: null;

const isTrustedCdnUrl = (url: string) => {
if (!normalizedCdnHost) return false;
try {
return new URL(url).hostname.toLowerCase() === normalizedCdnHost;
} catch {
return false;
}
};

if (!config?.backblazeConfigured) {
return (
<div className="p-4 bg-muted/50 rounded-lg">
Expand Down Expand Up @@ -200,19 +221,19 @@ export function TicketAttachments({
<DialogTitle>{attachment.fileName}</DialogTitle>
</DialogHeader>
<div className="mt-4">
{isImage(attachment.fileType) ? (
{isImage(attachment.fileType) && isTrustedCdnUrl(attachment.url) ? (
<img
src={attachment.url}
alt={attachment.fileName}
className="max-w-full h-auto rounded-lg"
/>
) : isVideo(attachment.fileType) ? (
) : isVideo(attachment.fileType) && isTrustedCdnUrl(attachment.url) ? (
<video
src={attachment.url}
controls
className="max-w-full h-auto rounded-lg"
/>
) : isPdf(attachment.fileType) ? (
) : isPdf(attachment.fileType) && isTrustedCdnUrl(attachment.url) ? (
<iframe
src={attachment.url}
className="w-full h-96 rounded-lg"
Expand Down Expand Up @@ -284,4 +305,4 @@ export function TicketAttachments({
return content;
}

export default TicketAttachments;
export default TicketAttachments;
3 changes: 0 additions & 3 deletions client/src/components/analytics/TicketAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const COLORS = ['#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6', '#ec4899'
const statusColorMap: { [key: string]: string } = {
'Open': '#3b82f6',
'Closed': '#10b981',
'Under Review': '#f59e0b',
'Pending Player Response': '#8b5cf6',
'Resolved': '#10b981',
'Unfinished': '#6b7280'
};

Expand Down
17 changes: 9 additions & 8 deletions client/src/components/dashboard/AssignedTicketUpdatesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from '@modl-gg/shared-web/components/ui/button';
import { UserCheck, Clock, User, MessageSquare, X } from 'lucide-react';
import { useLocation } from 'wouter';
import { formatTimeAgo } from '@/utils/date-utils';
import { stripMarkdown } from '@/utils/markdown-utils';

const INITIAL_VISIBLE = 2;
const LOAD_MORE_COUNT = 2;
Expand All @@ -24,13 +25,13 @@ export interface AssignedTicketUpdate {
interface AssignedTicketUpdatesSectionProps {
updates: AssignedTicketUpdate[];
loading: boolean;
onMarkAsRead: (updateId: string) => Promise<void>;
onDismissTicket: (ticketId: string) => Promise<void>;
}

export function AssignedTicketUpdatesSection({
updates,
loading,
onMarkAsRead,
onDismissTicket,
}: AssignedTicketUpdatesSectionProps) {
const [, setLocation] = useLocation();
const [visibleCount, setVisibleCount] = useState(INITIAL_VISIBLE);
Expand All @@ -39,17 +40,17 @@ export function AssignedTicketUpdatesSection({
setLocation(`/panel/tickets/${ticketId}`);
};

const handleMarkAsRead = async (updateId: string) => {
const handleDismissTicket = async (ticketId: string) => {
try {
await onMarkAsRead(updateId);
await onDismissTicket(ticketId);
} catch (error) {
console.error('Error marking update as read:', error);
console.error('Error dismissing ticket updates:', error);
}
};

const truncateContent = (content: string | undefined | null, maxLength: number = 100) => {
if (!content) return 'No content available';
const contentStr = String(content);
const contentStr = stripMarkdown(String(content));
if (contentStr.length <= maxLength) return contentStr;
return contentStr.substring(0, maxLength) + '...';
};
Expand Down Expand Up @@ -136,9 +137,9 @@ export function AssignedTicketUpdatesSection({
className="h-6 w-6 p-0 text-muted-foreground hover:text-blue-500"
onClick={(e) => {
e.stopPropagation();
handleMarkAsRead(update.id);
handleDismissTicket(update.ticketId);
}}
title="Mark as read"
title="Dismiss all updates for this ticket"
>
<X className="h-3 w-3" />
</Button>
Expand Down
7 changes: 3 additions & 4 deletions client/src/components/dashboard/RecentTicketsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from '@modl-gg/shared-web/components/ui/button';
import { Ticket, Clock, User } from 'lucide-react';
import { useLocation } from 'wouter';
import { formatTimeAgo } from '@/utils/date-utils';
import { stripMarkdown } from '@/utils/markdown-utils';

export interface RecentTicket {
id: string;
Expand All @@ -25,9 +26,7 @@ interface RecentTicketsSectionProps {
const statusColors: Record<string, string> = {
open: 'bg-blue-500/20 text-blue-500',
closed: 'bg-green-500/20 text-green-500',
under_review: 'bg-yellow-500/20 text-yellow-500',
pending_player_response: 'bg-purple-500/20 text-purple-500',
draft: 'bg-gray-500/20 text-gray-500'
unfinished: 'bg-gray-500/20 text-gray-500'
};

const priorityColors: Record<string, string> = {
Expand All @@ -47,7 +46,7 @@ export function RecentTicketsSection({ tickets, loading }: RecentTicketsSectionP

const truncateMessage = (message: string | undefined | null, maxLength: number = 120) => {
if (!message) return 'No message available';
const messageStr = String(message);
const messageStr = stripMarkdown(String(message));
if (messageStr.length <= maxLength) return messageStr;
return messageStr.substring(0, maxLength) + '...';
};
Expand Down
22 changes: 11 additions & 11 deletions client/src/components/dashboard/TicketSubscriptionsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ interface TicketSubscriptionsSectionProps {
updates: TicketSubscriptionUpdate[];
loading: boolean;
onUnsubscribe: (ticketId: string) => Promise<void>;
onMarkAsRead: (updateId: string) => Promise<void>;
onDismissTicket: (ticketId: string) => Promise<void>;
}

export function TicketSubscriptionsSection({
updates,
loading,
onUnsubscribe,
onMarkAsRead
export function TicketSubscriptionsSection({
updates,
loading,
onUnsubscribe,
onDismissTicket
}: TicketSubscriptionsSectionProps) {
const [, setLocation] = useLocation();
const { toast } = useToast();
Expand All @@ -56,11 +56,11 @@ export function TicketSubscriptionsSection({
}
};

const handleMarkAsRead = async (updateId: string) => {
const handleDismissTicket = async (ticketId: string) => {
try {
await onMarkAsRead(updateId);
await onDismissTicket(ticketId);
} catch (error) {
console.error('Error marking update as read:', error);
console.error('Error dismissing ticket updates:', error);
}
};

Expand Down Expand Up @@ -157,9 +157,9 @@ export function TicketSubscriptionsSection({
className="h-6 w-6 p-0 text-muted-foreground hover:text-blue-500"
onClick={(e) => {
e.stopPropagation();
handleMarkAsRead(update.id);
handleDismissTicket(update.ticketId);
}}
title="Mark as read"
title="Dismiss all updates for this ticket"
>
<X className="h-3 w-3" />
</Button>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/settings/ArticleListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const ArticleListItem: React.FC<ArticleListItemProps> = ({
<div className="flex items-center">
<GripVertical className="mr-2 h-5 w-5 text-muted-foreground cursor-grab" />
<span className="text-sm">{article.title}</span>
{article.is_visible ? (
{article.isVisible ? (
<Eye className="ml-2 h-3 w-3 text-green-600" />
) : (
<EyeOff className="ml-2 h-3 w-3 text-gray-400" />
Expand Down Expand Up @@ -127,4 +127,4 @@ const ArticleListItem: React.FC<ArticleListItemProps> = ({
);
};

export default ArticleListItem;
export default ArticleListItem;
Loading