Skip to content

Commit

Permalink
Closes the dialogs belonging to the extracted token
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-slobodian committed Sep 19, 2024
1 parent 11bea41 commit 4be1db6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./global.scss";
import "./i18n";
import { useUpdateEffect } from "react-use";
import { useApp } from "./hooks/app";
import { FetchingStatusOwerlay } from "./components/fetching-status-owerlay";
import { CertificatesList } from "./components/certificates-list";
Expand Down Expand Up @@ -41,6 +42,7 @@ export function App() {

const {
open: handleCertificateDeleteDialogOpen,
close: handleCertificateDeleteDialogClose,
dialog: certificateDeleteDialog,
} = useCertificateDeleteDialog({
fortifyClient,
Expand Down Expand Up @@ -82,11 +84,28 @@ export function App() {

const {
open: handleCertificateViewerDialogOpen,
close: handleCertificateViewerDialogClose,
dialog: certificateViewerDialog,
} = useCertificateViewerDialog();

const { open: handleProviderInfoDialogOpen, dialog: providerInfoDialog } =
useProviderInfoDialog();
const {
open: handleProviderInfoDialogOpen,
close: handleProviderInfoDialogClose,
dialog: providerInfoDialog,
} = useProviderInfoDialog();

// Closes the dialogs belonging to the extracted token
useUpdateEffect(() => {
if (providers?.length && currentProviderId === undefined) {
return;
}
const curProvider = providers.find(({ id }) => currentProviderId === id);
if (!curProvider) {
handleProviderInfoDialogClose();
handleCertificateViewerDialogClose();
handleCertificateDeleteDialogClose();
}
}, [providers, currentProviderId]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function useCertificateDeleteDialog(

return {
open: handleOpen,
close: handleClose,
dialog: () =>
fortifyClient && isOpen && openParamsRef.current ? (
<CertificateDeleteDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function useCertificateViewerDialog() {

return {
open: handleOpen,
close: handleClose,
dialog: () =>
isOpen && certificateRef.current ? (
<CertificateViewerDialog
Expand Down
1 change: 1 addition & 0 deletions src/dialogs/provider-info-dialog/useProviderInfoDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function useProviderInfoDialog() {

return {
open: handleOpen,
close: handleClose,
dialog: () =>
isOpen && providerRef.current ? (
<ProviderInfoDialog
Expand Down

0 comments on commit 4be1db6

Please sign in to comment.