This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVPROD-1968 Convert AnnotationTicketsTable into a list (#2180)
- Loading branch information
Showing
14 changed files
with
425 additions
and
290 deletions.
There are no files selected for viewing
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
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
File renamed without changes.
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
35 changes: 35 additions & 0 deletions
35
...ationTicketsList/AnnotationTicketRowWithActions/AnnotationTicketRowWithAction.stories.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { CustomMeta, CustomStoryObj } from "test_utils/types"; | ||
import AnnotationTicketRowWithActionProps from "."; | ||
|
||
export default { | ||
component: AnnotationTicketRowWithActionProps, | ||
} satisfies CustomMeta<typeof AnnotationTicketRowWithActionProps>; | ||
|
||
export const Default: CustomStoryObj< | ||
typeof AnnotationTicketRowWithActionProps | ||
> = { | ||
render: (args) => <AnnotationTicketRowWithActionProps {...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, | ||
}, | ||
}; |
135 changes: 135 additions & 0 deletions
135
...s/buildBaronAndAnnotations/AnnotationTicketsList/AnnotationTicketRowWithActions/index.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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { forwardRef } from "react"; | ||
import styled from "@emotion/styled"; | ||
import Button, { Size } from "@leafygreen-ui/button"; | ||
import { palette } from "@leafygreen-ui/palette"; | ||
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"; | ||
|
||
const { gray } = palette; | ||
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; | ||
selected: boolean; | ||
} | ||
|
||
const AnnotationTicketRowWithActions = forwardRef< | ||
HTMLDivElement, | ||
AnnotationTicketRowWithActionsProps | ||
>( | ||
( | ||
{ | ||
isIssue, | ||
issueString, | ||
onMove, | ||
onRemove, | ||
selected, | ||
userCanModify, | ||
...rest | ||
}, | ||
ref | ||
) => { | ||
const { confidenceScore, issueKey, loading, url } = rest; | ||
return ( | ||
<Container selected={selected} ref={ref}> | ||
<AnnotationTicketRow {...rest} /> | ||
{!loading && ( | ||
<ButtonContainer> | ||
{ConditionalWrapper({ | ||
condition: userCanModify, | ||
wrapper: (children: JSX.Element) => ( | ||
<Popconfirm | ||
align="right" | ||
onConfirm={() => { | ||
onMove({ url, issueKey, confidenceScore }); | ||
}} | ||
trigger={children} | ||
> | ||
Do you want to move this {issueString} to{" "} | ||
{isIssue ? "suspected issues" : "issues"}? | ||
</Popconfirm> | ||
), | ||
altWrapper: (children: JSX.Element) => ( | ||
<Tooltip trigger={children}> | ||
You are not authorized to edit failure details | ||
</Tooltip> | ||
), | ||
children: ( | ||
<Button | ||
size={Size.Small} | ||
data-cy={`move-btn-${issueKey}`} | ||
disabled={!userCanModify} | ||
leftGlyph={<Icon glyph={isIssue ? "ArrowDown" : "ArrowUp"} />} | ||
> | ||
Move to {isIssue ? "suspected issues" : "issues"} | ||
</Button> | ||
), | ||
})} | ||
{ConditionalWrapper({ | ||
condition: userCanModify, | ||
wrapper: (children: JSX.Element) => ( | ||
<Popconfirm | ||
align="right" | ||
onConfirm={() => { | ||
onRemove(url, issueKey); | ||
}} | ||
trigger={children} | ||
> | ||
Do you want to delete this {issueString}? | ||
</Popconfirm> | ||
), | ||
altWrapper: (children: JSX.Element) => ( | ||
<Tooltip trigger={children}> | ||
You are not authorized to edit failure details | ||
</Tooltip> | ||
), | ||
children: ( | ||
<Button | ||
size="small" | ||
data-cy={`${issueKey}-delete-btn`} | ||
leftGlyph={<Icon glyph="Trash" />} | ||
disabled={!userCanModify} | ||
/> | ||
), | ||
})} | ||
</ButtonContainer> | ||
)} | ||
</Container> | ||
); | ||
} | ||
); | ||
|
||
const ButtonContainer = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
gap: ${size.xs}; | ||
`; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
padding: ${size.xs}; | ||
${({ selected }: { selected?: boolean }) => | ||
selected && | ||
` | ||
background-color: ${gray.light2}; | ||
`} | ||
`; | ||
|
||
export default AnnotationTicketRowWithActions; |
Oops, something went wrong.