Skip to content

Commit

Permalink
🐛 Add link to associated ticket (konveyor#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Nov 27, 2023
1 parent 1c663a4 commit c7c6d7c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 53 deletions.
35 changes: 23 additions & 12 deletions client/src/app/pages/migration-waves/components/ticket-issue.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
import React from "react";
import { Text } from "@patternfly/react-core";
import { Text, TextVariants } from "@patternfly/react-core";

import { Ticket } from "@app/api/models";
import { useTranslation } from "react-i18next";
import ExternalLink from "@app/components/ExternalLink";
import { useTrackerTypesByProjectId } from "@app/queries/trackers";

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 ticketIssue = useTicketIssue(ticket);

const ticketIssue = useTicketIssue();
return (
<Text component={TextVariants.p}>
{ticket?.link ? (
<ExternalLink href={ticket.link}>{ticketIssue}</ExternalLink>
) : (
t("terms.unassigned")
)}
</Text>
);
};

const useTicketIssue = (ticket?: Ticket) => {
const types = useTrackerTypesByProjectId(
ticket?.tracker?.name,
ticket?.parent
);
const type = types.find((kind) => kind.id === ticket?.kind);

return <Text>{ticketIssue}</Text>;
return type ? type.name : "";
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { useHistory } from "react-router-dom";
import { useFetchTickets } from "@app/queries/tickets";
import { Paths } from "@app/Paths";
import { TicketIssue } from "./ticket-issue";
import { useDeleteTicketMutation } from "@app/queries/migration-waves";
import UnlinkIcon from "@patternfly/react-icons/dist/esm/icons/unlink-icon";

export interface IWaveStatusTableProps {
migrationWave: WaveWithStatus;
Expand All @@ -44,6 +46,7 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
const history = useHistory();

const { tickets } = useFetchTickets();
const { mutate: deleteTicket } = useDeleteTicketMutation();

const tableControls = useLocalTableControls({
idProperty: "name",
Expand Down Expand Up @@ -130,52 +133,63 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
}
>
<Tbody>
{currentPageItems?.map((app, rowIndex) => (
<Tr key={app.name} {...getTrProps({ item: app })}>
<TableRowContentWithControls
{...tableControls}
item={app}
rowIndex={rowIndex}
>
<Td width={20} {...getTdProps({ columnKey: "appName" })}>
{app.name}
</Td>
<Td width={20} {...getTdProps({ columnKey: "status" })}>
{getTicketByApplication(tickets, app.id)?.error ? (
{currentPageItems?.map((app, rowIndex) => {
const ticket = getTicketByApplication(tickets, app.id);
return (
<Tr key={app.name} {...getTrProps({ item: app })}>
<TableRowContentWithControls
{...tableControls}
item={app}
rowIndex={rowIndex}
>
<Td width={20} {...getTdProps({ columnKey: "appName" })}>
{app.name}
</Td>
<Td width={20} {...getTdProps({ columnKey: "status" })}>
{getTicketByApplication(tickets, app.id)?.error ? (
<Button
type="button"
variant="plain"
onClick={() =>
setCodeModalState(
getTicketByApplication(tickets, app.id)
? getTicketByApplication(tickets, app.id)
?.message
: ""
)
}
>
Error
</Button>
) : (
getTicketByApplication(tickets, app?.id)?.status || ""
)}
</Td>
<Td width={30} {...getTdProps({ columnKey: "issue" })}>
<TicketIssue
ticket={getTicketByApplication(tickets, app.id)}
/>
</Td>
<Td className={alignment.textAlignRight}>
{ticket?.id && (
<Button
variant="link"
icon={<UnlinkIcon />}
onClick={() => deleteTicket(ticket.id)}
/>
)}
<Button
type="button"
variant="plain"
onClick={() =>
setCodeModalState(
getTicketByApplication(tickets, app.id)
? getTicketByApplication(tickets, app.id)?.message
: ""
)
}
onClick={() => removeApplication(migrationWave, app.id)}
>
Error
<TrashIcon />
</Button>
) : (
getTicketByApplication(tickets, app?.id)?.status || ""
)}
</Td>
<Td width={20} {...getTdProps({ columnKey: "issue" })}>
<TicketIssue
ticket={getTicketByApplication(tickets, app.id)}
/>
</Td>
<Td className={alignment.textAlignRight}>
<Button
type="button"
variant="plain"
onClick={() => removeApplication(migrationWave, app.id)}
>
<TrashIcon />
</Button>
</Td>
</TableRowContentWithControls>
</Tr>
))}
</Td>
</TableRowContentWithControls>
</Tr>
);
})}
</Tbody>
</ConditionalTableBody>
</Table>
Expand Down

0 comments on commit c7c6d7c

Please sign in to comment.