diff --git a/package-lock.json b/package-lock.json
index d9fb6d8471..f8c84e8c07 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -38,6 +38,7 @@
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/react": "^12.1.1",
+ "@testing-library/react-hooks": "^7.0.2",
"@types/dagre": "^0.7.45",
"@types/file-saver": "^2.0.4",
"@types/lodash": "^4.14.177",
@@ -4483,6 +4484,35 @@
"react-dom": "*"
}
},
+ "node_modules/@testing-library/react-hooks": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/@testing-library/react-hooks/-/react-hooks-7.0.2.tgz",
+ "integrity": "sha512-dYxpz8u9m4q1TuzfcUApqi8iFfR6R0FaMbr2hjZJy1uC8z+bO/K4v8Gs9eogGKYQop7QsrBTFkv/BCF7MzD2Cg==",
+ "dev": true,
+ "dependencies": {
+ "@babel/runtime": "^7.12.5",
+ "@types/react": ">=16.9.0",
+ "@types/react-dom": ">=16.9.0",
+ "@types/react-test-renderer": ">=16.9.0",
+ "react-error-boundary": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "peerDependencies": {
+ "react": ">=16.9.0",
+ "react-dom": ">=16.9.0",
+ "react-test-renderer": ">=16.9.0"
+ },
+ "peerDependenciesMeta": {
+ "react-dom": {
+ "optional": true
+ },
+ "react-test-renderer": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@tootallnate/once": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
@@ -5002,6 +5032,15 @@
"@types/react-router": "*"
}
},
+ "node_modules/@types/react-test-renderer": {
+ "version": "17.0.1",
+ "resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-17.0.1.tgz",
+ "integrity": "sha512-3Fi2O6Zzq/f3QR9dRnlnHso9bMl7weKCviFmfF6B4LS1Uat6Hkm15k0ZAQuDz+UBq6B3+g+NM6IT2nr5QgPzCw==",
+ "dev": true,
+ "dependencies": {
+ "@types/react": "*"
+ }
+ },
"node_modules/@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
@@ -24660,6 +24699,19 @@
"@testing-library/dom": "^8.0.0"
}
},
+ "@testing-library/react-hooks": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/@testing-library/react-hooks/-/react-hooks-7.0.2.tgz",
+ "integrity": "sha512-dYxpz8u9m4q1TuzfcUApqi8iFfR6R0FaMbr2hjZJy1uC8z+bO/K4v8Gs9eogGKYQop7QsrBTFkv/BCF7MzD2Cg==",
+ "dev": true,
+ "requires": {
+ "@babel/runtime": "^7.12.5",
+ "@types/react": ">=16.9.0",
+ "@types/react-dom": ">=16.9.0",
+ "@types/react-test-renderer": ">=16.9.0",
+ "react-error-boundary": "^3.1.0"
+ }
+ },
"@tootallnate/once": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz",
@@ -25176,6 +25228,15 @@
"@types/react-router": "*"
}
},
+ "@types/react-test-renderer": {
+ "version": "17.0.1",
+ "resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-17.0.1.tgz",
+ "integrity": "sha512-3Fi2O6Zzq/f3QR9dRnlnHso9bMl7weKCviFmfF6B4LS1Uat6Hkm15k0ZAQuDz+UBq6B3+g+NM6IT2nr5QgPzCw==",
+ "dev": true,
+ "requires": {
+ "@types/react": "*"
+ }
+ },
"@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
diff --git a/package.json b/package.json
index 842af35541..1f95bcb4c1 100644
--- a/package.json
+++ b/package.json
@@ -54,6 +54,7 @@
"@testing-library/cypress": "^8.0.2",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/react": "^12.1.1",
+ "@testing-library/react-hooks": "^7.0.2",
"@types/dagre": "^0.7.45",
"@types/file-saver": "^2.0.4",
"@types/lodash": "^4.14.177",
diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx
index 3e0983082a..b6a875ae7a 100644
--- a/src/PageHeader.tsx
+++ b/src/PageHeader.tsx
@@ -132,16 +132,12 @@ export const Header = () => {
const KebabDropdown = () => {
const [isDropdownOpen, setDropdownOpen] = useState(false);
- const onDropdownToggle = () => {
- setDropdownOpen(!isDropdownOpen);
- };
-
return (
}
+ toggle={}
isOpen={isDropdownOpen}
dropdownItems={kebabDropdownItems}
/>
@@ -152,10 +148,6 @@ export const Header = () => {
const { whoAmI } = useWhoAmI();
const [isDropdownOpen, setDropdownOpen] = useState(false);
- const onDropdownToggle = () => {
- setDropdownOpen(!isDropdownOpen);
- };
-
return (
{
id="user-dropdown"
isOpen={isDropdownOpen}
toggle={
-
+
{whoAmI.getDisplayName()}
}
diff --git a/src/authentication/AuthenticationSection.tsx b/src/authentication/AuthenticationSection.tsx
index 248f9dd6c6..d5604fa163 100644
--- a/src/authentication/AuthenticationSection.tsx
+++ b/src/authentication/AuthenticationSection.tsx
@@ -24,6 +24,7 @@ import { useRealm } from "../context/realm-context/RealmContext";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { useAlerts } from "../components/alert/Alerts";
import { toUpperCase } from "../util";
+import useToggle from "../utils/useToggle";
import { DuplicateFlowModal } from "./DuplicateFlowModal";
import { toCreateFlow } from "./routes/CreateFlow";
import { toFlow } from "./routes/Flow";
@@ -55,7 +56,7 @@ export default function AuthenticationSection() {
const { addAlert, addError } = useAlerts();
const [selectedFlow, setSelectedFlow] = useState();
- const [open, setOpen] = useState(false);
+ const [open, toggleOpen, setOpen] = useToggle();
const loader = async () => {
const clients = await adminClient.clients.find();
@@ -202,7 +203,7 @@ export default function AuthenticationSection() {
setOpen(!open)}
+ toggleDialog={toggleOpen}
onComplete={() => {
refresh();
setOpen(false);
diff --git a/src/authentication/FlowDetails.tsx b/src/authentication/FlowDetails.tsx
index c33cae1d2c..25a0c7ea2a 100644
--- a/src/authentication/FlowDetails.tsx
+++ b/src/authentication/FlowDetails.tsx
@@ -40,6 +40,7 @@ import { AddSubFlowModal, Flow } from "./components/modals/AddSubFlowModal";
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
import { DuplicateFlowModal } from "./DuplicateFlowModal";
import { useRealm } from "../context/realm-context/RealmContext";
+import useToggle from "../utils/useToggle";
import { toAuthentication } from "./routes/Authentication";
import { EditFlowModal } from "./EditFlowModal";
@@ -69,7 +70,7 @@ export default function FlowDetails() {
const [showAddSubFlowDialog, setShowSubFlowDialog] = useState();
const [selectedExecution, setSelectedExecution] =
useState();
- const [open, setOpen] = useState(false);
+ const [open, toggleOpen, setOpen] = useToggle();
const [edit, setEdit] = useState(false);
useFetch(
@@ -280,7 +281,7 @@ export default function FlowDetails() {
setOpen(!open)}
+ toggleDialog={toggleOpen}
onComplete={() => {
refresh();
setOpen(false);
diff --git a/src/authentication/components/EditFlowDropdown.tsx b/src/authentication/components/EditFlowDropdown.tsx
index 056e881577..27a21a16fd 100644
--- a/src/authentication/components/EditFlowDropdown.tsx
+++ b/src/authentication/components/EditFlowDropdown.tsx
@@ -47,7 +47,7 @@ export const EditFlowDropdown = ({
data-testid={`${execution.displayName}-edit-dropdown`}
isOpen={open}
toggle={
- setOpen(open)}>
+
}
diff --git a/src/authentication/components/FlowRequirementDropdown.tsx b/src/authentication/components/FlowRequirementDropdown.tsx
index 7d739a63f1..fa052458d6 100644
--- a/src/authentication/components/FlowRequirementDropdown.tsx
+++ b/src/authentication/components/FlowRequirementDropdown.tsx
@@ -28,7 +28,7 @@ export const FlowRequirementDropdown = ({