fix:loading
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
* @Author: yujiangping
|
* @Author: yujiangping
|
||||||
* @Date: 2025-11-10 18:52:55
|
* @Date: 2025-11-10 18:52:55
|
||||||
* @LastEditors: yujiangping
|
* @LastEditors: yujiangping
|
||||||
* @LastEditTime: 2026-03-03 14:46:08
|
* @LastEditTime: 2026-03-09 16:39:07
|
||||||
*/
|
*/
|
||||||
import { forwardRef, useImperativeHandle, useState, useRef } from 'react';
|
import { forwardRef, useImperativeHandle, useState, useRef } from 'react';
|
||||||
import { Switch } from 'antd';
|
import { Switch } from 'antd';
|
||||||
@@ -58,16 +58,21 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleShare = async() => {
|
const handleShare = async() => {
|
||||||
const workspaceIds = spaceList
|
setLoading(true);
|
||||||
.map(item => item.target_kb?.workspace_id)
|
try {
|
||||||
.filter(Boolean)
|
const workspaceIds = spaceList
|
||||||
.join(',');
|
.map(item => item.target_kb?.workspace_id)
|
||||||
|
.filter(Boolean)
|
||||||
console.log('Workspace IDs:', workspaceIds);
|
.join(',');
|
||||||
shareSpaceModalRef?.current?.handleOpen(kbId,knowledgeBase,workspaceIds);
|
|
||||||
|
console.log('Workspace IDs:', workspaceIds);
|
||||||
// Close modal after sharing
|
shareSpaceModalRef?.current?.handleOpen(kbId,knowledgeBase,workspaceIds);
|
||||||
handleClose();
|
|
||||||
|
// Close modal after sharing
|
||||||
|
handleClose();
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const handleChange = (checked: boolean, item: any) => {
|
const handleChange = (checked: boolean, item: any) => {
|
||||||
// Toggle shared knowledge base status
|
// Toggle shared knowledge base status
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* @Author: yujiangping
|
* @Author: yujiangping
|
||||||
* @Date: 2025-11-10 18:52:55
|
* @Date: 2025-11-10 18:52:55
|
||||||
* @LastEditors: yujiangping
|
* @LastEditors: yujiangping
|
||||||
* @LastEditTime: 2025-12-03 18:44:58
|
* @LastEditTime: 2026-03-09 16:34:51
|
||||||
*/
|
*/
|
||||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
import { Switch } from 'antd';
|
import { Switch } from 'antd';
|
||||||
@@ -50,34 +50,38 @@ const ShareModal = forwardRef<ShareModalRef,ShareModalRefProps>(({ handleShare:
|
|||||||
setSpaceList(filteredItems as SpaceItem[]);
|
setSpaceList(filteredItems as SpaceItem[]);
|
||||||
}
|
}
|
||||||
const handleShare = async() => {
|
const handleShare = async() => {
|
||||||
|
|
||||||
// Get all data with checked = true
|
// Get all data with checked = true
|
||||||
const checkedItems = spaceList.filter(item => item.is_active);
|
const checkedItems = spaceList.filter(item => item.is_active);
|
||||||
debugger
|
|
||||||
// Get currently selected item (corresponding to curIndex)
|
// Get currently selected item (corresponding to curIndex)
|
||||||
const selectedItem = curIndex !== -1 ? spaceList[curIndex] : null;
|
const selectedItem = curIndex !== -1 ? spaceList[curIndex] : null;
|
||||||
if(!selectedItem){
|
if(!selectedItem){
|
||||||
messageApi.error(t('knowledgeBase.selectSpace'));
|
messageApi.error(t('knowledgeBase.selectSpace'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const payload = {
|
|
||||||
source_kb_id: kbId ?? '',
|
|
||||||
target_workspace_id: selectedItem?.id ?? '',
|
|
||||||
}
|
|
||||||
const respose = await shareKnowledgeBase(payload)
|
|
||||||
if(respose){
|
|
||||||
messageApi.success(t('knowledgeBase.shareSuccess'));
|
|
||||||
}else{
|
|
||||||
messageApi.error(t('knowledgeBase.shareFailed'));
|
|
||||||
}
|
|
||||||
// Call parent component's callback function with selected data
|
|
||||||
onShare?.({
|
|
||||||
checkedItems,
|
|
||||||
selectedItem
|
|
||||||
});
|
|
||||||
|
|
||||||
// Close modal after sharing
|
setLoading(true);
|
||||||
handleClose();
|
try {
|
||||||
|
const payload = {
|
||||||
|
source_kb_id: kbId ?? '',
|
||||||
|
target_workspace_id: selectedItem?.id ?? '',
|
||||||
|
}
|
||||||
|
const respose = await shareKnowledgeBase(payload)
|
||||||
|
if(respose){
|
||||||
|
messageApi.success(t('knowledgeBase.shareSuccess'));
|
||||||
|
}else{
|
||||||
|
messageApi.error(t('knowledgeBase.shareFailed'));
|
||||||
|
}
|
||||||
|
// Call parent component's callback function with selected data
|
||||||
|
onShare?.({
|
||||||
|
checkedItems,
|
||||||
|
selectedItem
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close modal after sharing
|
||||||
|
handleClose();
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const handleClick = (index: number, checked: boolean) => {
|
const handleClick = (index: number, checked: boolean) => {
|
||||||
if (!checked) return;
|
if (!checked) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user