Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upg: allow selecting specific files in folders for assistants #10071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,7 @@ function DataSourceViewsSection({
return (
<Tree.Item
key={`${dsConfig.dataSourceViewId}-${JSON.stringify(dsConfig.filter)}`}
type={
canBeExpanded(viewType, dataSourceView?.dataSource)
? "node"
: "leaf"
}
type={canBeExpanded(dataSourceView?.dataSource) ? "node" : "leaf"}
label={dataSourceName}
visual={dsLogo ?? FolderIcon}
className="whitespace-nowrap"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function DataSourceSelectionSection({
<Tree.Item
key={dsConfig.dataSourceView.sId}
type={
canBeExpanded(viewType, dsConfig.dataSourceView.dataSource)
canBeExpanded(dsConfig.dataSourceView.dataSource)
? "node"
: "leaf"
} // todo make useConnectorPermissions hook work for non managed ds (Folders)
Expand Down
4 changes: 1 addition & 3 deletions front/components/data_source_view/DataSourceViewSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,7 @@ export function DataSourceViewSelector({
label={getDisplayNameForDataSource(dataSourceView.dataSource)}
visual={LogoComponent}
defaultCollapsed={defaultCollapsed}
type={
canBeExpanded(viewType, dataSourceView.dataSource) ? "node" : "leaf"
}
type={canBeExpanded(dataSourceView.dataSource) ? "node" : "leaf"}
checkbox={
hideCheckbox || (!isRootSelectable && !hasActiveSelection)
? undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const TrackerDataSourceSelectedTree = ({
<Tree.Item
key={dsConfig.dataSourceView.sId}
type={
canBeExpanded("documents", dsConfig.dataSourceView.dataSource)
canBeExpanded(dsConfig.dataSourceView.dataSource)
? "node"
: "leaf"
} // todo make useConnectorPermissions hook work for non managed ds (Folders)
Expand Down
10 changes: 2 additions & 8 deletions front/lib/data_sources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type {
ConnectorProvider,
ContentNodesViewType,
CoreAPIDocument,
DataSourceType,
DataSourceViewType,
Expand Down Expand Up @@ -96,16 +95,11 @@ export function supportsStructuredData(ds: DataSource): boolean {
);
}

export function canBeExpanded(
viewType: ContentNodesViewType,
ds?: DataSource
): boolean {
export function canBeExpanded(ds?: DataSource): boolean {
if (!ds) {
return false;
}
// Folders with viewType "documents" are always considered leaf items.
// For viewType "tables", folders are not leaf items because users need to select a specific table.
return !isFolder(ds) || viewType === "tables";
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the function could become just !!ds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I figured we keep it for future ease of usage if we want to disallow expand again for something else.

}

export function getDataSourceNameFromView(dsv: DataSourceViewType): string {
Expand Down
Loading