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

🐛 Add a fallback for issue title #1273

Merged
merged 1 commit into from
Aug 10, 2023
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
16 changes: 14 additions & 2 deletions client/src/app/pages/issues/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Location, LocationDescriptor } from "history";
import { AnalysisIssueReport, AnalysisRuleReport } from "@app/api/models";
import {
AnalysisIssue,
AnalysisIssueReport,
AnalysisRuleReport,
} from "@app/api/models";
import {
FilterCategory,
FilterType,
Expand Down Expand Up @@ -113,11 +117,12 @@ export const getAffectedAppsUrl = ({
.replace("/:rule/", `/${encodeURIComponent(ruleReport.rule)}/`);
const prefix = (key: string) =>
`${TableURLParamKeyPrefix.issuesAffectedApps}:${key}`;

return `${baseUrl}?${trimAndStringifyUrlParams({
newPrefixedSerializedParams: {
[prefix("filters")]: serializeFilterUrlParams(toFilterValues).filters,
[FROM_ISSUES_PARAMS_KEY]: fromIssuesParams,
issueTitle: ruleReport.description.split("\n")[0],
issueTitle: getIssueTitle(ruleReport),
},
})}`;
};
Expand Down Expand Up @@ -195,3 +200,10 @@ export const parseReportLabels = (
});
return { sources, targets, otherLabels };
};

export const getIssueTitle = (
issueReport: AnalysisRuleReport | AnalysisIssue | AnalysisIssueReport
) =>
issueReport?.description?.split("\n")[0] ||
issueReport?.name?.split("\n")[0] ||
"*Unnamed*";
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useFetchIncidents } from "@app/queries/issues";
import { IncidentCodeSnipViewer } from "./incident-code-snip-viewer";
import { FileAllIncidentsTable } from "./file-all-incidents-table";
import { IssueDescriptionAndLinks } from "../../components/issue-description-and-links";
import { getIssueTitle } from "../../helpers";

export interface IFileIncidentsDetailModalProps {
issue: AnalysisIssue;
Expand Down Expand Up @@ -58,7 +59,7 @@ export const FileIncidentsDetailModal: React.FC<
isFetching ||
(firstFiveIncidents.length > 0 && activeTabIncidentId === undefined);

const issueTitle = issue.description.split("\n")[0];
const issueTitle = getIssueTitle(issue);

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IssueAffectedFilesTable } from "./issue-affected-files-table";
import { useFetchIssue } from "@app/queries/issues";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
import { StateNoData } from "@app/components/StateNoData";
import { getIssueTitle } from "../helpers";

export interface IIssueDetailDrawerProps
extends Pick<IPageDrawerContentProps, "onCloseClick"> {
Expand Down Expand Up @@ -61,7 +62,7 @@ export const IssueDetailDrawer: React.FC<IIssueDetailDrawerProps> = ({
{applicationName}
</Text>
<Title headingLevel="h2" size="lg" className={spacing.mtXs}>
<Truncate content={issue.description.split("\n")[0]} />
<Truncate content={getIssueTitle(issue)} />
</Title>
</TextContent>
<Tabs
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/pages/issues/issues-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
parseReportLabels,
getIssuesSingleAppSelectedLocation,
useSharedAffectedApplicationFilterCategories,
getIssueTitle,
} from "./helpers";
import { IssueFilterGroups } from "./issues";
import {
Expand Down Expand Up @@ -354,7 +355,7 @@ export const IssuesTable: React.FC<IIssuesTableProps> = ({ mode }) => {
{...getTdProps({ columnKey: "description" })}
modifier="truncate"
>
{report.description.split("\n")[0]}
{getIssueTitle(report)}
</Td>
<Td width={20} {...getTdProps({ columnKey: "category" })}>
{report.category}
Expand Down