-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'donskov/v2' into aslobodian/v2-fix-certificate-import-d…
…ialog
- Loading branch information
Showing
20 changed files
with
269 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { AppFallback } from "./AppFallback"; | ||
import { fn } from "@storybook/test"; | ||
|
||
const meta: Meta<typeof AppFallback> = { | ||
title: "Components/AppFallback", | ||
component: AppFallback, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof AppFallback>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
resetErrorBoundary: fn(), | ||
}, | ||
}; |
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,40 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { FallbackProps } from "react-error-boundary"; | ||
import { Button, Typography } from "@peculiar/react-components"; | ||
|
||
import ErrorIcon from "../../icons/error-big.svg?react"; | ||
|
||
import styles from "./styles/index.module.scss"; | ||
|
||
export const AppFallback = (props: FallbackProps) => { | ||
const { resetErrorBoundary } = props; | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className={styles.box}> | ||
<div className={styles.content}> | ||
<div className={styles.icon_wrapper}> | ||
<ErrorIcon /> | ||
</div> | ||
<Typography variant="h5" color="black"> | ||
{t("app-error.message")} | ||
</Typography> | ||
<Typography variant="b2" color="gray-9"> | ||
{t("app-error.description")} | ||
</Typography> | ||
<div className={styles.buttons_group}> | ||
<Button component="a" href="/" variant="outlined"> | ||
{t("app-error.button.home-page")} | ||
</Button> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
onClick={resetErrorBoundary} | ||
> | ||
{t("app-error.button.try-again")} | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export * from "./AppFallback"; |
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,31 @@ | ||
.box { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
position: fixed; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
top: 0; | ||
z-index: 1000; | ||
background-color: var(--pv-color-gray-2); | ||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--pv-size-base-2); | ||
text-align: center; | ||
align-items: center; | ||
|
||
.icon_wrapper { | ||
font-size: 0; | ||
padding-bottom: var(--pv-size-base-2); | ||
} | ||
|
||
.buttons_group { | ||
padding-top: var(--pv-size-base-4); | ||
display: flex; | ||
gap: var(--pv-size-base-2); | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/components/certificate-name/CertificateName.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,16 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CertificateName } from "./CertificateName"; | ||
|
||
const meta: Meta<typeof CertificateName> = { | ||
title: "Components/CertificateName", | ||
component: CertificateName, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CertificateName>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
name: "Certificate name", | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/components/certificate-serial-number/CertificateSerialNumber.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,16 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CertificateSerialNumber } from "./CertificateSerialNumber"; | ||
|
||
const meta: Meta<typeof CertificateSerialNumber> = { | ||
title: "Components/CertificateSerialNumber", | ||
component: CertificateSerialNumber, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CertificateSerialNumber>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
value: "nd84ifbhsl85ncfm975nn", | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/components/certificate-type-label/CertificateTypeLabel.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,16 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CertificateTypeLabel } from "./CertificateTypeLabel"; | ||
|
||
const meta: Meta<typeof CertificateTypeLabel> = { | ||
title: "Components/CertificateTypeLabel", | ||
component: CertificateTypeLabel, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CertificateTypeLabel>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
type: "x509", | ||
}, | ||
}; |
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
16 changes: 16 additions & 0 deletions
16
src/components/certificates-sidebar/CertificatesSidebar.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,16 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CertificatesSidebar } from "./CertificatesSidebar"; | ||
|
||
const meta: Meta<typeof CertificatesSidebar> = { | ||
title: "Components/CertificatesSidebar", | ||
component: CertificatesSidebar, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof CertificatesSidebar>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "", | ||
}, | ||
}; |
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,16 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { Date as DateComponent } from "./Date"; | ||
|
||
const meta: Meta<typeof DateComponent> = { | ||
title: "Components/Date", | ||
component: DateComponent, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof DateComponent>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
date: new Date(), | ||
}, | ||
}; |
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 @@ | ||
export * from "./useCertificateDeleteDialog"; |
66 changes: 66 additions & 0 deletions
66
src/dialogs/certificate-delete-dialog/useCertificateDeleteDialog.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,66 @@ | ||
import React from "react"; | ||
import { useToast } from "@peculiar/react-components"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useLockBodyScroll } from "react-use"; | ||
import { CertificateDeleteDialog } from "../../components/certificate-delete-dialog"; | ||
|
||
export function useCertificateDeleteDialog() { | ||
const { addToast } = useToast(); | ||
const { t } = useTranslation(); | ||
|
||
const [isLoading, setIsLoading] = React.useState(false); | ||
const [currentCertificatDelete, setCurrentCetificateDelete] = React.useState< | ||
undefined | { certificateId: string; providerId: string; label: string } | ||
>(); | ||
|
||
const handleOpen = ( | ||
certificateId: string, | ||
providerId: string, | ||
label: string | ||
) => { | ||
setCurrentCetificateDelete({ | ||
certificateId, | ||
providerId, | ||
label, | ||
}); | ||
}; | ||
|
||
const handleClose = () => { | ||
setCurrentCetificateDelete(undefined); | ||
}; | ||
|
||
const handleCertificateDelete = (id: string) => { | ||
// TODO: add logic | ||
console.log("Delete certificate: ", id, currentCertificatDelete); | ||
// temporary behaviour | ||
setIsLoading(true); | ||
setTimeout(function () { | ||
setIsLoading(false); | ||
handleClose(); | ||
addToast({ | ||
message: t("certificates.dialog.delete.failure-message"), | ||
variant: "wrong", | ||
disableIcon: true, | ||
isClosable: true, | ||
}); | ||
}, 1000); | ||
}; | ||
|
||
const isOpen = !!currentCertificatDelete?.certificateId; | ||
|
||
useLockBodyScroll(isOpen); | ||
|
||
return { | ||
open: handleOpen, | ||
dialog: () => | ||
isOpen ? ( | ||
<CertificateDeleteDialog | ||
certificateId={currentCertificatDelete.certificateId} | ||
certificateName={currentCertificatDelete.label} | ||
loading={isLoading} | ||
onDialogClose={handleClose} | ||
onDeleteClick={handleCertificateDelete} | ||
/> | ||
) : null, | ||
}; | ||
} |
Oops, something went wrong.