Skip to content

Commit

Permalink
✨ Add link for jira ticket in drawer view (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Nov 15, 2023
1 parent f112198 commit d838571
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ export interface Ticket {
reference?: string | null;
readonly status?: TicketStatus | null;
error?: boolean;
link?: string;
}

export type Role = "Owner" | "Contributor" | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ import {
Button,
Grid,
GridItem,
Spinner,
} from "@patternfly/react-core";
import { Application } from "@app/api/models";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import { ApplicationBusinessService } from "../application-business-service";
import { EmptyTextMessage } from "@app/components/EmptyTextMessage";
import { EditIcon } from "@patternfly/react-icons";
import { useFetchTickets } from "@app/queries/tickets";
import { useDeleteTicketMutation } from "@app/queries/migration-waves";
import { UnlinkIcon } from "@patternfly/react-icons";

export const ApplicationDetailFields: React.FC<{
application: Application | null;
onEditClick: () => void;
onCloseClick: () => void;
}> = ({ application, onEditClick, onCloseClick }) => {
const { t } = useTranslation();

const { tickets } = useFetchTickets();
const { mutate: deleteTicket, isLoading } = useDeleteTicketMutation();
const matchingTicket = tickets?.find(
(ticket) => ticket.application?.id === application?.id
);
return (
<>
<TextContent className={spacing.mtLg}>
Expand Down Expand Up @@ -143,11 +151,51 @@ export const ApplicationDetailFields: React.FC<{
<Title headingLevel="h3" size="md">
{t("terms.migrationWave")}
</Title>
<Text component="small">
<Text
component={TextVariants.small}
className="pf-v5-u-color-200 pf-v5-u-font-weight-light"
>
Wave name{": "}
</Text>
<Text
component={TextVariants.small}
className="pf-v5-u-color-200 pf-v5-u-font-weight-light"
>
{application?.migrationWave
? application.migrationWave.name
: t("terms.unassigned")}
</Text>
<br />
<Text
component={TextVariants.small}
className="pf-v5-u-color-200 pf-v5-u-font-weight-light"
>
Ticket{": "}
</Text>
<Text
component={TextVariants.small}
className="pf-v5-u-color-200 pf-v5-u-font-weight-light"
>
{matchingTicket ? (
<a href={matchingTicket.link} target="_">
{matchingTicket?.link}
</a>
) : (
t("terms.unassigned")
)}
{matchingTicket?.id ? (
isLoading ? (
<Spinner role="status" size="sm" />
) : (
<Button
variant="link"
icon={<UnlinkIcon />}
onClick={() => deleteTicket(matchingTicket.id)}
/>
)
) : null}
</Text>

<Title headingLevel="h3" size="md">
{t("terms.commentsFromApplication")}
</Title>
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/queries/migration-waves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
deleteTicket,
} from "@app/api/rest";
import { getWavesWithStatus } from "@app/utils/waves-selector";
import { useFetchTickets } from "./tickets";
import { TicketsQueryKey, useFetchTickets } from "./tickets";
import { TrackersQueryKey } from "./trackers";
import { useFetchApplications } from "./applications";
import { useFetchStakeholders } from "./stakeholders";
Expand Down Expand Up @@ -111,6 +111,7 @@ export const useDeleteTicketMutation = (
onSuccess: (res) => {
onSuccess && onSuccess(res);
queryClient.invalidateQueries([MigrationWavesQueryKey]);
queryClient.invalidateQueries([TicketsQueryKey]);
},
onError: onError,
});
Expand Down

0 comments on commit d838571

Please sign in to comment.