Skip to content

Commit

Permalink
🐛 Add link to associated ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Nov 21, 2023
1 parent d215b73 commit 90c0c95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
43 changes: 29 additions & 14 deletions client/src/app/pages/migration-waves/components/ticket-issue.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import React from "react";
import { Text } from "@patternfly/react-core";
import { Button, Text, TextVariants } from "@patternfly/react-core";

import { Ticket } from "@app/api/models";
import { useTrackerTypesByProjectId } from "@app/queries/trackers";
import { useTranslation } from "react-i18next";
import { UnlinkIcon } from "@patternfly/react-icons";
import { useDeleteTicketMutation } from "@app/queries/migration-waves";

export interface ITicketIssueProps {
ticket?: Ticket;
}

export const TicketIssue: React.FC<ITicketIssueProps> = ({ ticket }) => {
const useTicketIssue = () => {
const types = useTrackerTypesByProjectId(
ticket?.tracker?.name,
ticket?.parent
);
const type = types.find((kind) => kind.id === ticket?.kind);
if (type) return type.name;
return "";
};
const { t } = useTranslation();
const { mutate: deleteTicket } = useDeleteTicketMutation();

const ticketIssue = useTicketIssue();

return <Text>{ticketIssue}</Text>;
return (
<>
<Text
component={TextVariants.p}
className="pf-v5-u-color-200 pf-v5-u-font-weight-light"
>
{ticket ? (
<a href={ticket.link} target="_">
{ticket?.link}
</a>
) : (
t("terms.unassigned")
)}
{ticket?.id && (
<Button
variant="link"
icon={<UnlinkIcon />}
onClick={() => deleteTicket(ticket.id)}
/>
)}
</Text>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
getTicketByApplication(tickets, app?.id)?.status || ""
)}
</Td>
<Td width={20} {...getTdProps({ columnKey: "issue" })}>
<Td width={30} {...getTdProps({ columnKey: "issue" })}>
<TicketIssue
ticket={getTicketByApplication(tickets, app.id)}
/>
Expand Down

0 comments on commit 90c0c95

Please sign in to comment.