diff options
| author | Oskar <oskar@mullvad.net> | 2024-10-22 15:32:24 +0200 |
|---|---|---|
| committer | Oskar <oskar@mullvad.net> | 2024-10-22 15:32:24 +0200 |
| commit | 1ec8c9d6c4dc799fb0c6479cdc9dad438bf37129 (patch) | |
| tree | 43caf1e9884496f64c2333648c16381eaa1cf18a /gui/src/renderer/components/ApiAccessMethods.tsx | |
| parent | 6533665d1fdf9a97e6ea1e36f01ee2f293b4338c (diff) | |
| parent | cf62ffdd17eac7958977895f098742c704aa3047 (diff) | |
| download | mullvadvpn-1ec8c9d6c4dc799fb0c6479cdc9dad438bf37129.tar.xz mullvadvpn-1ec8c9d6c4dc799fb0c6479cdc9dad438bf37129.zip | |
Merge branch 'add-react-linter-rules'
Diffstat (limited to 'gui/src/renderer/components/ApiAccessMethods.tsx')
| -rw-r--r-- | gui/src/renderer/components/ApiAccessMethods.tsx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gui/src/renderer/components/ApiAccessMethods.tsx b/gui/src/renderer/components/ApiAccessMethods.tsx index 78f0a11e77..57668df787 100644 --- a/gui/src/renderer/components/ApiAccessMethods.tsx +++ b/gui/src/renderer/components/ApiAccessMethods.tsx @@ -10,7 +10,7 @@ import { useApiAccessMethodTest } from '../lib/api-access-methods'; import { useHistory } from '../lib/history'; import { generateRoutePath } from '../lib/routeHelpers'; import { RoutePath } from '../lib/routes'; -import { useBoolean } from '../lib/utilityHooks'; +import { useBoolean } from '../lib/utility-hooks'; import { useSelector } from '../redux/store'; import * as Cell from './cell'; import { @@ -168,7 +168,7 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { updateApiAccessMethod, removeApiAccessMethod, } = useAppContext(); - const history = useHistory(); + const { push } = useHistory(); const [testing, testResult, testApiAccessMethod] = useApiAccessMethodTest(); @@ -177,7 +177,7 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { const confirmRemove = useCallback(() => { void removeApiAccessMethod(props.method.id); hideRemoveConfirmation(); - }, [props.method.id]); + }, [hideRemoveConfirmation, props.method.id, removeApiAccessMethod]); // Toggle on/off on an access method. const toggle = useCallback( @@ -186,7 +186,7 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { updatedMethod.enabled = value; await updateApiAccessMethod(updatedMethod); }, - [props.method], + [props.method, updateApiAccessMethod], ); const setApiAccessMethod = useCallback(async () => { @@ -194,7 +194,7 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { if (reachable) { await setApiAccessMethodImpl(props.method.id); } - }, [testApiAccessMethod, props.method.id]); + }, [testApiAccessMethod, props.method.id, setApiAccessMethodImpl]); const menuItems = useMemo<Array<ContextMenuItem>>(() => { const items: Array<ContextMenuItem> = [ @@ -219,9 +219,7 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { type: 'item' as const, label: messages.gettext('Edit'), onClick: () => - history.push( - generateRoutePath(RoutePath.editApiAccessMethods, { id: props.method.id }), - ), + push(generateRoutePath(RoutePath.editApiAccessMethods, { id: props.method.id })), }, { type: 'item' as const, @@ -232,7 +230,15 @@ function ApiAccessMethod(props: ApiAccessMethodProps) { } return items; - }, [props.method.id, props.inUse, setApiAccessMethod, testApiAccessMethod, history.push]); + }, [ + props.inUse, + props.custom, + props.method.id, + setApiAccessMethod, + testApiAccessMethod, + showRemoveConfirmation, + push, + ]); return ( <Cell.Row data-testid="access-method"> |
