diff options
author | LASER-Yi <[email protected]> | 2021-04-05 01:18:43 +0800 |
---|---|---|
committer | LASER-Yi <[email protected]> | 2021-04-05 01:18:43 +0800 |
commit | a99c4d5438b1b53dcc376c2737816c98ab8e4eb5 (patch) | |
tree | 548198ab4a9bae204e8877b1751e38bcc3ef8ae1 | |
parent | 94dd36d5dc0104b52db72a1455646e3a4b643c70 (diff) | |
download | bazarr-a99c4d5438b1b53dcc376c2737816c98ab8e4eb5.tar.gz bazarr-a99c4d5438b1b53dcc376c2737816c98ab8e4eb5.zip |
Disable add Profile button when enabled languages are empty
-rw-r--r-- | frontend/src/Settings/Languages/table.tsx | 9 |
1 files 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 ( <React.Fragment> <SimpleTable @@ -126,6 +130,7 @@ const Table: FunctionComponent = () => { ></SimpleTable> <Button block + disabled={!canAdd} variant="light" onClick={() => { const profile = { @@ -137,7 +142,7 @@ const Table: FunctionComponent = () => { showModal("profile", profile); }} > - Add New Profile + {canAdd ? "Add New Profile" : "No Enabled Languages"} </Button> <Modal update={updateProfile} modalKey="profile"></Modal> </React.Fragment> |