feat(web): agent and multi_agent handleSave function add promise resolve result
This commit is contained in:
@@ -311,17 +311,15 @@ const Agent = forwardRef<AgentRef>((_props, ref) => {
|
|||||||
enabled: vo.enabled
|
enabled: vo.enabled
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('params', rest, params)
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
saveAgentConfig(data.app_id, params)
|
saveAgentConfig(data.app_id, params)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
message.success(t('common.saveSuccess'))
|
message.success(t('common.saveSuccess'))
|
||||||
}
|
}
|
||||||
setIsSave(false)
|
setIsSave(false)
|
||||||
resolve(true)
|
resolve(res)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -58,16 +58,14 @@ const Cluster = forwardRef<ClusterRef>((_props, ref) => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('params', params)
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
form.validateFields().then(() => {
|
form.validateFields().then(() => {
|
||||||
saveMultiAgentConfig(id as string, params)
|
saveMultiAgentConfig(id as string, params)
|
||||||
.then(() => {
|
.then((res) => {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
message.success(t('common.saveSuccess'))
|
message.success(t('common.saveSuccess'))
|
||||||
}
|
}
|
||||||
resolve(true)
|
resolve(res)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import exportIcon from '@/assets/images/export_hover.svg'
|
|||||||
import deleteIcon from '@/assets/images/delete_hover.svg'
|
import deleteIcon from '@/assets/images/delete_hover.svg'
|
||||||
import type { Application, ApplicationModalRef } from '@/views/ApplicationManagement/types';
|
import type { Application, ApplicationModalRef } from '@/views/ApplicationManagement/types';
|
||||||
import ApplicationModal from '@/views/ApplicationManagement/components/ApplicationModal'
|
import ApplicationModal from '@/views/ApplicationManagement/components/ApplicationModal'
|
||||||
import type { CopyModalRef, WorkflowRef } from '../types'
|
import type { CopyModalRef, AgentRef, ClusterRef, WorkflowRef } from '../types'
|
||||||
import { deleteApplication } from '@/api/application'
|
import { deleteApplication } from '@/api/application'
|
||||||
import CopyModal from './CopyModal'
|
import CopyModal from './CopyModal'
|
||||||
|
|
||||||
@@ -30,10 +30,11 @@ interface ConfigHeaderProps {
|
|||||||
handleChangeTab: (key: string) => void;
|
handleChangeTab: (key: string) => void;
|
||||||
refresh: () => void;
|
refresh: () => void;
|
||||||
workflowRef: React.RefObject<WorkflowRef>
|
workflowRef: React.RefObject<WorkflowRef>
|
||||||
|
appRef?: React.RefObject<AgentRef | ClusterRef | WorkflowRef>
|
||||||
}
|
}
|
||||||
const ConfigHeader: FC<ConfigHeaderProps> = ({
|
const ConfigHeader: FC<ConfigHeaderProps> = ({
|
||||||
application, activeTab, handleChangeTab, refresh,
|
application, activeTab, handleChangeTab, refresh,
|
||||||
workflowRef
|
workflowRef,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -48,7 +49,7 @@ const ConfigHeader: FC<ConfigHeaderProps> = ({
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
const formatMenuItems = () => {
|
const formatMenuItems = () => {
|
||||||
const items = ['edit', 'copy', 'delete'].map(key => ({
|
const items = ['edit', 'copy', 'export', 'delete'].map(key => ({
|
||||||
key,
|
key,
|
||||||
icon: <img src={menuIcons[key]} className="rb:w-4 rb:h-4 rb:mr-2" />,
|
icon: <img src={menuIcons[key]} className="rb:w-4 rb:h-4 rb:mr-2" />,
|
||||||
label: t(`common.${key}`),
|
label: t(`common.${key}`),
|
||||||
@@ -59,7 +60,6 @@ const ConfigHeader: FC<ConfigHeaderProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleClick: MenuProps['onClick'] = ({ key }) => {
|
const handleClick: MenuProps['onClick'] = ({ key }) => {
|
||||||
console.log('key', key)
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'edit':
|
case 'edit':
|
||||||
applicationModalRef.current?.handleOpen(application as Application)
|
applicationModalRef.current?.handleOpen(application as Application)
|
||||||
|
|||||||
@@ -60,10 +60,11 @@ const ApplicationConfig: React.FC = () => {
|
|||||||
handleChangeTab={handleChangeTab}
|
handleChangeTab={handleChangeTab}
|
||||||
application={application as Application}
|
application={application as Application}
|
||||||
refresh={getApplicationInfo}
|
refresh={getApplicationInfo}
|
||||||
|
appRef={application?.type === 'agent' ? agentRef : application?.type === 'multi_agent' ? clusterRef : application?.type === 'workflow' ? workflowRef : undefined}
|
||||||
workflowRef={workflowRef}
|
workflowRef={workflowRef}
|
||||||
/>
|
/>
|
||||||
{activeTab === 'arrangement' && application?.type === 'agent' && <Agent ref={agentRef} />}
|
{activeTab === 'arrangement' && application?.type === 'agent' && <Agent ref={agentRef} />}
|
||||||
{activeTab === 'arrangement' && application?.type === 'multi_agent' && <Cluster ref={clusterRef} application={application as Application} />}
|
{activeTab === 'arrangement' && application?.type === 'multi_agent' && <Cluster ref={clusterRef} />}
|
||||||
{activeTab === 'arrangement' && application?.type === 'workflow' && <Workflow ref={workflowRef} />}
|
{activeTab === 'arrangement' && application?.type === 'workflow' && <Workflow ref={workflowRef} />}
|
||||||
{activeTab === 'api' && <Api application={application} />}
|
{activeTab === 'api' && <Api application={application} />}
|
||||||
{activeTab === 'release' && <ReleasePage data={application as Application} refresh={getApplicationInfo} />}
|
{activeTab === 'release' && <ReleasePage data={application as Application} refresh={getApplicationInfo} />}
|
||||||
|
|||||||
Reference in New Issue
Block a user