This commit is contained in:
2025-11-10 13:34:12 +01:00
parent 9252883a2b
commit 6eb50c0555
7 changed files with 39 additions and 24 deletions
+8 -17
View File
@@ -1,5 +1,4 @@
import React, { useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import SettingsModal from '../settings/SettingsModal';
import { useAppShell } from '../appShellContext';
import useApiTokens from '../settings/useApiTokens';
@@ -7,8 +6,7 @@ import useCapabilitySets from '../settings/useCapabilitySets';
import useCapabilities from '../settings/useCapabilities';
import { api } from './appState';
const SettingsRoute = () => {
const navigate = useNavigate();
const SettingsRoute = ({ open = true, onClose }) => {
const {
token,
notifyApiError,
@@ -71,27 +69,20 @@ const SettingsRoute = () => {
const handleClose = useCallback(() => {
dismissSecret();
navigate(-1);
}, [dismissSecret, navigate]);
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape') {
event.preventDefault();
handleClose();
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [handleClose]);
onClose?.();
}, [dismissSecret, onClose]);
useEffect(() => () => {
dismissSecret();
}, [dismissSecret]);
if (!open) {
return null;
}
return (
<SettingsModal
open
open={open}
onClose={handleClose}
tokens={tokens}
loading={tokensLoading}