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

chore(sidebar): sidebar editor database #33808

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

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

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

Problem

  • too many sidebars stacked from the left

Changes

  • make the editor sidebar part of the tree sidebar
  • follow up to delete all unused code

TODO:

  • move query var and materialization options to separate panel
    CleanShot 2025-06-17 at 11 49 43
    CleanShot 2025-06-17 at 21 46 29

@EDsCODE EDsCODE changed the base branch from master to sidebar-data-management June 17, 2025 15:51
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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

Size Change: 0 B

Total Size: 2.57 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2.57 MB

compressed-size-action

@EDsCODE EDsCODE marked this pull request as ready for review June 18, 2025 01:47
@EDsCODE EDsCODE requested review from a team and mariusandra June 18, 2025 01:47
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

Major refactoring of the SQL editor's sidebar UI to reduce layout clutter by consolidating multiple sidebars into a unified tree structure.

  • Introduced new DatabaseTree component in frontend/src/layout/panel-layout/DatabaseTree/DatabaseTree.tsx to integrate with existing panel layout system
  • Refactored QueryWindow and QueryPane from column-based to row-based flexbox to support the new panel layout
  • Added QuerySecondaryPanel enum in multitabEditorLogic.tsx to manage Variables and Info panels visibility
  • Integrated editor sidebar functionality with panel layout system through PanelLayoutNavBar Database navigation item
  • Removed separate EditorSidebar while preserving all functionality through the tree sidebar structure

12 files reviewed, 4 comments
Edit PR Review Bot Settings | Greptile

Comment on lines +171 to +181
{
identifier: 'Database',
id: 'Database',
icon: <IconDatabase />,
onClick: (e?: React.KeyboardEvent) => {
if (!e || e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowRight') {
handlePanelTriggerClick('Database')
}
},
showChevron: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Both Database and Data management items use the same <IconDatabase /> icon, which could be confusing to users. Consider using distinct icons to differentiate these sections.

Comment on lines 163 to +166
{activePanelIdentifier === 'Shortcuts' && (
<ProjectTree root="shortcuts://" searchPlaceholder="Search your shortcuts" />
)}
{activePanelIdentifier === 'Database' && <DatabaseTree />}
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 adding a searchPlaceholder prop to DatabaseTree for consistency with other tree components

Comment on lines 78 to 82
=>
setSecondaryPanel(
secondaryPanel === QuerySecondaryPanel.Variables ? null : QuerySecondaryPanel.Variables
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This pattern is repeated twice. Consider extracting panel toggle logic into a reusable function to avoid duplication

{secondaryPanel && (
<div className="relative flex flex-row w-1/2">
{secondaryPanel === QuerySecondaryPanel.Info && (
<QueryInfo codeEditorKey={props.codeEditorProps.queryKey} />
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: codeEditorProps.queryKey might be undefined since it's part of Partial<CodeEditorProps>. Add null check to prevent runtime errors.

@EDsCODE
Copy link
Member Author
EDsCODE commented Jun 18, 2025

need a new icon for database sidebar item

@Gilbert09
Copy link
Member

Hmmm, can't say I'm a fan of the right side panel. I think having materialisation and variables back in the output pane (but with icons on the tabs) would be better. I also worry that someone may close the database panel and not realise how to reopen it (finding "database" in a side panel full of other items isn't obvious). Maybe adding a icon-only "database" button to the left of the query tabs to open the panel would be helpful here

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Collaborator
@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

If I have no views, the view looks weird:

2025-06-18 13 53 58

I really want to just click the table and get a query. Could we have either as the first item when the table opens a "--> select *" button that makes a query with the table, or then add it to the dropdown here:

image

Basically I'm missing some way to go to the query editor (or just some kind of data browser) from the database view.

Then +1 to the idea of putting a "toggle database" or similar button to the left of the tabs in the query editor, which would show/hide the panel.

I'm not against the right tabs, though it feels like they could be full height perhaps? They're not perfect as they are, but overall with the sidebars I'd say this is all a step in the right direction, so... 🤔

2025-06-18 13 59 15

Base automatically changed from sidebar-data-management to master June 18, 2025 12:49
@EDsCODE
Copy link
Member Author
EDsCODE commented Jun 19, 2025

Some more state cleanup but worth a look with these changes:

  • button to show sidebar when closed
  • more links from views and queries to editor
  • variables and materialization to the bottom

CleanShot 2025-06-19 at 12 12 14

@EDsCODE EDsCODE requested review from mariusandra and Gilbert09 June 19, 2025 16:13
@phixMe
Copy link
Contributor
phixMe commented Jun 19, 2025

I think we could have a better default for materialization where we say "Save and materialize" or hide the tab all together although I think the former is better.

I am happy with a more landscape space to work with as we add some more elements here, like longer tables and a graph for example.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

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

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@EDsCODE
Copy link
Member Author
EDsCODE commented Jun 19, 2025

I think we could have a better default for materialization where we say "Save and materialize" or hide the tab all together although I think the former is better.

I am happy with a more landscape space to work with as we add some more elements here, like longer tables and a graph for example.

good point, bringing this back
CleanShot 2025-06-19 at 12 53 35@2x

Comment on lines +499 to +503
urlToAction({
[urls.sqlEditor()]: () => {
panelLayoutLogic.actions.setActivePanelIdentifier('Database')
},
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't check, but this may cause some issues if you have a very small screen --> the panel might open in a weird way on top of everything else

<DropdownMenuItem
asChild
=> {
e.stopPropagation()
selectSourceTable(item.name)
if (router.values.location.pathname.endsWith(urls.sqlEditor())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be nicer as a selector somewhere

Copy link
Collaborator
@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

Overall looks good to me! I could probably nit on some things here and there (fonts 🙈), but let's get it in and iterate then.

The playwright tests probably need to be updated though...

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.

5 participants
0