8000 chore: editor sidebar tree view by EDsCODE · Pull Request #33250 · PostHog/posthog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: editor sidebar tree view #33250

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

Merged
merged 24 commits into from
Jun 12, 2025
Merged

chore: editor sidebar tree view #33250

merged 24 commits into from
Jun 12, 2025

Conversation

EDsCODE
Copy link
Member
@EDsCODE EDsCODE commented Jun 5, 2025

Problem

  • sql editor sidebar is out of date and incongruent with new tree view

Changes

  • usee the new tree view
  • implemented completely clientside as the first pass
    CleanShot 2025-06-05 at 14 21 02

TODO

  • feature flag
  • set up API for file system

</DropdownMenu>
)}
{itemSideAction &&
itemSideAction(item) !== undefined &&
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about the best pattern here without blowing up any defaults but I needed something where I could override sideaction through icon

@EDsCODE EDsCODE requested a review from a team June 5, 2025 18:27
@@ -293,7 +293,7 @@ const LemonTreeNode = forwardRef<HTMLDivElement, LemonTreeNodeProps>(
<div className={cn('flex flex-col gap-y-px list-none m-0 p-0 h-full w-full', className)}>
Copy link
Member Author

Choose a reason for hiding this comment

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

@adamleithp @mariusandra some slight changes here to core tree component. No strong opinions here/happy to take suggestions if there's a built in way to do what I'm doing here. The plus button on sources needs to be a direct link and not trigger a dropdown

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll have a look tonight!

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

7 snapshot changes in total. 0 added, 7 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor
@adamleithp adamleithp left a comment

Choose a reason for hiding this comment

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

pushed a small change to help! You were rendering two buttons, now it's just one prop for button + cleaned up my mess a bit

@EDsCODE EDsCODE marked this pull request as ready for review June 9, 2025 03:25
@EDsCODE EDsCODE requested a review from a team June 9, 2025 03:26
Copy link
Contributor
@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Implements a new tree view UI for the SQL editor sidebar with client-side search functionality and improved database table organization.

  • Upgraded LemonTree component in frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx with consolidated action button prop and improved folder detection logic
  • Added fuzzy search with Fuse.js in new queryDatabaseLogic.tsx, replacing old schema management implementation
  • Set fixed height (39px) in frontend/src/scenes/data-warehouse/editor/EditorScene.scss to match tree view nav bar
  • Cleaned up button styling by removing unnecessary transition classes and improving type safety
  • TODO items remain: feature flag implementation and API setup for filesystem

11 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -1,6 +1,8 @@
.EditorScene {
.LemonTabs__bar {
margin-bottom: 1px;
// height is hardcoded to match implicit height from tree view nav bar˝
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: There's a rogue unicode character '˝' at the end of this comment line that should be removed

Suggested change
// height is hardcoded to match implicit height from tree view nav bar˝
// height is hardcoded to match implicit height from tree view nav bar

</DropdownMenuTrigger>

{/* The Dropdown content menu */}
{!!itemSideAction(item) && (
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Extra !! operator unnecessary since itemSideAction(item) is already checked

Suggested change
{!!itemSideAction(item) && (
{itemSideAction(item) && (

Comment on lines +11 to +13
const { treeRef } = useValues(queryDatabaseLogic)
const { searchTerm } = useValues(queryDatabaseLogic)
const { setSearchTerm, clearSearch } = useActions(queryDatabaseLogic)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider destructuring values in a single useValues call for better performance

=> {
// Copy column name when clicking on a column
if (item && item.record?.type === 'column') {
void copyToClipboard(item.record.columnName, item.record.columnName)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Duplicate parameter passed to copyToClipboard - columnName used twice

Suggested change
void copyToClipboard(item.record.columnName, item.record.columnName)
void copyToClipboard(item.record.columnName, 'Column name')

return []
}

const relevantJoins = joins.filter((join) => join.source_table_name === table!.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Unnecessary non-null assertion (!). The table variable is already checked to be non-null in the condition above

Suggested change
const relevantJoins = joins.filter((join) => join.source_table_name === table!.name)
const relevantJoins = joins.filter((join) => join.source_table_name === table.name)

Comment on lines +56 to +61
const FUSE_OPTIONS: Fuse.IFuseOptions<any> = {
keys: [{ name: 'name', weight: 2 }],
threshold: 0.3,
ignoreLocation: true,
includeMatches: true,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider moving FUSE_OPTIONS to a constants file for better maintainability

EDsCODE and others added 2 commits June 9, 2025 10:17
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Copy link
Member
@Gilbert09 Gilbert09 left a comment

Choose a reason for hiding this comment

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

bliemy, new logic is big, but overall this looks good - im liking the UI

)

Object.entries(tablesBySourceType).forEach(([sourceType, tablesWithMatches]) => {
expandedIds.push(`search-${sourceType}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an inconsistency between the ID formats used for search expansion. In createSourceFolderNode(), the ID is normalized with sourceType === 'PostHog' ? 'posthog' : sourceType, but here the raw sourceType is used without normalization. This could prevent auto-expansion from working correctly for some source types, particularly "PostHog". Consider using the same normalization logic in both places:

expandedIds.push(`search-${sourceType === 'PostHog' ? 'posthog' : sourceType}`)
Suggested change
expandedIds.push(`search-${sourceType}`)
expandedIds.push(`search-${sourceType === 'PostHog' ? 'posthog' : sourceType}`)

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor
github-actions bot commented Jun 9, 2025

Size Change: +44 B (0%)

Total Size: 1.83 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 1.83 MB +44 B (0%)

compressed-size-action

Comment on lines +132 to +134
const viewId = item.id.startsWith('search-view-')
? item.id.replace('search-view-', '')
: item.id.replace('view-', '')
Copy link
Contributor

Choose a reason for hiding this comment

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

The ID extraction logic may not handle edge cases where the view ID itself contains the substring view-. Consider using a more robust approach such as a regex with capture groups or splitting the string and taking the appropriate part. For example:

// More robust approach
const viewId = item.id.startsWith('search-view-') 
  ? item.id.substring('search-view-'.length)
  : item.id.substring('view-'.length)

This ensures correct extraction regardless of the ID's content.

Suggested change
const viewId = item.id.startsWith('search-view-')
? item.id.replace('search-view-', '')
: item.id.replace('view-', '')
const viewId = item.id.startsWith('search-view-')
? item.id.substring('search-view-'.length)
: item.id.substring('view-'.length)

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

Caution

Detected flapping snapshots

These snapshots have auto-updated more than once since the last human commit:

  • scenes-app-insights-funnels--funnel-top-to-bottom--light.png (chromium, shard 2)

The flippy-flappies are deadly and must be fixed ASAP. They're productivity killers.
Run pnpm storybook locally and make the fix now.
(Often, the cause is ResizeObserver being used instead of the better CSS container queries.)

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@EDsCODE EDsCODE merged commit bb81bda into master Jun 12, 2025
97 checks passed
@EDsCODE EDsCODE deleted the editor-sidebar-tree-view branch June 12, 2025 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0