-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Clear data action in Recent activity (#883)
Add Clear data action in Recent activity Fix icons Update analytics Add a blurred background for the Impact Waiting data card
- Loading branch information
1 parent
38dd996
commit 896a6d6
Showing
34 changed files
with
426 additions
and
308 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
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
34 changes: 34 additions & 0 deletions
34
src/components/RecentActivity/ConfirmationDialog/ConfirmationDialog.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,34 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { ConfirmationDialog } from "."; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction | ||
const meta: Meta<typeof ConfirmationDialog> = { | ||
title: "Recent Activity/ConfirmationDialog", | ||
component: ConfirmationDialog, | ||
parameters: { | ||
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout | ||
layout: "fullscreen" | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args | ||
export const DeleteEnvironment: Story = { | ||
args: { | ||
title: "Delete environment", | ||
message: "Are you sure that you want to delete this environment?", | ||
confirmButtonText: "Delete" | ||
} | ||
}; | ||
|
||
export const ClearEnvironmentData: Story = { | ||
args: { | ||
title: "Clear Data?", | ||
message: | ||
"Are you sure you want to clear the data from this environment? This action cannot be undone.", | ||
confirmButtonText: "Clear Data" | ||
} | ||
}; |
67 changes: 67 additions & 0 deletions
67
src/components/RecentActivity/ConfirmationDialog/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,67 @@ | ||
import { useEffect, useRef } from "react"; | ||
import { isString } from "../../../typeGuards/isString"; | ||
import { sendUserActionTrackingEvent } from "../../../utils/actions/sendUserActionTrackingEvent"; | ||
import { Button } from "../../common/Button"; | ||
import { CrossIcon } from "../../common/icons/CrossIcon"; | ||
import { trackingEvents } from "../tracking"; | ||
import * as s from "./styles"; | ||
import { ConfirmationDialogProps } from "./types"; | ||
|
||
export const ConfirmationDialog = ({ | ||
title, | ||
message, | ||
confirmButtonText, | ||
onConfirm, | ||
onCancel, | ||
trackingData | ||
}: ConfirmationDialogProps) => { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
const handleConfirmButtonClick = () => { | ||
sendUserActionTrackingEvent( | ||
trackingEvents.CONFIRMATION_DIALOG_CONFIRM_BUTTON_CLICKED, | ||
trackingData | ||
); | ||
onConfirm(); | ||
}; | ||
|
||
const handleCancelButtonClick = () => { | ||
sendUserActionTrackingEvent( | ||
trackingEvents.CONFIRMATION_DIALOG_CANCEL_BUTTON_CLICKED, | ||
trackingData | ||
); | ||
onCancel(); | ||
}; | ||
|
||
const handleCloseButtonClick = () => { | ||
sendUserActionTrackingEvent( | ||
trackingEvents.CONFIRMATION_DIALOG_CLOSE_BUTTON_CLICKED, | ||
trackingData | ||
); | ||
onCancel(); | ||
}; | ||
|
||
useEffect(() => { | ||
containerRef.current?.focus(); | ||
}, []); | ||
|
||
return ( | ||
<s.Container ref={containerRef} tabIndex={0}> | ||
<s.Header> | ||
<s.Title>{title}</s.Title> | ||
<s.CloseButton onClick={handleCloseButtonClick}> | ||
<CrossIcon color={"currentColor"} size={12} /> | ||
</s.CloseButton> | ||
</s.Header> | ||
{isString(message) && <span>{message}</span>} | ||
<s.ButtonsContainer> | ||
<Button buttonType={"secondary"} onClick={handleCancelButtonClick}> | ||
Cancel | ||
</Button> | ||
<Button onClick={handleConfirmButtonClick}> | ||
{confirmButtonText || "Confirm"} | ||
</Button> | ||
</s.ButtonsContainer> | ||
</s.Container> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
src/components/RecentActivity/ConfirmationDialog/styles.ts
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,48 @@ | ||
import styled from "styled-components"; | ||
import { | ||
bodySemiboldTypography, | ||
footnoteRegularTypography | ||
} from "../../common/App/typographies"; | ||
|
||
export const Container = styled.div` | ||
${footnoteRegularTypography} | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
padding: 12px; | ||
border-radius: 4px; | ||
width: 339px; | ||
height: fit-content; | ||
background: ${({ theme }) => theme.colors.v3.surface.primary}; | ||
color: ${({ theme }) => theme.colors.v3.text.secondary}; | ||
`; | ||
|
||
export const Header = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
`; | ||
|
||
export const Title = styled.span` | ||
${bodySemiboldTypography} | ||
text-transform: capitalize; | ||
color: ${({ theme }) => theme.colors.v3.text.primary}; | ||
`; | ||
|
||
export const ButtonsContainer = styled.div` | ||
display: flex; | ||
padding-top: 8px; | ||
gap: 8px; | ||
justify-content: flex-end; | ||
`; | ||
|
||
export const CloseButton = styled.button` | ||
display: flex; | ||
padding: 0; | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
color: ${({ theme }) => theme.colors.v3.text.secondary}; | ||
`; |
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,9 @@ | ||
export interface ConfirmationDialogProps { | ||
title: string; | ||
message?: string; | ||
confirmButtonText?: string; | ||
trackingPrefix?: string; | ||
onConfirm: () => void; | ||
onCancel: () => void; | ||
trackingData?: Record<string, any>; | ||
} |
19 changes: 0 additions & 19 deletions
19
...ts/RecentActivity/DeleteEnvironmentConfirmation/DeleteEnvironmentConfirmation.stories.tsx
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
src/components/RecentActivity/DeleteEnvironmentConfirmation/index.tsx
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
src/components/RecentActivity/DeleteEnvironmentConfirmation/styles.ts
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/components/RecentActivity/DeleteEnvironmentConfirmation/types.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.