Skip to content

Commit

Permalink
Upg: allow selecting specific files in folders (#10071)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle authored Jan 17, 2025
1 parent da37bf3 commit 7475a86
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
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;
}

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

0 comments on commit 7475a86

Please sign in to comment.