Skip to content

Commit

Permalink
feat(knowledge): change path to files for create and update
Browse files Browse the repository at this point in the history
  • Loading branch information
Carrotzpc committed Mar 28, 2024
1 parent 14bb46e commit 351bdb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/pages/KnowledgeCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ class KnowledgeCreate$$Page extends React.Component {
name: version,
namespace: this.utils.getAuthData().project,
},
path: selectFiles,
files: selectFiles.map(path => ({
path,
})),
},
];
try {
Expand Down
18 changes: 13 additions & 5 deletions src/pages/KnowledgeDetail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,25 @@ class KnowledgeDetail$$Page extends React.Component {
const knowledge = this.getKnowledge();
const fileGroups = (knowledge.fileGroupDetails || []).map(fgd => ({
source: fgd.source,
path: fgd.filedetails.map(detail => detail.path),
files: fgd.filedetails.map(detail => ({
path: detail.path,
})),
}));
const version = this.getCurrentDatasetAndVersion().version;
const targetFileGroupIndex = fileGroups.findIndex(fg => fg.source?.name === version);
if (targetFileGroupIndex > -1) {
fileGroups[targetFileGroupIndex].path = modalFilesSelectedKeys;
fileGroups[targetFileGroupIndex].files = modalFilesSelectedKeys.map(path => ({
path,
}));
} else {
fileGroups.push({
source: {
kind: 'VersionedDataset',
name: version,
},
path: modalFilesSelectedKeys,
files: modalFilesSelectedKeys.map(path => ({
path,
})),
});
}
const input = {
Expand Down Expand Up @@ -400,9 +406,11 @@ class KnowledgeDetail$$Page extends React.Component {
const knowledge = this.getKnowledge();
const fileGroups = (knowledge.fileGroupDetails || []).map(fgd => ({
source: fgd.source,
path: fgd.filedetails
files: fgd.filedetails
.filter(detail => detail.path !== path || fgd.source.name !== source)
.map(detail => detail.path),
.map(detail => ({
path: detail.path,
})),
}));
const input = {
name: knowledge.name,
Expand Down

0 comments on commit 351bdb7

Please sign in to comment.