From a99c4d5438b1b53dcc376c2737816c98ab8e4eb5 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Mon, 5 Apr 2021 01:18:43 +0800 Subject: Disable add Profile button when enabled languages are empty --- frontend/src/Settings/Languages/table.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/Settings/Languages/table.tsx b/frontend/src/Settings/Languages/table.tsx index 81fb6e78d..8c70608f3 100644 --- a/frontend/src/Settings/Languages/table.tsx +++ b/frontend/src/Settings/Languages/table.tsx @@ -8,7 +8,7 @@ import React, { } from "react"; import { Badge, Button, ButtonGroup } from "react-bootstrap"; import { Column, TableUpdater } from "react-table"; -import { useProfiles } from "."; +import { useEnabledLanguages, useProfiles } from "."; import { ActionButton, SimpleTable, useShowModal } from "../../components"; import { useSingleUpdate } from "../components"; import { languageProfileKey } from "../keys"; @@ -18,6 +18,8 @@ import { anyCutoff } from "./options"; const Table: FunctionComponent = () => { const originalProfiles = useProfiles(); + const languages = useEnabledLanguages(); + const [profiles, setProfiles] = useState(() => cloneDeep(originalProfiles)); const nextProfileId = useMemo( @@ -117,6 +119,8 @@ const Table: FunctionComponent = () => { [] ); + const canAdd = languages.length !== 0; + return ( { > -- cgit v1.2.3