diff --git a/src/components/AccessPolicySelection/AccessPolicySelection.tsx b/src/components/AccessPolicySelection/AccessPolicySelection.tsx index f3a7392789..3b7746cbc7 100644 --- a/src/components/AccessPolicySelection/AccessPolicySelection.tsx +++ b/src/components/AccessPolicySelection/AccessPolicySelection.tsx @@ -22,16 +22,10 @@ export const AccessPolicySelection: FC = ({accessPol const {t} = useTranslation(); const [visiblePassphrase, setVisiblePassphrase] = useState(true); - const handlePolicyChange = (newAccessPolicy: AccessPolicy) => { - if (newAccessPolicy >= 0 && newAccessPolicy <= 2) { - onAccessPolicyChange(newAccessPolicy); - } - }; - let AccessPolicyDescription; let AdditionalAccessPolicySettings; switch (accessPolicy) { - case AccessPolicy.BY_PASSPHRASE: + case "BY_PASSPHRASE": AccessPolicyDescription = {t("AccessPolicySelection.byPassphrase")}; AdditionalAccessPolicySettings = ( <> @@ -68,10 +62,10 @@ export const AccessPolicySelection: FC = ({accessPol ); break; - case AccessPolicy.BY_INVITE: + case "BY_INVITE": AccessPolicyDescription = {t("AccessPolicySelection.manualVerification")}; break; - case AccessPolicy.PUBLIC: + case "PUBLIC": default: AccessPolicyDescription = {t("AccessPolicySelection.public")}; break; @@ -82,24 +76,20 @@ export const AccessPolicySelection: FC = ({accessPol

{t("AccessPolicySelection.title")}

- diff --git a/src/components/AccessPolicySelection/__tests__/AccessPolicySelection.test.tsx b/src/components/AccessPolicySelection/__tests__/AccessPolicySelection.test.tsx index 9da18972a3..3ba6383325 100644 --- a/src/components/AccessPolicySelection/__tests__/AccessPolicySelection.test.tsx +++ b/src/components/AccessPolicySelection/__tests__/AccessPolicySelection.test.tsx @@ -1,24 +1,21 @@ import {fireEvent, waitFor} from "@testing-library/react"; import {AccessPolicySelection} from "components/AccessPolicySelection/AccessPolicySelection"; -import {AccessPolicy} from "store/features/board/types"; import {render} from "testUtils"; describe("AccessPolicySelection", () => { test("dont show passphrase input on default state", () => { - const {container} = render(); + const {container} = render(); expect(container.querySelector(`[data-testid="passphrase-input"]`)).toBeNull(); }); test("show passphrase input on access policy by passphrase", () => { - const {container} = render(); + const {container} = render(); expect(container.querySelector(`[data-testid="passphrase-input"]`)).toBeDefined(); }); test("trigger on change on passphrase change", async () => { const onChangeOfPassphrase = jest.fn(); - const {container} = render( - - ); + const {container} = render(); fireEvent.change(container.querySelector(`[data-testid="passphrase-input"]`)!, {target: {value: "1234"}}); @@ -29,9 +26,7 @@ describe("AccessPolicySelection", () => { test("trigger on password change when random generator is clicked", async () => { const onChangeOfPassphrase = jest.fn(); - const {container} = render( - - ); + const {container} = render(); fireEvent.click(container.querySelector(`[data-testid="random-passwort-generator"]`)!); diff --git a/src/routes/NewBoard/NewBoard.tsx b/src/routes/NewBoard/NewBoard.tsx index 80d76096c3..1d18e09034 100644 --- a/src/routes/NewBoard/NewBoard.tsx +++ b/src/routes/NewBoard/NewBoard.tsx @@ -16,13 +16,13 @@ export const NewBoard = () => { const navigate = useNavigate(); const [boardName, setBoardName] = useState(); const [columnTemplate, setColumnTemplate] = useState(undefined); - const [accessPolicy, setAccessPolicy] = useState(0); + const [accessPolicy, setAccessPolicy] = useState("PUBLIC"); const [passphrase, setPassphrase] = useState(""); const [extendedConfiguration, setExtendedConfiguration] = useState(false); async function onCreateBoard() { let additionalAccessPolicyOptions = {}; - if (accessPolicy === AccessPolicy.BY_PASSPHRASE && Boolean(passphrase)) { + if (accessPolicy === "BY_PASSPHRASE" && Boolean(passphrase)) { additionalAccessPolicyOptions = { passphrase, }; @@ -32,7 +32,7 @@ export const NewBoard = () => { const boardId = await API.createBoard( boardName, { - type: AccessPolicy[accessPolicy], + type: accessPolicy, ...additionalAccessPolicyOptions, }, columnTemplates[columnTemplate].columns @@ -41,7 +41,7 @@ export const NewBoard = () => { } } - const isCreatedBoardDisabled = !columnTemplate || (accessPolicy === AccessPolicy.BY_PASSPHRASE && !passphrase); + const isCreatedBoardDisabled = !columnTemplate || (accessPolicy === "BY_PASSPHRASE" && !passphrase); return (
diff --git a/src/store/features/board/types.ts b/src/store/features/board/types.ts index 2c1d1628c4..c2ad48ec43 100644 --- a/src/store/features/board/types.ts +++ b/src/store/features/board/types.ts @@ -6,17 +6,13 @@ import {Reaction} from "../reactions"; import {Vote} from "../votes"; import {Voting} from "../votings"; -export enum AccessPolicy { - "PUBLIC" = 0, - "BY_PASSPHRASE" = 1, - "BY_INVITE" = 2, -} +export type AccessPolicy = "PUBLIC" | "BY_PASSPHRASE" | "BY_INVITE"; export interface Board { id: string; name?: string; - accessPolicy: keyof typeof AccessPolicy; + accessPolicy: AccessPolicy; showAuthors: boolean; showNotesOfOtherUsers: boolean; showNoteReactions: boolean;