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

chore: Move IDE Sidebar into ADS #38641

Merged
merged 6 commits into from
Jan 14, 2025
Merged

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Jan 14, 2025

Description

We are making the IDE sidebar an ADS template that can be used by other IDEs with ease

Fixes #38640

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12766796609
Commit: 5466245
Cypress dashboard.
Tags: @tag.IDE
Spec:


Tue, 14 Jan 2025 12:10:17 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new IDESidebar component for enhanced sidebar functionality.
    • Added a new SidebarButton component with interactive elements and conditional rendering.
    • Implemented a Condition enum for button state management.
    • Enhanced export capabilities from the Sidebar module.
    • Added new styled components for improved visual representation of sidebar elements.
  • Bug Fixes

    • Updated types for IDESidebarButton and IDESidebarProps for improved compatibility.
  • Documentation

    • Added Storybook configuration for the IDESidebar component to showcase usage examples.
  • Refactor

    • Reorganized sidebar components and moved them to a design system package.
    • Updated import paths for sidebar-related components and types across multiple files.

Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Walkthrough

The pull request introduces modifications to the IDESidebar and SidebarButton components in the design system. Key changes include the addition of the IDESidebar function component, which accepts various props and renders a sidebar with interactive buttons. A new SidebarButton component is also introduced, featuring conditional rendering capabilities based on the Condition enum. Additionally, various import statements are updated, and tests for the SidebarButton are streamlined using the screen utility from @testing-library/react.

Changes

File Change Summary
.../Sidebar/Sidebar.tsx Introduced IDESidebar function component; accepts and destructures props for rendering.
.../SidebarButton/SidebarButton.tsx Added SidebarButton component with props for icon, tooltip, and condition-based rendering.
.../Sidebar/enums.ts Added Condition enum with Warn member.
.../Sidebar/index.tsx Updated exports to include IDESidebar, IDESidebarButton, and Condition.
.../IDE/index.ts Removed exports for IDESidebar, IDESidebarButton, and Condition.
.../constants.ts Updated import for IDESidebarButton type.
.../Editor/IDE/Sidebar.tsx Modified import statements for IDESidebar and Condition.
.../Sidebar/SidebarButton/SidebarButton.test.tsx Streamlined tests for SidebarButton using screen utility.
.../Sidebar/Sidebar.stories.tsx Introduced Storybook stories for IDESidebar.
.../SidebarButton/index.ts Added export statement for SidebarButton.
.../Components/Sidebar/index.tsx Removed exports for Sidebar component and IDESidebarButton type.
.../SidebarButton/constants.ts Added ConditionConfig constant mapping conditions to icons and colors.
.../SidebarButton/styles.ts Introduced styled-components for SidebarButton including Container, IconContainer, and ConditionIcon.
.../styles.ts Added Container styled component for the sidebar.
.../SidebarButton/SidebarButton.types.ts Introduced SidebarButtonProps interface for button properties.
.../types.ts Added IDESidebarButton and IDESidebarProps interfaces for sidebar button management.

Possibly related PRs

Suggested labels

Enhancement

Suggested Reviewers

  • ankitakinger
  • ApekshaBhosale
  • sagar-qa007

Poem

In the sidebar, buttons gleam,
A dance of code, a seamless dream! ✨
With props and states, they come alive,
In this UI world, we thrive! 🎉
Click and hover, watch them play,
A joyful journey, day by day! 💻


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1db59c2 and 5466245.

📒 Files selected for processing (1)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests

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 IDE Navigation Issues/feature requests related to IDE navigation, and context switching 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 14, 2025
@hetunandu hetunandu added the ok-to-test Required label for CI label Jan 14, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 14, 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: 2

🧹 Nitpick comments (3)
app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.test.tsx (1)

17-60: Add test coverage for tooltip and remaining conditions.

While the current tests cover core functionality, consider adding tests for:

  • Tooltip rendering and content
  • Other conditions that will be added (mentioned in TODO)
  • Title rendering
app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1)

7-15: Consider making the sidebar width configurable.

The fixed width of 50px might not work well across different screen sizes and resolutions.

-  width: 50px;
+  width: ${props => props.width || '50px'};
app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (1)

15-18: Create issue to track remaining condition implementations.

The TODO comment indicates pending work for Error and Success conditions.

Would you like me to create a GitHub issue to track the implementation of the remaining conditions?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b6f7164 and 3e55989.

📒 Files selected for processing (10)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.test.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/index.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/enums.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/index.ts (1 hunks)
  • app/client/src/IDE/index.ts (0 hunks)
  • app/client/src/ce/entities/IDE/constants.ts (1 hunks)
  • app/client/src/pages/Editor/IDE/Sidebar.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/IDE/index.ts
✅ Files skipped from review due to trivial changes (4)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/enums.ts
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/index.ts
  • app/client/src/pages/Editor/IDE/Sidebar.tsx
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (2)
app/client/packages/design-system/ads/src/Templates/index.ts (1)

3-3: LGTM! Clean export statement following the existing pattern.

app/client/src/ce/entities/IDE/constants.ts (1)

24-24: LGTM! Import path update aligns with modularization.

The updated import path reflects the move of IDE components to ADS, supporting better modularity.

Let's verify the new import path exists:

✅ Verification successful

Import path is valid and aligns with IDE component refactoring

The type IDESidebarButton exists in the design system package and the import path is correctly updated as part of moving IDE components to ADS.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the new import path exists and exports IDESidebarButton
ast-grep --pattern 'export type IDESidebarButton'

Length of output: 130878


Script:

#!/bin/bash
# Search for any mention of IDESidebarButton
rg "IDESidebarButton"

# Look for IDE sidebar related files
fd -t f -e ts -e tsx "sidebar" app/client/src

# Check if @appsmith/ads exists
fd -t d "ads" app/client/src

Length of output: 2345

Comment on lines 36 to 69
return (
<Container className="t--sidebar" id={props.id}>
<div>
{topButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
<div>
{bottomButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
</Container>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add ARIA attributes and extract button rendering logic.

  1. Add navigation role for accessibility:
-    <Container className="t--sidebar" id={props.id}>
+    <Container className="t--sidebar" id={props.id} role="navigation" aria-label="IDE Navigation">
  1. Consider extracting the repeated button mapping logic into a reusable function to avoid duplication.
📝 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
return (
<Container className="t--sidebar" id={props.id}>
<div>
{topButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
<div>
{bottomButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
</Container>
);
return (
<Container className="t--sidebar" id={props.id} role="navigation" aria-label="IDE Navigation">
<div>
{topButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
<div>
{bottomButtons.map((button) => (
<SidebarButton
condition={button.condition}
icon={button.icon}
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
/>
))}
</div>
</Container>
);

Comment on lines 76 to 113
function SidebarButton(props: SidebarButtonProps) {
const { condition, icon, onClick, selected, title, tooltip, urlSuffix } =
props;
const handleOnClick = useCallback(() => {
if (!selected) {
onClick(urlSuffix);
}
}, [selected, onClick, urlSuffix]);

return (
<Container>
<Tooltip
content={tooltip}
isDisabled={!!title && !tooltip}
placement={"right"}
>
<IconContainer
className={`t--sidebar-${title || tooltip}`}
data-selected={selected}
data-testid={"t--sidebar-" + props.testId}
onClick={handleOnClick}
role="button"
>
<Icon name={icon} size="lg" />
{condition && (
<ConditionIcon
className={`t--sidebar-${condition}-condition-icon`}
data-testid={`t--sidebar-${condition}-condition-icon`}
name={ConditionConfig[condition].icon}
size="md"
/>
)}
</IconContainer>
</Tooltip>
{title ? <Text kind="body-s">{title}</Text> : null}
</Container>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add keyboard navigation support.

The button should be keyboard accessible. Consider these improvements:

  1. Add keyboard event handling
  2. Include proper ARIA attributes
 <IconContainer
   className={`t--sidebar-${title || tooltip}`}
   data-selected={selected}
   data-testid={"t--sidebar-" + props.testId}
   onClick={handleOnClick}
+  onKeyDown={(e) => e.key === 'Enter' && handleOnClick()}
+  tabIndex={0}
   role="button"
+  aria-pressed={selected}
+  aria-label={tooltip || title}
 >
📝 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
function SidebarButton(props: SidebarButtonProps) {
const { condition, icon, onClick, selected, title, tooltip, urlSuffix } =
props;
const handleOnClick = useCallback(() => {
if (!selected) {
onClick(urlSuffix);
}
}, [selected, onClick, urlSuffix]);
return (
<Container>
<Tooltip
content={tooltip}
isDisabled={!!title && !tooltip}
placement={"right"}
>
<IconContainer
className={`t--sidebar-${title || tooltip}`}
data-selected={selected}
data-testid={"t--sidebar-" + props.testId}
onClick={handleOnClick}
role="button"
>
<Icon name={icon} size="lg" />
{condition && (
<ConditionIcon
className={`t--sidebar-${condition}-condition-icon`}
data-testid={`t--sidebar-${condition}-condition-icon`}
name={ConditionConfig[condition].icon}
size="md"
/>
)}
</IconContainer>
</Tooltip>
{title ? <Text kind="body-s">{title}</Text> : null}
</Container>
);
}
function SidebarButton(props: SidebarButtonProps) {
const { condition, icon, onClick, selected, title, tooltip, urlSuffix } =
props;
const handleOnClick = useCallback(() => {
if (!selected) {
onClick(urlSuffix);
}
}, [selected, onClick, urlSuffix]);
return (
<Container>
<Tooltip
content={tooltip}
isDisabled={!!title && !tooltip}
placement={"right"}
>
<IconContainer
className={`t--sidebar-${title || tooltip}`}
data-selected={selected}
data-testid={"t--sidebar-" + props.testId}
onClick={handleOnClick}
onKeyDown={(e) => e.key === 'Enter' && handleOnClick()}
tabIndex={0}
role="button"
aria-pressed={selected}
aria-label={tooltip || title}
>
<Icon name={icon} size="lg" />
{condition && (
<ConditionIcon
className={`t--sidebar-${condition}-condition-icon`}
data-testid={`t--sidebar-${condition}-condition-icon`}
name={ConditionConfig[condition].icon}
size="md"
/>
)}
</IconContainer>
</Tooltip>
{title ? <Text kind="body-s">{title}</Text> : null}
</Container>
);
}

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: 0

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

12-16: Consider making the template dimensions configurable.

The fixed height and width might not represent all usage scenarios. Consider making these configurable through story parameters.

-  <Flex background="var(--ads-v2-color-bg)" h="400px" width="100px">
+  <Flex 
+    background="var(--ads-v2-color-bg)" 
+    h={args.containerHeight || "400px"} 
+    width={args.containerWidth || "100px"}
+  >

18-41: Maintain consistent testId naming convention.

The testIds use mixed naming conventions:

  • "Editor" (PascalCase)
  • "warning-button" (kebab-case)
  • "settings" (lowercase)

Consider standardizing to kebab-case for all testIds.

-    testId: "Editor",
+    testId: "editor",

43-66: Consider using Storybook actions instead of console.log.

Replace console.log with Storybook's actions for better debugging and documentation.

+import { action } from '@storybook/addon-actions';

-  onClick: (urlSuffix: string) => console.log("Clicked:", urlSuffix),
+  onClick: action("sidebar-click"),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e55989 and 3d17ca1.

📒 Files selected for processing (3)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.stories.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1 hunks)
  • app/client/src/IDE/Components/Sidebar/index.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/IDE/Components/Sidebar/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • 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 (1)
app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.stories.tsx (1)

1-10: LGTM! Clean imports and proper Storybook configuration.

@@ -19,19 +18,19 @@ const Container = styled(Flex)`
// the button should be selected and only handle calling the onClick
export interface IDESidebarButton
extends Omit<SidebarButtonProps, "onClick" | "selected"> {
state: EditorState;
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we move the styled component to a separate styles file? Also a separate file for types?

Copy link
Contributor

Choose a reason for hiding this comment

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

same for the sidebar button component

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

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: 2

🧹 Nitpick comments (4)
app/client/packages/design-system/ads/src/Templates/Sidebar/styles.ts (1)

5-5: Consider making the width configurable.

The fixed width of 50px might not accommodate all use cases. Consider making it configurable through props or CSS variables for better flexibility.

-  width: 50px;
+  width: var(--ads-v2-sidebar-width, 50px);
app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/constants.ts (1)

11-13: Create GitHub issues for the pending conditions.

The TODO comments indicate missing implementations for Error and Success conditions. Consider creating GitHub issues to track these enhancements.

Would you like me to help create GitHub issues for implementing the Error and Success conditions?

app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (2)

24-28: Optimize the click handler dependency array.

The useCallback dependency array includes selected which causes unnecessary re-renders when selection changes.

  const handleOnClick = useCallback(() => {
    if (!selected) {
      onClick(urlSuffix);
    }
-  }, [selected, onClick, urlSuffix]);
+  }, [onClick, urlSuffix]);

32-36: Add aria-label to Tooltip component.

Enhance accessibility by providing an aria-label for the tooltip.

  <Tooltip
    content={tooltip}
    isDisabled={!!title && !tooltip}
    placement={"right"}
+   aria-label={`${title || tooltip} button tooltip`}
  >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d17ca1 and fe484aa.

📒 Files selected for processing (5)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (2 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/constants.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/styles.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/styles.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • 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 (2)
app/client/packages/design-system/ads/src/Templates/Sidebar/styles.ts (1)

6-11: LGTM! Good use of design system variables.

Proper usage of design system variables (--ads-v2-*) for colors and borders ensures consistency across the application.

app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (1)

37-43: Add keyboard navigation support.

The button should be keyboard accessible.

Comment on lines +7 to +10
[Condition.Warn]: {
icon: "warning",
color: "#ffe283",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use design system color tokens instead of hardcoded values.

Replace the hardcoded color value with the appropriate design system token for consistency.

  [Condition.Warn]: {
    icon: "warning",
-   color: "#ffe283",
+   color: "var(--ads-v2-color-warning)",
  },
📝 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
[Condition.Warn]: {
icon: "warning",
color: "#ffe283",
},
[Condition.Warn]: {
icon: "warning",
color: "var(--ads-v2-color-warning)",
},

Comment on lines +15 to +37
export const IconContainer = styled.div`
padding: 2px;
border-radius: 3px;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
position: relative;

&[data-selected="false"] {
background-color: var(--ads-v2-color-bg);

&:hover {
background-color: var(--ads-v2-color-bg-subtle, #f1f5f9);
}
}

&[data-selected="true"] {
background-color: var(--ads-v2-color-bg-muted);
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add focus styles for keyboard navigation.

The IconContainer needs focus styles for better keyboard accessibility.

export const IconContainer = styled.div`
  /* existing styles */

+ &:focus {
+   outline: 2px solid var(--ads-v2-color-border-focus);
+   outline-offset: 2px;
+ }

+ &:focus:not(:focus-visible) {
+   outline: none;
+ }
`;
📝 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
export const IconContainer = styled.div`
padding: 2px;
border-radius: 3px;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
position: relative;
&[data-selected="false"] {
background-color: var(--ads-v2-color-bg);
&:hover {
background-color: var(--ads-v2-color-bg-subtle, #f1f5f9);
}
}
&[data-selected="true"] {
background-color: var(--ads-v2-color-bg-muted);
}
`;
export const IconContainer = styled.div`
padding: 2px;
border-radius: 3px;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
position: relative;
&[data-selected="false"] {
background-color: var(--ads-v2-color-bg);
&:hover {
background-color: var(--ads-v2-color-bg-subtle, #f1f5f9);
}
}
&[data-selected="true"] {
background-color: var(--ads-v2-color-bg-muted);
}
&:focus {
outline: 2px solid var(--ads-v2-color-border-focus);
outline-offset: 2px;
}
&:focus:not(:focus-visible) {
outline: none;
}
`;

ankitakinger
ankitakinger previously approved these changes Jan 14, 2025
@hetunandu hetunandu enabled auto-merge (squash) January 14, 2025 10:32
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: 0

♻️ Duplicate comments (1)
app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1)

10-41: 🛠️ Refactor suggestion

Improve accessibility and reduce code duplication.

  1. Add proper ARIA attributes for navigation
  2. Extract duplicated button mapping logic
+const renderButtons = (buttons: IDESidebarButton[], onClick: IDESidebarProps['onClick'], editorState: string) => (
+  buttons.map((button) => (
+    <SidebarButton
+      key={button.state}
+      {...button}
+      onClick={onClick}
+      selected={editorState === button.state}
+    />
+  ))
+);

 return (
-  <Styled.Container className="t--sidebar" id={props.id}>
+  <Styled.Container 
+    className="t--sidebar" 
+    id={props.id} 
+    role="navigation" 
+    aria-label="IDE Navigation"
+  >
     <div>
-      {topButtons.map((button) => (
-        <SidebarButton
-          condition={button.condition}
-          icon={button.icon}
-          key={button.state}
-          onClick={onClick}
-          selected={editorState === button.state}
-          testId={button.testId}
-          title={button.title}
-          tooltip={button.tooltip}
-          urlSuffix={button.urlSuffix}
-        />
-      ))}
+      {renderButtons(topButtons, onClick, editorState)}
     </div>
     <div>
-      {bottomButtons.map((button) => (
-        <SidebarButton
-          condition={button.condition}
-          icon={button.icon}
-          key={button.state}
-          onClick={onClick}
-          selected={editorState === button.state}
-          testId={button.testId}
-          title={button.title}
-          tooltip={button.tooltip}
-          urlSuffix={button.urlSuffix}
-        />
-      ))}
+      {renderButtons(bottomButtons, onClick, editorState)}
     </div>
   </Styled.Container>
 );
🧹 Nitpick comments (3)
app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.types.ts (1)

3-12: Enhance type safety and accessibility support in SidebarButtonProps.

  1. The icon prop should have a more specific type than string to ensure valid icons are passed.
  2. Consider adding accessibility-related props.
 export interface SidebarButtonProps {
   title?: string;
   testId: string;
   selected: boolean;
-  icon: string;
+  icon: IconName; // Create a union type of valid icon names
   onClick: (urlSuffix: string) => void;
   urlSuffix: string;
   tooltip?: string;
   condition?: Condition;
+  ariaLabel?: string;
 }
app/client/packages/design-system/ads/src/Templates/Sidebar/types.ts (1)

5-9: Consider type safety for state values.

The state property should be constrained to valid editor states to prevent runtime errors.

+type EditorState = 'edit' | 'preview' | 'deploy'; // Add valid states

 export interface IDESidebarButton
   extends Omit<SidebarButtonProps, "onClick" | "selected"> {
-  state: string;
+  state: EditorState;
   urlSuffix: string;
 }
app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1)

6-8: Add memoization for performance optimization.

Consider memoizing the component to prevent unnecessary re-renders.

-export function IDESidebar(props: IDESidebarProps) {
+export const IDESidebar = React.memo(function IDESidebar(props: IDESidebarProps) {
   const { bottomButtons, editorState, onClick, topButtons } = props;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe484aa and 1db59c2.

📒 Files selected for processing (8)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.stories.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.test.tsx (4 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.types.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/index.ts (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx (1 hunks)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/index.ts
  • app/client/packages/design-system/ads/src/Templates/Sidebar/index.tsx
  • app/client/packages/design-system/ads/src/Templates/Sidebar/Sidebar.stories.tsx
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.tsx
  • app/client/packages/design-system/ads/src/Templates/Sidebar/SidebarButton/SidebarButton.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests

@hetunandu hetunandu merged commit 357664f into release Jan 14, 2025
52 of 53 checks passed
@hetunandu hetunandu deleted the chore/ads/move-sidebar-to-ads branch January 14, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Navigation Issues/feature requests related to IDE navigation, and context switching 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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Move Sidebar into ADS
2 participants