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

feat: extract segment header into ads #38679

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

alex-golovanov
Copy link
Contributor

@alex-golovanov alex-golovanov commented Jan 15, 2025

Description

Extract SegmentHeader component into ADS templates.

Fixes #37688

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12789984820
Commit: 27a8d4b
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Wed, 15 Jan 2025 14:45:08 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new SegmentHeader component for the design system
    • Added documentation and Storybook stories for the component
    • Implemented a flexible header with tab navigation capabilities
  • Documentation

    • Created comprehensive Markdown documentation for the SegmentHeader
    • Added Storybook stories to showcase component functionality

@github-actions github-actions bot added IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Jan 15, 2025
Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Walkthrough

The pull request introduces a new SegmentHeader component in the design system, specifically for the Entity Explorer. This component is a flexible container designed to house navigation tabs in a split-screen IDE environment. The implementation includes a styled root element, a Storybook story for visual testing, and comprehensive documentation using MDX. The component supports rendering multiple children and provides a consistent, reusable UI element for navigation headers.

Changes

File Change Summary
...EntityExplorer/SegmentHeader/SegmentHeader.mdx New documentation file for SegmentHeader component
...EntityExplorer/SegmentHeader/SegmentHeader.stories.tsx Added Storybook story with Basic implementation
...EntityExplorer/SegmentHeader/SegmentHeader.styles.ts Created styled Root component with flexbox layout
...EntityExplorer/SegmentHeader/SegmentHeader.tsx Implemented SegmentHeader React component
...EntityExplorer/SegmentHeader/index.ts Added export for SegmentHeader component

Assessment against linked issues

Objective Addressed Explanation
Create section header component
Support optional left/right controls Current implementation lacks explicit control props
Render tabs list Storybook example shows tabs, but implementation details unclear
Wrapper component without core logic

Possibly related PRs

Suggested labels

Design System Product, ok-to-test, skip-changelog

Suggested reviewers

  • hetunandu
  • ankitakinger
  • ApekshaBhosale

Poem

In pixels and prose, a header takes flight,
Tabs dancing softly in design's pure light
Flexbox embraces each element's grace
A segment of UI, finding its place! 🎨✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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.

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.

@github-actions github-actions bot added the Enhancement New feature or request label Jan 15, 2025
@alex-golovanov alex-golovanov added the ok-to-test Required label for CI label Jan 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.stories.tsx (3)

39-39: Extract magic numbers to constants.

Hard-coded style values (height: 32, top: 0.5, minWidth: 24) should be extracted to theme constants or style variables for consistency and maintainability.

Also applies to: 59-59


41-54: Consider simplifying the story implementation.

The current implementation includes many tabs with different states. Consider reducing the complexity to demonstrate the core functionality more clearly, perhaps with just 2-3 tabs.


66-70: Consider adding more story variants.

The current implementation only shows a basic case. Consider adding variants with different widths and child component combinations to better demonstrate the component's flexibility.

app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.tsx (1)

5-7: Add JSDoc comments for better documentation.

Consider adding JSDoc comments to describe the interface and its prop.

+/**
+ * Props for the SegmentHeader component
+ */
 interface SegmentHeaderProps {
+  /** The content to be rendered inside the segment header */
   children: React.ReactNode;
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b496e4a and 27a8d4b.

📒 Files selected for processing (5)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.mdx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.stories.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.styles.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/index.ts
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.styles.ts
  • app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.mdx
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (5)
app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.stories.tsx (3)

1-17: LGTM! Well-organized imports and type-safe constant definition.


18-24: LGTM! Proper Storybook metadata configuration.


30-30: Address the TODO comment.

The comment indicates that the children components are temporary. Please ensure this is addressed before merging.

Would you like me to help track this by creating a GitHub issue?

app/client/packages/design-system/ads/src/Templates/EntityExplorer/SegmentHeader/SegmentHeader.tsx (2)

1-3: Clean and well-organized imports!

The imports are minimal and well-structured, using namespace import for styles.


8-10: Clean implementation!

The component follows React best practices with a simple and focused implementation.

Let's verify the styled component implementation:

✅ Verification successful

Styled component implementation verified ✓

Clean styling implementation using design system variables for consistent theming.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the styles file exists and contains the Root component
fd -e ts "SegmentHeader.styles.ts" -x cat {} | grep -A 5 "export const Root"

Length of output: 286

children: React.ReactNode;
}
export function SegmentHeader({ children }: SegmentHeaderProps) {
return <Styled.Root>{children}</Styled.Root>;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we not do it in the below format?

<Styled.Root>
      {props.leftControl}
      <ScrollArea>
             <Tabs>
                  <TabsList>
                        {tabs.map(() => <Tab  />)
                        <AddTab />
                        <AddButton />
                  </TabsList>
             </Tabs>
      </ScrollArea>
      {props.righControl}
</Styled.Root>

CC: @hetunandu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Short answer - no.

Long answer is - it's too limiting and super inconvenient to work with, at the same time this approach does not offer any protection against passing literally anything in those props. Additionally we cannot have tabs wrapped up in this particular component as it is in ADS and tabs will be wrapped up in all kinds of business logic.

@ankitakinger

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per our discussion, this will need a bit more thought, moving it to a draft state for now.

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI Stale Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a "Section Header" which will house the Tabs list with Left and Right controls
3 participants