From 189c5a2f1e6b5337611caed992f938762a5ccfdd Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 1 Dec 2023 13:04:46 -0500 Subject: [PATCH 01/12] Move annotationTicketRow stories --- .../{ => AnnotationTicketRow}/AnnotationTicketRow.stories.tsx | 3 ++- .../__snapshots__/AnnotationTicketRow.stories.storyshot | 0 .../{AnnotationTicketRow.tsx => AnnotationTicketRow/index.tsx} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/{ => AnnotationTicketRow}/AnnotationTicketRow.stories.tsx (93%) rename src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/{ => AnnotationTicketRow}/__snapshots__/AnnotationTicketRow.stories.storyshot (100%) rename src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/{AnnotationTicketRow.tsx => AnnotationTicketRow/index.tsx} (100%) diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow.stories.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx similarity index 93% rename from src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow.stories.tsx rename to src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx index 644a5e856e..c6f9ea268e 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow.stories.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx @@ -1,5 +1,5 @@ import { CustomStoryObj, CustomMeta } from "test_utils/types"; -import { AnnotationTicketRow } from "./AnnotationTicketRow"; +import { AnnotationTicketRow } from "."; export default { component: AnnotationTicketRow, @@ -29,6 +29,7 @@ export const Default: CustomStoryObj = { ), args: { confidenceScore: 0.5, + loading: false, }, argTypes: { confidenceScore: { diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/__snapshots__/AnnotationTicketRow.stories.storyshot b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/__snapshots__/AnnotationTicketRow.stories.storyshot similarity index 100% rename from src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/__snapshots__/AnnotationTicketRow.stories.storyshot rename to src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/__snapshots__/AnnotationTicketRow.stories.storyshot diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx similarity index 100% rename from src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow.tsx rename to src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx From 1f2ca59440c564d85c9d560d6f9a4b874b49c43b Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 1 Dec 2023 13:12:14 -0500 Subject: [PATCH 02/12] Remove antd skeleton --- .../AnnotationTicketRow/index.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx index 57564548b8..1e833498ca 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx @@ -1,7 +1,7 @@ import styled from "@emotion/styled"; import Badge from "@leafygreen-ui/badge"; +import { Skeleton } from "@leafygreen-ui/skeleton-loader"; import { Disclaimer } from "@leafygreen-ui/typography"; -import { Skeleton } from "antd"; import { useAnnotationAnalytics } from "analytics"; import { StyledLink } from "components/styles"; import { size } from "constants/tokens"; @@ -40,25 +40,25 @@ export const AnnotationTicketRow: React.FC = ({ return (
- - annotationAnalytics.sendEvent({ - name: "Click Annotation Ticket Link", - }) - } - > - {issueKey} - {summary && `: ${summary}`} - {loading ? ( - + ) : ( <> + + annotationAnalytics.sendEvent({ + name: "Click Annotation Ticket Link", + }) + } + > + {issueKey} + {summary && `: ${summary}`} + {jiraTicket && ( {status.name} From 31f2cce37626c46b5de594ae04eac628d5068525 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 1 Dec 2023 13:13:10 -0500 Subject: [PATCH 03/12] Remove barrel export --- .../AnnotationTicketsTable/AnnotationTicketsTable.test.tsx | 2 +- .../buildBaronAndAnnotations/AnnotationTicketsTable/index.ts | 3 --- .../{AnnotationTicketsTable.tsx => index.tsx} | 0 3 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.ts rename src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/{AnnotationTicketsTable.tsx => index.tsx} (100%) diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.test.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.test.tsx index 722b075997..d329cbd7ff 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.test.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.test.tsx @@ -11,7 +11,7 @@ import { getUserMock } from "gql/mocks/getUser"; import { MOVE_ANNOTATION, REMOVE_ANNOTATION } from "gql/mutations"; import { renderWithRouterMatch as render, screen } from "test_utils"; import { ApolloMock } from "types/gql"; -import AnnotationTicketsTable from "./AnnotationTicketsTable"; +import AnnotationTicketsTable from "."; const taskId = "spruce_ubuntu1604_e2e_test_e0ece5ad52ad01630bdf29f55b9382a26d6256b3_20_08_26_19_20_41"; diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.ts b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.ts deleted file mode 100644 index 416ea6210c..0000000000 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import AnnotationTicketsTable from "./AnnotationTicketsTable"; - -export { AnnotationTicketsTable }; diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.tsx similarity index 100% rename from src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.tsx rename to src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/index.tsx From 33a3062da03bcf11ac989cf021f498ea7a66d8a0 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 1 Dec 2023 13:34:52 -0500 Subject: [PATCH 04/12] AnnotationTicketsTable stories --- .../AnnotationTicketsTable.stories.tsx | 61 +++++++++++++++++++ .../Issues/AnnotationTickets.tsx | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.stories.tsx diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.stories.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.stories.tsx new file mode 100644 index 0000000000..09a7457140 --- /dev/null +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketsTable.stories.tsx @@ -0,0 +1,61 @@ +import WithToastContext from "test_utils/toast-decorator"; +import { CustomMeta, CustomStoryObj } from "test_utils/types"; +import AnnotationTicketsTable from "."; + +export default { + component: AnnotationTicketsTable, + decorators: [(Story: () => JSX.Element) => WithToastContext(Story)], +} satisfies CustomMeta; + +export const Default: CustomStoryObj = { + render: (args) => , + argTypes: {}, + args: { + execution: 0, + isIssue: true, + taskId: "taskId", + userCanModify: true, + selectedRowKey: "key", + loading: false, + jiraIssues: [ + { + confidenceScore: 0.5, + issueKey: "DEVPROD-123", + url: "https://example.com", + jiraTicket: { + key: "key", + fields: { + summary: "summary", + status: { + name: "status", + id: "id", + }, + created: "2020-01-02", + updated: "2020-01-02", + assigneeDisplayName: "mohamed.khelif", + assignedTeam: "evg-ui", + }, + }, + }, + { + confidenceScore: 0.99, + issueKey: "DEVPROD-456", + url: "https://example.com", + jiraTicket: { + key: "key2", + fields: { + summary: "other summary", + status: { + name: "failed", + id: "id", + }, + created: "2020-01-02", + updated: "2020-01-02", + assigneeDisplayName: "sophie.stadler", + assignedTeam: "evg-ui", + }, + }, + }, + ], + }, +}; diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx index 54fda20810..7f7f79913b 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx @@ -6,7 +6,7 @@ import { PlusButton } from "components/Buttons"; import { size } from "constants/tokens"; import { IssueLink } from "gql/generated/types"; import { AddIssueModal } from "../AddIssueModal"; -import { AnnotationTicketsTable } from "../AnnotationTicketsTable"; +import AnnotationTicketsTable from "../AnnotationTicketsTable"; import { TicketsTitle } from "../BBComponents"; interface AnnotationTicketsProps { From 8df50df6aa053aa27827ee8dde326aa5c7d457c1 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 1 Dec 2023 14:12:45 -0500 Subject: [PATCH 05/12] Extract annotationticketrow with actions into its own component --- .../AnnotationTicketRow.stories.tsx | 2 +- .../AnnotationTicketRow/index.tsx | 5 +- .../AnnotationTicketRowWithAction.stories.tsx | 35 ++++++ .../AnnotationTicketRowWithActions/index.tsx | 109 ++++++++++++++++++ .../CustomCreatedTicketsTable.tsx | 2 +- 5 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/AnnotationTicketRowWithAction.stories.tsx create mode 100644 src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/index.tsx diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx index c6f9ea268e..d78a9af141 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/AnnotationTicketRow.stories.tsx @@ -1,5 +1,5 @@ import { CustomStoryObj, CustomMeta } from "test_utils/types"; -import { AnnotationTicketRow } from "."; +import AnnotationTicketRow from "."; export default { component: AnnotationTicketRow, diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx index 1e833498ca..8c06233edd 100644 --- a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRow/index.tsx @@ -19,7 +19,7 @@ interface AnnotationTicketRowProps { confidenceScore?: number; } -export const AnnotationTicketRow: React.FC = ({ +const AnnotationTicketRow: React.FC = ({ confidenceScore, issueKey, jiraTicket, @@ -118,3 +118,6 @@ const BottomMetaDataWrapper = styled.div` margin-top: ${size.xs}; width: 80%; `; + +export default AnnotationTicketRow; +export type { AnnotationTicketRowProps }; diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/AnnotationTicketRowWithAction.stories.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/AnnotationTicketRowWithAction.stories.tsx new file mode 100644 index 0000000000..c1d971496d --- /dev/null +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/AnnotationTicketRowWithAction.stories.tsx @@ -0,0 +1,35 @@ +import { CustomMeta, CustomStoryObj } from "test_utils/types"; +import AnnotationTicketRowWithActionProps from "."; + +export default { + component: AnnotationTicketRowWithActionProps, +} satisfies CustomMeta; + +export const Default: CustomStoryObj< + typeof AnnotationTicketRowWithActionProps +> = { + render: (args) => , + argTypes: {}, + args: { + issueKey: "EVG-123", + url: "https://www.google.com", + jiraTicket: { + key: "key", + fields: { + summary: "summary", + status: { + name: "status", + id: "id", + }, + created: "2020-01-02", + updated: "2020-01-02", + assigneeDisplayName: "mohamed.khelif", + assignedTeam: "evg-ui", + }, + }, + confidenceScore: 0.5, + loading: false, + userCanModify: true, + isIssue: true, + }, +}; diff --git a/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/index.tsx b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/index.tsx new file mode 100644 index 0000000000..21343127ba --- /dev/null +++ b/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsTable/AnnotationTicketRowWithActions/index.tsx @@ -0,0 +1,109 @@ +import styled from "@emotion/styled"; +import Button, { Size } from "@leafygreen-ui/button"; +import Tooltip from "@leafygreen-ui/tooltip"; +import { ConditionalWrapper } from "components/ConditionalWrapper"; +import Icon from "components/Icon"; +import Popconfirm from "components/Popconfirm"; +import { size } from "constants/tokens"; +import AnnotationTicketRow, { + AnnotationTicketRowProps, +} from "../AnnotationTicketRow"; + +interface AnnotationTicketRowWithActionsProps extends AnnotationTicketRowProps { + onRemove: (url: string, issueKey: string) => void; + userCanModify: boolean; + onMove: ({ + confidenceScore, + issueKey, + url, + }: { + url: string; + issueKey: string; + confidenceScore?: number; + }) => void; + issueString: string; + isIssue: boolean; +} + +const AnnotationTicketRowWithActions: React.FC< + AnnotationTicketRowWithActionsProps +> = ({ isIssue, issueString, onMove, onRemove, userCanModify, ...rest }) => { + const { confidenceScore, issueKey, url } = rest; + return ( + + + + {ConditionalWrapper({ + condition: userCanModify, + wrapper: (children: JSX.Element) => ( + { + onMove({ url, issueKey, confidenceScore }); + }} + trigger={children} + > + Do you want to move this {issueString} to{" "} + {isIssue ? "suspected issues" : "issues"}? + + ), + altWrapper: (children: JSX.Element) => ( + + You are not authorized to edit failure details + + ), + children: ( + + ), + })} + {ConditionalWrapper({ + condition: userCanModify, + wrapper: (children: JSX.Element) => ( + { + onRemove(url, issueKey); + }} + trigger={children} + > + Do you want to delete this {issueString}? + + ), + altWrapper: (children: JSX.Element) => ( + + You are not authorized to edit failure details + + ), + children: ( + - ), - })} - {ConditionalWrapper({ - condition: userCanModify, - wrapper: (children: JSX.Element) => ( - { - handleRemove(url, issueKey); - }} - trigger={children} - > - Do you want to delete this {issueString}? - - ), - altWrapper: (children: JSX.Element) => ( - - You are not authorized to edit failure details - - ), - children: ( -