Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey committed Nov 21, 2024
1 parent 9a47ebc commit 8045809
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 40 deletions.
2 changes: 0 additions & 2 deletions apiclient/types/knowledgesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type KnowledgeSource struct {
LastSyncStartTime *Time `json:"lastSyncStartTime,omitempty"`
LastSyncEndTime *Time `json:"lastSyncEndTime,omitempty"`
LastRunID string `json:"lastRunID,omitempty"`
FilePathPrefixInclude []string `json:"filePathPrefixInclude,omitempty"`
FilePathPrefixExclude []string `json:"filePathPrefixExclude,omitempty"`
}

type KnowledgeSourceManifest struct {
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/handlers/knowledgesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ func convertKnowledgeSource(agentName string, knowledgeSource v1.KnowledgeSource
LastSyncStartTime: types.NewTime(knowledgeSource.Status.LastSyncStartTime.Time),
LastSyncEndTime: types.NewTime(knowledgeSource.Status.LastSyncEndTime.Time),
LastRunID: knowledgeSource.Status.RunName,
FilePathPrefixExclude: knowledgeSource.Spec.Manifest.FilePathPrefixExclude,
FilePathPrefixInclude: knowledgeSource.Spec.Manifest.FilePathPrefixInclude,
}
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/handlers/knowledgefile/knowledgefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ func (h *Handler) IngestFile(req router.Request, _ router.Response) error {

// Check approval
if file.Spec.Approved == nil {
matchInclude := isFileMatchPrefixPattern(file.Spec.FileName, source.Spec.Manifest.FilePathPrefixInclude)
matchExclude := isFileMatchPrefixPattern(file.Spec.FileName, source.Spec.Manifest.FilePathPrefixExclude)
switch {
case source.Spec.Manifest.AutoApprove != nil && *source.Spec.Manifest.AutoApprove:
file.Spec.Approved = typed.Pointer(true)
case matchExclude:
case isFileMatchPrefixPattern(file.Spec.FileName, source.Spec.Manifest.FilePathPrefixExclude):
file.Spec.Approved = typed.Pointer(false)
case matchInclude:
case isFileMatchPrefixPattern(file.Spec.FileName, source.Spec.Manifest.FilePathPrefixInclude):
file.Spec.Approved = typed.Pointer(true)
}

Expand Down
81 changes: 49 additions & 32 deletions ui/admin/app/components/knowledge/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ export default function FileTreeNode({
"group"
)}
>
<div className="flex flex-1 justify-between items-center truncate">
<div className="flex items-center justify-center">
<div className="flex justify-between items-center flex-1 truncate">
<div className="flex items-center justify-center overflow-hidden">
{hasChildren ? (
isOpen ? (
<>
Expand All @@ -176,40 +176,57 @@ export default function FileTreeNode({
<File className="h-4 w-4 mr-2 flex-shrink-0" />
)}
{isFile ? (
<div
className={cn(
"font-medium truncate flex",
(file.state ===
KnowledgeFileState.Unapproved ||
file.state ===
KnowledgeFileState.PendingApproval) &&
"text-muted-foreground"
)}
>
<a
href={file.url}
target="_blank"
rel="noopener noreferrer"
className="hover:underline"
>
<Tooltip>
<TooltipTrigger asChild>
<a
href={file.url}
target="_blank"
rel="noopener noreferrer"
className={cn(
"hover:underline truncate flex flex-1 overflow-hidden",
(file.state ===
KnowledgeFileState.Unapproved ||
file.state ===
KnowledgeFileState.PendingApproval) &&
"text-muted-foreground"
)}
>
<span className="truncate">
{
getKnowledgeFileDisplayName(
file,
source
).displayName
}
</span>
</a>
</TooltipTrigger>
<TooltipContent>
{
getKnowledgeFileDisplayName(
file,
source
).displayName
}
</a>
</div>
</TooltipContent>
</Tooltip>
) : (
<span
className={cn(
"font-medium truncate flex",
selectedFiles === 0 &&
"text-muted-foreground"
)}
>
{node.name}
</span>
<Tooltip>
<TooltipTrigger asChild>
<span
className={cn(
"font-medium truncate flex",
selectedFiles === 0 &&
"text-muted-foreground"
)}
>
{node.name}
</span>
</TooltipTrigger>
<TooltipContent>
{node.name}
</TooltipContent>
</Tooltip>
)}
{isFile ? (
<div className="flex flex-row items-center justify-center ml-2">
Expand Down Expand Up @@ -248,7 +265,7 @@ export default function FileTreeNode({
)}
</div>
{!disableToggleButton && (
<div className="flex flex-row items-center group mr-2">
<div className="flex items-center group mr-2 ml-2">
<Button
variant="ghost"
size="icon"
Expand All @@ -272,11 +289,11 @@ export default function FileTreeNode({
});
}
}}
className="justify-start items-center group ml-2 invisible group-hover:visible hover:bg-gray-200"
className="justify-center items-center group invisible group-hover:visible hover:bg-gray-200"
>
<Tooltip>
<TooltipTrigger asChild>
<div className="flex justify-center items-center ml-2">
<div className="flex justify-center items-center">
{included ? (
<MinusIcon className="w-4 h-4 text-destructive" />
) : (
Expand Down

0 comments on commit 8045809

Please sign in to comment.