Skip to content

Added sidebar to Post Analytics Beta - #23086

Merged
peterzimon merged 4 commits into
mainfrom
ta-add-post-analytics-tabs
Apr 29, 2025
Merged

peterzimon merged 4 commits into
mainfrom
ta-add-post-analytics-tabs

Conversation

@peterzimon

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/PROD-659/add-sidebar-to-ember-and-react-apps-allowing-tabs-to-work-across-both

  • So far the link between the Overview (Ember) and Web (React) views of Post Analytics has been through a simple button in the page header. We changed this to include a sidebar in both the Ember and the React version with tabs to simulate a longer term concept and design.

ref https://linear.app/ghost/issue/PROD-659/add-sidebar-to-ember-and-react-apps-allowing-tabs-to-work-across-both

- So far the link between the Overview (Ember) and Web (React) views of Post Analytics has been through a simple button in the page header. We changed this to include a sidebar in both the Ember and the React version with tabs to simulate a longer term concept and design.
@coderabbitai

coderabbitai Bot commented Apr 29, 2025 •

Copy link
Copy Markdown
Contributor

"""

Walkthrough

This set of changes focuses on restructuring and refining the layout and styling of the Post Analytics page across both the application and admin interfaces. In the main app, the PostAnalytics view and its content component are updated to adopt a grid layout, introduce a sidebar, and apply consistent typography and spacing. The Sidebar component, previously commented out, is now enabled. Breadcrumb and heading elements receive updated line height and margin classes for improved alignment. In the Ghost admin interface, the analytics template is reorganized to wrap content in a new container and move the "Web stats" link from the header to a sidebar navigation item, with conditional rendering based on user permissions and feature flags. Additionally, a comprehensive set of new CSS rules is introduced, scoped to the Traffic Analytics feature, to style the new layout and sidebar, including responsive adjustments for smaller screens.

Possibly related PRs

Suggested labels

browser-tests
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/posts/src/views/PostAnalytics/PostAnalytics.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/apps/posts".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in "apps/posts/.eslintrc.cjs".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7bf99c and 2645cb8.

📒 Files selected for processing (1)
  • apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx

[error] 87-87: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 89-89: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (1)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (1)

63-99: UI improvements align well with sidebar introduction

The styling changes to the ViewHeader, breadcrumbs, title, and published date elements create a more consistent visual hierarchy with improved vertical alignment. The leading-[24px] class on breadcrumb elements and the flex container for the published date provide better alignment and spacing.

These refinements complement the sidebar navigation being introduced in this PR, creating a cohesive layout across both Ember and React implementations.

🧰 Tools
🪛 Biome (1.9.4)

[error] 87-87: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 89-89: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@peterzimon
peterzimon enabled auto-merge (squash) April 29, 2025 11:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d66cd01 and 4a744bc.

⛔ Files ignored due to path filters (2)
  • ghost/admin/public/assets/icons/stats-overview.svg is excluded by !**/*.svg
  • ghost/admin/public/assets/icons/stats-web.svg is excluded by !**/*.svg
📒 Files selected for processing (4)
  • apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (1 hunks)
  • apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx (1 hunks)
  • ghost/admin/app/components/posts/analytics.hbs (2 hunks)
  • ghost/admin/app/styles/layouts/content.css (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx (1)
apps/shade/src/lib/utils.ts (1)
  • cn (7-9)
🪛 Biome (1.9.4)
apps/posts/src/views/PostAnalytics/PostAnalytics.tsx

[error] 87-87: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 89-89: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Lint
  • GitHub Check: Admin tests - Chrome
🔇 Additional comments (11)
ghost/admin/app/styles/layouts/content.css (4)

2227-2241: The new grid layout properly accommodates the sidebar element.

The CSS structure follows a good pattern by scoping the Traffic Analytics beta styles under the .feature-trafficAnalytics class. The grid layout using fixed column widths is appropriate for the sidebar implementation, providing a consistent sidebar width while allowing the main content to be fluid.


2252-2282: Well-implemented interactive states for sidebar navigation.

The sidebar styling includes all necessary states (default, active, hover) with appropriate visual hierarchy through color and font weight. The border-left approach for separating the sidebar from content is a clean design pattern.


2283-2327: Elegant tab state indicators with clear visual feedback.

The tab styling uses a subtle but effective approach with the :before pseudo-element for the underline indicator on hover and selected states. This provides good visual feedback while maintaining a clean aesthetic.


2395-2419: Comprehensive responsive breakpoints handle different screen sizes.

The media queries at 1320px and 1200px breakpoints properly adjust grid columns, font sizes, and spacing to maintain usability on smaller screens. The adjustments are well thought out and preserve the functionality of the interface.

apps/posts/src/views/PostAnalytics/PostAnalytics.tsx (2)

63-63: ViewHeader class adjustment improves vertical alignment.

Removing the before:hidden class allows the header to render correctly with the new sidebar layout.


68-83: Consistent line height in breadcrumb improves visual alignment.

Adding leading-[24px] to all breadcrumb elements creates consistent vertical alignment throughout the navigation path.

apps/posts/src/views/PostAnalytics/components/PostAnalyticsContent.tsx (2)

1-3: Properly enabled the Sidebar component.

Uncommenting the Sidebar import is necessary for the new layout to work correctly.


7-12: Effective switch from flex to grid layout with sidebar integration.

The layout change from flex column to a grid layout with responsive column widths is well implemented. The grid template columns use appropriate widths that match the CSS in the main stylesheet, with a responsive adjustment for extra-large screens.

The commented-out previous implementation helps maintain context for future development.

ghost/admin/app/components/posts/analytics.hbs (3)

1-1: Conditional feature flag usage is appropriate for the feature rollout.

The conditional application of the feature-trafficAnalytics class based on user permissions, configuration, and feature flag is a good approach for gradually rolling out this feature.


93-94: New content wrapper provides proper structure for sidebar layout.

The addition of the gh-post-analytics-content div creates the necessary container for implementing the grid layout that holds both the main content and sidebar.


269-278: Well-implemented sidebar with conditional rendering.

The sidebar implementation with navigation items includes proper active state on the current view and conditional rendering based on user permissions and feature flags.

Comment on lines +86 to 88
<H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
{post && post.title}
</H1>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

The heading uses optional chain pattern inconsistently.

While the code is functional, static analysis suggests using optional chaining for the post object to prevent potential runtime errors.

Apply this diff to fix the potential null/undefined reference:

-                    <H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
-                        {post && post.title}
+                    <H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
+                        {post?.title}
                    </H1>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
{post && post.title}
</H1>
<H1 className='min-h-[35px] indent-0 leading-[1.2em]'>
{post?.title}
</H1>
🧰 Tools
🪛 Biome (1.9.4)

[error] 87-87: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Comment on lines 89 to 93
{typedPost && typedPost.published_at && (
<div className='mt-1 text-sm text-grey-600'>
<div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'>
Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')}
</div>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve date container styling and fix optional chaining.

The styling changes using flex layout with specific height values creates better vertical alignment and consistency. However, there's a potential null/undefined reference with typedPost.

Apply this diff to fix the potential null/undefined reference:

-                    {typedPost && typedPost.published_at && (
+                    {typedPost?.published_at && (
                        <div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'>
                            Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')}
                        </div>
                    )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{typedPost && typedPost.published_at && (
<div className='mt-1 text-sm text-grey-600'>
<div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'>
Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')}
</div>
)}
{typedPost?.published_at && (
<div className='text-grey-600 flex h-9 items-center justify-start text-sm leading-[1.65em]'>
Published on your site on {moment.utc(typedPost.published_at).format('D MMM YYYY')} at {moment.utc(typedPost.published_at).format('HH:mm')}
</div>
)}
🧰 Tools
🪛 Biome (1.9.4)

[error] 89-89: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

@peterzimon
peterzimon merged commit 5ef111f into main Apr 29, 2025
@peterzimon
peterzimon deleted the ta-add-post-analytics-tabs branch April 29, 2025 11:47
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.

1 participant