-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d215b73
commit 90c0c95
Showing
2 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
43 changes: 29 additions & 14 deletions
43
client/src/app/pages/migration-waves/components/ticket-issue.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters