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(log): [new-bug] added artifacts to new bug #202

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
48 changes: 29 additions & 19 deletions libs/shared/tailwind-ui/src/lib/new-bug/new-bug.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ import { useCopyToClipboard } from '@/shared/hooks';
import { config } from '@/bublik/config';

import { cn, toast } from '../utils';
import {
Dialog,
DialogContent,
DialogOverlay,
DialogTrigger,
dialogContentStyles,
dialogOverlayStyles
} from '../dialog';
import { DialogOverlay, dialogOverlayStyles } from '../dialog';
import { ButtonTw } from '../button';
import { Icon } from '../icon';
import { DrawerContent, DrawerRoot, DrawerTrigger } from '../drawer';
Expand Down Expand Up @@ -67,14 +60,21 @@ function getBugProps(
.filter((v) => !!v)
.flat();

const verdicts =
log.root
.flatMap((b) => b.content)
.filter((b) => b.type === 'te-log-meta')
.map((meta) => meta.meta.verdicts)
.filter((v) => !!v)
.flat()
.map((v) => v.verdict) ?? [];
const verdicts = log.root
.flatMap((b) => b.content)
.filter((b) => b.type === 'te-log-meta')
.map((meta) => meta.meta.verdicts)
.filter((v) => !!v)
.flat()
.map((v) => v.verdict);

const artifacts = log.root
.flatMap((b) => b.content)
.filter((b) => b.type === 'te-log-meta')
.map((meta) => meta.meta.artifacts)
.filter((v) => !!v)
.flat()
.map((v) => v.artifact);

const objectives = (log.root
.flatMap((b) => b.content)
Expand Down Expand Up @@ -121,7 +121,8 @@ function getBugProps(
parameters
},
objectives,
verdicts
verdicts,
artifacts
};
}

Expand Down Expand Up @@ -235,8 +236,7 @@ function getFormattedMarkdown(options: NewBugButtonProps): string {
markdown += `Path: \`${options.path}\`\n`;
}

// CMD
// TODO: Fix configration key
// TODO: Fix configuration key
const haveConfigurations = Object.entries(
options.tags.specialCategories
).some(([_, value]) => value.length > 0);
Expand Down Expand Up @@ -276,6 +276,14 @@ function getFormattedMarkdown(options: NewBugButtonProps): string {
)}\n\n`;
}

if (options.artifacts?.length) {
markdown += '\n## Artifacts\n\n';
markdown += `${generateMarkdownTable(
options.artifacts.map((v) => ({ value: v })),
[{ accessor: 'value', header: 'Value' }]
)}\n\n`;
}

// 2. Branches
if (options.tags.branches.length) {
markdown += `\n## Branches\n\n`;
Expand Down Expand Up @@ -325,6 +333,7 @@ function getFormattedMarkdown(options: NewBugButtonProps): string {
}
);
}

return markdown;
} catch (e) {
console.error(e);
Expand All @@ -349,6 +358,7 @@ interface NewBugButtonProps {
tags: BugTags;
isDisabled?: boolean;
objectives?: string[];
artifacts?: string[];
lineLink?: string;
}

Expand Down