From 3fc847576a26684eee406b94cb19eabe8209b742 Mon Sep 17 00:00:00 2001 From: Long Alan Date: Fri, 2 Apr 2021 12:48:39 +0800 Subject: [PATCH 1/2] fix qna section display err --- .../src/pages/knowledge-base/table-view.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Composer/packages/client/src/pages/knowledge-base/table-view.tsx b/Composer/packages/client/src/pages/knowledge-base/table-view.tsx index 18bc90bf05..8558ad8c73 100644 --- a/Composer/packages/client/src/pages/knowledge-base/table-view.tsx +++ b/Composer/packages/client/src/pages/knowledge-base/table-view.tsx @@ -224,11 +224,15 @@ const TableView: React.FC = (props) => { actions.setMessage('item deleted'); const sectionIndex = qnaSections.findIndex((item) => item.fileId === fileId); setCreateQnAPairSettings({ groupKey: '', sectionIndex: -1 }); - removeQnAPairs({ - id: fileId, - sectionId, - projectId: actualProjectId, - }); + if (sectionId) { + removeQnAPairs({ + id: fileId, + sectionId, + projectId: actualProjectId, + }); + } else { + setQnASections(qnaSections.filter((section) => section.Answer === '' && section.Questions.length === 0)); + } // update expand status if (expandedIndex) { if (sectionIndex < expandedIndex) { @@ -252,11 +256,11 @@ const TableView: React.FC = (props) => { const groupStartIndex = qnaSections.findIndex((item) => item.fileId === fileId); // create on empty KB. let insertPosition = groupStartIndex; - if (groupStartIndex === -1) { - insertPosition = 0; - } const newGroups = getGroups(fileId); setGroups(newGroups); + if (groupStartIndex === -1) { + insertPosition = newGroups?.find((group) => group.key === fileId)?.startIndex || 0; + } const newItem = createQnASectionItem(fileId); const newQnaSections = [...qnaSections]; newQnaSections.splice(insertPosition, 0, newItem); From 6cd341757efa2f3b783310ced62cbb0680126775 Mon Sep 17 00:00:00 2001 From: Long Alan Date: Fri, 2 Apr 2021 13:14:05 +0800 Subject: [PATCH 2/2] delete empty qna pair --- .../packages/client/src/pages/knowledge-base/table-view.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/client/src/pages/knowledge-base/table-view.tsx b/Composer/packages/client/src/pages/knowledge-base/table-view.tsx index 8558ad8c73..047b7b8cd6 100644 --- a/Composer/packages/client/src/pages/knowledge-base/table-view.tsx +++ b/Composer/packages/client/src/pages/knowledge-base/table-view.tsx @@ -231,7 +231,7 @@ const TableView: React.FC = (props) => { projectId: actualProjectId, }); } else { - setQnASections(qnaSections.filter((section) => section.Answer === '' && section.Questions.length === 0)); + setQnASections(qnaSections.filter((section) => !(section.Answer === '' && section.Questions.length === 0))); } // update expand status if (expandedIndex) {