메뉴, dialog 정리
This commit is contained in:
+49
-30
@@ -3,6 +3,7 @@ import {APIProvider, useAPI} from './providers/APIProvider';
|
||||
import {LoadTestProvider} from './providers/LoadTestProvider';
|
||||
import APITester from './components/APITester';
|
||||
import LoadTestManager from './components/LoadTestManager';
|
||||
import DialogManager from './components/DialogManager';
|
||||
import {monacoConfig} from '@/config/monaco.js';
|
||||
import LoginDialog from '@/components/LoginDialog.jsx';
|
||||
import {Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarTrigger} from '@/components/ui/menubar.jsx';
|
||||
@@ -88,39 +89,46 @@ const MenuItem = ({item, onMenuClick}) => {
|
||||
);
|
||||
};
|
||||
|
||||
const handleMenuClick = async (action) => {
|
||||
// Handle menu item clicks
|
||||
console.log('Menu action:', action);
|
||||
switch (action) {
|
||||
case 'request-add':
|
||||
setShowAddApi(true);
|
||||
break;
|
||||
case 'collection-add':
|
||||
setShowAddCollection(true);
|
||||
break;
|
||||
case 'scenario-add':
|
||||
setShowAddScenario(true);
|
||||
break;
|
||||
case 'variables-show':
|
||||
setShowVariableModal(true);
|
||||
break;
|
||||
case 'logout':
|
||||
const success = await handleLogout();
|
||||
if (success) {
|
||||
window.location.href = "/actionLogout.do";
|
||||
}
|
||||
break;
|
||||
case 'change-password':
|
||||
// Handle password change
|
||||
break;
|
||||
// Add other cases as needed
|
||||
}
|
||||
};
|
||||
|
||||
const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
const { isAuthenticated, setIsAuthenticated } = useAPI();
|
||||
const { isAuthenticated, setIsAuthenticated, handleLogout } = useAPI();
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
const [dialogState, setDialogState] = useState({
|
||||
showAddApi: false,
|
||||
showAddCollection: false,
|
||||
showAddScenario: false,
|
||||
showVariableModal: false
|
||||
});
|
||||
|
||||
const handleMenuClick = async (action) => {
|
||||
|
||||
console.log('Menu action:', action);
|
||||
switch (action) {
|
||||
case 'request-add':
|
||||
setDialogState(prev => ({ ...prev, showAddApi: true }));
|
||||
break;
|
||||
case 'collection-add':
|
||||
setDialogState(prev => ({ ...prev, showAddCollection: true }));
|
||||
break;
|
||||
case 'scenario-add':
|
||||
setDialogState(prev => ({ ...prev, showAddScenario: true }));
|
||||
|
||||
break;
|
||||
case 'variables-show':
|
||||
setDialogState(prev => ({ ...prev, showVariableModal: true }));
|
||||
|
||||
break;
|
||||
case 'logout':
|
||||
const success = await handleLogout();
|
||||
if (success) {
|
||||
window.location.href = "/actionLogout.do";
|
||||
}
|
||||
break;
|
||||
case 'change-password':
|
||||
// Handle password change
|
||||
break;
|
||||
// Add other cases as needed
|
||||
}
|
||||
};
|
||||
|
||||
const checkAuth = async () => {
|
||||
try {
|
||||
@@ -151,6 +159,10 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
}
|
||||
}, [isInitialized]);
|
||||
|
||||
const handleDialogChange = (dialogName, isOpen) => {
|
||||
setDialogState(prev => ({ ...prev, [dialogName]: isOpen }));
|
||||
};
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <LoginDialog open={showLogin} onOpenChange={setShowLogin} />;
|
||||
}
|
||||
@@ -187,6 +199,13 @@ const AppContent = ({ options, showLogin, setShowLogin }) => {
|
||||
</Menubar>
|
||||
</div>
|
||||
</div>
|
||||
<DialogManager
|
||||
showAddApi={dialogState.showAddApi}
|
||||
showAddCollection={dialogState.showAddCollection}
|
||||
showAddScenario={dialogState.showAddScenario}
|
||||
showVariableModal={dialogState.showVariableModal}
|
||||
onDialogChange={handleDialogChange}
|
||||
/>
|
||||
{options.type === 'api' ? (
|
||||
<APITester />
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user