diff --git a/frontend/src/components/MarketServerDetail.tsx b/frontend/src/components/MarketServerDetail.tsx index ae05496..c170950 100644 --- a/frontend/src/components/MarketServerDetail.tsx +++ b/frontend/src/components/MarketServerDetail.tsx @@ -3,10 +3,12 @@ import { useTranslation } from 'react-i18next'; import { MarketServer, MarketServerInstallation } from '@/types'; import ServerForm from './ServerForm'; +import { ServerConfig } from '@/types'; + interface MarketServerDetailProps { server: MarketServer; onBack: () => void; - onInstall: (server: MarketServer) => void; + onInstall: (server: MarketServer, config: ServerConfig) => void; installing?: boolean; isInstalled?: boolean; } @@ -83,8 +85,8 @@ const MarketServerDetail: React.FC = ({ const handleSubmit = async (payload: any) => { try { setError(null); - // Pass the server object to the parent component for installation - onInstall(server); + // Pass the server object and the payload (includes env changes) for installation + onInstall(server, payload.config); setModalVisible(false); } catch (err) { console.error('Error installing server:', err); @@ -294,4 +296,4 @@ const MarketServerDetail: React.FC = ({ ); }; -export default MarketServerDetail; \ No newline at end of file +export default MarketServerDetail; diff --git a/frontend/src/hooks/useMarketData.ts b/frontend/src/hooks/useMarketData.ts index 5f61d85..25f6316 100644 --- a/frontend/src/hooks/useMarketData.ts +++ b/frontend/src/hooks/useMarketData.ts @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; -import { MarketServer, ApiResponse } from '@/types'; +import { MarketServer, ApiResponse, ServerConfig } from '@/types'; import { getApiUrl } from '../utils/runtime'; export const useMarketData = () => { @@ -347,7 +347,7 @@ export const useMarketData = () => { // Install server to the local environment const installServer = useCallback( - async (server: MarketServer) => { + async (server: MarketServer, customConfig: ServerConfig) => { try { const installType = server.installations?.npm ? 'npm' @@ -362,13 +362,13 @@ export const useMarketData = () => { const installation = server.installations[installType]; - // Prepare server configuration + // Prepare server configuration, merging with customConfig const serverConfig = { name: server.name, config: { - command: installation.command, - args: installation.args, - env: installation.env || {}, + command: customConfig.command || installation.command || '', + args: customConfig.args || installation.args || [], + env: { ...installation.env, ...customConfig.env }, }, }; diff --git a/frontend/src/pages/MarketPage.tsx b/frontend/src/pages/MarketPage.tsx index 53caa9c..de4296e 100644 --- a/frontend/src/pages/MarketPage.tsx +++ b/frontend/src/pages/MarketPage.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate, useParams, useLocation } from 'react-router-dom'; -import { MarketServer } from '@/types'; +import { MarketServer, ServerConfig } from '@/types'; import { useMarketData } from '@/hooks/useMarketData'; import { useToast } from '@/contexts/ToastContext'; import MarketServerCard from '@/components/MarketServerCard'; @@ -90,10 +90,11 @@ const MarketPage: React.FC = () => { navigate('/market'); }; - const handleInstall = async (server: MarketServer) => { + const handleInstall = async (server: MarketServer, config: ServerConfig) => { try { setInstalling(true); - const success = await installServer(server); + // Pass the server object and the config to the installServer function + const success = await installServer(server, config); if (success) { // Show success message using toast instead of alert showToast(t('market.installSuccess', { serverName: server.display_name }), 'success'); @@ -353,4 +354,4 @@ const MarketPage: React.FC = () => { ); }; -export default MarketPage; \ No newline at end of file +export default MarketPage;