Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/api/src/audit/audit-log.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const COMMENT_ENTITY_TYPE_MAP: Record<string, AuditLogEntityType> = {
[CommentEntityType.vendor]: AuditLogEntityType.vendor,
[CommentEntityType.risk]: AuditLogEntityType.risk,
[CommentEntityType.policy]: AuditLogEntityType.policy,
[CommentEntityType.finding]: AuditLogEntityType.finding,
};

// Fields that reference the member table and should be resolved to user names.
Expand Down
21 changes: 21 additions & 0 deletions apps/api/src/comments/comment-mention-notifier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ async function buildFallbackCommentContext(params: {
};
}

if (entityType === CommentEntityType.finding) {
const finding = await db.finding.findFirst({
where: { id: entityId, organizationId },
select: { content: true },
});

if (!finding) {
return null;
}

const url = new URL(`${appUrl}/${organizationId}/overview/findings`);
url.searchParams.set('open', entityId);

const snippet = finding.content?.trim().split('\n')[0]?.slice(0, 80);
return {
entityName: snippet || 'Finding',
entityRoutePath: 'overview/findings',
commentUrl: url.toString(),
};
}

// CommentEntityType.policy
const policy = await db.policy.findFirst({
where: { id: entityId, organizationId },
Expand Down
8 changes: 8 additions & 0 deletions apps/api/src/comments/comments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ export class CommentsService {
break;
}

case CommentEntityType.finding: {
const finding = await db.finding.findFirst({
where: { id: entityId, organizationId },
});
entityExists = !!finding;
break;
}

default:
throw new BadRequestException(`Unsupported entity type: ${entityType}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
function capitalize(s: string) {
return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
}
import { Comments } from '@/components/comments/Comments';
import { usePermissions } from '@/hooks/use-permissions';
import { useSession } from '@/utils/auth-client';
import { FindingSeverity, FindingStatus } from '@db';
Expand Down Expand Up @@ -409,6 +410,18 @@ export function FindingDetailSheet({
</HStack>
</HStack>

<Stack gap="xs">
<Text size="sm" weight="medium">
Comments
</Text>
<Comments
entityId={finding.id}
entityType="finding"
organizationId={organizationId}
readOnly={!canUpdate}
/>
</Stack>

<Stack gap="xs">
<Text size="sm" weight="medium">
Activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "CommentEntityType" ADD VALUE 'finding';
1 change: 1 addition & 0 deletions packages/db/prisma/schema/comment.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ enum CommentEntityType {
vendor
risk
policy
finding
}
Loading