Skip to content

fixed org delete + added chat menu to header - #235

Merged
carhartlewis merged 3 commits into
mainfrom
lewis/ui-fixes
Mar 31, 2025
Merged

carhartlewis merged 3 commits into
mainfrom
lewis/ui-fixes

Conversation

@carhartlewis

@carhartlewis carhartlewis commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced an assistant chat button on desktop screens, now accessible from the header for quick support.
  • Style

    • Refined spacing in dashboard and header layouts for improved visual alignment.
    • Updated the sidebar logo size to ensure consistent branding.
  • Bug Fixes

    • Enhanced content refresh after organization removal, ensuring up-to-date information is displayed.

- Introduced the `AssistantButton` component for AI interaction, utilizing responsive design with media queries.
- Integrated `AssistantButton` into the `Header` component, enhancing the user interface.
- Refactored the `Header` component for improved readability and structure.
- Maintained existing functionality while optimizing layout and component usage.
- Added revalidation of the organization path after successful deletion in the `deleteOrganizationAction`.
- Updated layout styles in the dashboard for improved spacing and responsiveness.
- Refactored `Header` component to maintain structure and readability.
- Adjusted `SidebarLogo` component to ensure consistent styling and added width/height attributes for the logo.
@vercel

vercel Bot commented Mar 31, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 11:33pm
comp-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 31, 2025 11:33pm

@coderabbitai

coderabbitai Bot commented Mar 31, 2025 •

Copy link
Copy Markdown

Walkthrough

This pull request introduces modifications across several components. It adds a call to revalidatePath in the organization deletion action for cache updates. In addition, layout and styling changes have been applied to improve margins, paddings, and the display of the sidebar logo. A new AssistantButton component has been created for desktop views and integrated into the header, replacing the previous notification center import.

Changes

Files Change Summary
apps/app/src/actions/.../delete-organization-action.ts Added a call to revalidatePath after organization deletion; reformatted the DeleteOrganizationResult type for consistency.
apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx
apps/app/src/components/sidebar-logo.tsx
Updated layout styling: replaced p-4 with responsive margin and padding classes in layout; modified SidebarLogo to use explicit icon dimensions and removed conditional class logic based on isCollapsed.
apps/app/src/components/ai/chat-button.tsx
apps/app/src/components/header.tsx
Introduced new AssistantButton component which renders only on desktop (≥768px). Integrated the component within the header and removed the outdated NotificationCenter import.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as DeleteOrganizationAction
    participant R as revalidatePath

    U->>A: Trigger organization deletion
    A->>A: Execute deletion logic
    A->>R: Call revalidatePath after success
    R-->>A: Path revalidated
    A-->>U: Return deletion result
Loading
sequenceDiagram
    participant U as User
    participant AB as AssistantButton
    participant QS as QueryState

    U->>AB: Click Assistant Button
    AB->>QS: Call setAssistantOpen(true)
    QS-->>AB: Assistant state set (open)
    AB-->>U: Render Assistant UI (if applicable)
Loading

Possibly related PRs

  • Organization Switcher #165: Introduces revalidatePath after organization changes, directly relating to the deletion action update.
  • SSR Settings + Loading UI #147: Applies a similar revalidatePath approach in action methods for API key operations, aligning with the modifications seen here.

Poem

I hop through lines of code with glee,
Adjusting paths and styles carefully.
A button appears when screens are wide,
Revalidating routes with a joyful stride.
I'm a rabbit dancing through the change spree!
🐇💻

✨ 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (5)
apps/app/src/components/ai/chat-button.tsx (2)

23-23: Consider simplifying the class name string

The class string is quite long with many utility classes. Consider extracting these into a constant or using a component variant for better maintainability.


26-29: Add aria-label for improved accessibility

For better accessibility, consider adding an aria-label to better describe the button's function.

  <Button
    variant="outline"
    className="relative min-w-[250px] w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 lg:w-64 border-0 p-0 hover:bg-transparent font-normal no-drag"
+   aria-label="Open AI assistant chat"
    onClick={() => setAssistantOpen(true)}
  >
apps/app/src/components/sidebar-logo.tsx (1)

8-9: Unused isCollapsed prop

The isCollapsed prop is still required in the interface and accepted in the component parameters, but it's no longer used in the component rendering logic.

If this prop is truly no longer needed for this component, consider removing it:

interface SidebarLogoProps {
-  isCollapsed: boolean;
  organizationId: string;
}

-export function SidebarLogo({ isCollapsed, organizationId }: SidebarLogoProps) {
+export function SidebarLogo({ organizationId }: SidebarLogoProps) {

Also applies to: 12-29

apps/app/src/actions/organization/delete-organization-action.ts (1)

8-8: Unused import

The revalidateTag import is not used in this file.

-import { revalidatePath, revalidateTag } from "next/cache";
+import { revalidatePath } from "next/cache";
apps/app/src/components/header.tsx (1)

54-54: Remove commented-out code.

Instead of leaving commented-out code in the codebase, it's better to remove it entirely. If the NotificationCenter component is no longer needed, the commented-out reference should be removed for cleaner code maintenance.

-        {/* <NotificationCenter /> */}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c352974 and a979935.

📒 Files selected for processing (5)
  • apps/app/src/actions/organization/delete-organization-action.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx (1 hunks)
  • apps/app/src/components/ai/chat-button.tsx (1 hunks)
  • apps/app/src/components/header.tsx (1 hunks)
  • apps/app/src/components/sidebar-logo.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/app/src/components/header.tsx (3)
apps/app/src/components/mobile-menu.tsx (1)
  • MobileMenu (9-39)
apps/app/src/components/ai/chat-button.tsx (1)
  • AssistantButton (8-32)
apps/app/src/components/user-menu.tsx (1)
  • UserMenu (15-94)
🔇 Additional comments (6)
apps/app/src/components/ai/chat-button.tsx (1)

8-32: Well-implemented AssistantButton component

The component is well-structured with:

  • Responsive behavior that only renders on desktop (min-width: 768px)
  • Good use of URL state management via the nuqs library
  • Keyboard shortcut display for improved usability
apps/app/src/components/sidebar-logo.tsx (1)

20-23: Fixed logo dimensions improve layout stability

Setting explicit width and height values for the logo is good practice as it helps prevent layout shifts during page loading.

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx (1)

43-43:

Details

❓ Verification inconclusive

Layout spacing changes may affect content alignment

The changes from general padding (p-4) to specific margins and only bottom padding (mx-4 md:ml-[95px] md:mr-10 pb-8) will affect how the content aligns with other elements.

Some considerations:

  • The removal of top padding might affect spacing between header and content
  • The specific left margin value of 95px seems unusual in a Tailwind context which typically uses scale values

Can you verify that these specific margin values correctly align with the intended design, especially with the new AssistantButton in the header?


🏁 Script executed:

#!/bin/bash
# Check for any margin/padding consistency in similar layout components
rg "className=\"[^\"]*m[lrtbxy]-\[" --type tsx

Length of output: 74


Below is an updated verification step to help gather the necessary data before finalizing the review:


Action Required: Re-run Updated Margin & AssistantButton Verifications

It looks like the previous shell script failed due to unrecognized TSX file types. To further verify that the custom margin values (specifically, md:ml-[95px]) align with the intended design—especially with the new AssistantButton in the header—please run the following updated shell scripts:

#!/bin/bash
# Add TSX file type for rg and search for margin-related class names in all .tsx files
rg --type-add 'tsx:*.tsx' -g '*.tsx' 'className="[^"]*m[lrtbxy]-\['

# Search for references to the AssistantButton to understand its usage context
rg -g '*.tsx' 'AssistantButton'

These commands will help determine if:

  • Similar layouts are using comparable margin configurations,
  • The custom left margin of 95px is consistent across the codebase,
  • And how the AssistantButton is integrated with the surrounding layout.

Once you’ve verified the outputs, please review whether any adjustments are needed to ensure layout consistency.

apps/app/src/actions/organization/delete-organization-action.ts (1)

43-43: Good addition of cache revalidation

Adding revalidatePath after the organization deletion is important to ensure the UI reflects the current state and doesn't show stale data.

apps/app/src/components/header.tsx (2)

13-13: Import added correctly for the new AssistantButton component.

The import statement follows proper conventions and correctly references the component from its location in the project structure.


33-33: AssistantButton integration looks good.

The AssistantButton component is properly placed between the MobileMenu and the right-aligned elements. Based on the implementation in chat-button.tsx, this component will only render on desktop views (min-width: 768px), which aligns with the responsive design of the header.

Comment on lines 10 to +53
type DeleteOrganizationResult = {
success: boolean;
redirect?: string;
success: boolean;
redirect?: string;
};

export const deleteOrganizationAction = authActionClient
.schema(deleteOrganizationSchema)
.metadata({
name: "delete-organization",
track: {
event: "delete-organization",
channel: "server",
},
})
.action(async ({ parsedInput, ctx }): Promise<DeleteOrganizationResult> => {
const { id } = parsedInput;
const { user } = ctx;

if (!id) {
throw new Error("Invalid user input");
}

if (!user.organizationId) {
throw new Error("Invalid organization input");
}

try {
await db.$transaction(async () => {
await db.organization.delete({
where: { id: user.organizationId },
});
});

return {
success: true,
};
} catch (error) {
return {
success: false,
};
}
});
.schema(deleteOrganizationSchema)
.metadata({
name: "delete-organization",
track: {
event: "delete-organization",
channel: "server",
},
})
.action(async ({ parsedInput, ctx }): Promise<DeleteOrganizationResult> => {
const { id } = parsedInput;
const { user } = ctx;

if (!id) {
throw new Error("Invalid user input");
}

if (!user.organizationId) {
throw new Error("Invalid organization input");
}

try {
await db.$transaction(async () => {
await db.organization.delete({
where: { id: user.organizationId },
});
});

revalidatePath(`/${user.organizationId}`);

return {
success: true,
};
} catch (error) {
return {
success: false,
};
}
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Inconsistent indentation throughout the file

The file uses tabs for indentation while most modern JavaScript/TypeScript projects use spaces. This appears inconsistent with the other files in the codebase.

Consider standardizing on either tabs or spaces throughout the project for consistent code style.

Let's check the project's indentation style:


🏁 Script executed:

#!/bin/bash
# Check for tab indentation in TypeScript files
rg "^\t" --type ts --count | sort -nr | head -5
# Check for space indentation in TypeScript files
rg "^  " --type ts --count | sort -nr | head -5

Length of output: 475


Indentation Standardization Required

The repository-wide analysis confirms that we have mixed indentation styles. The file apps/app/src/actions/organization/delete-organization-action.ts is using tabs for indentation, while several other TypeScript files (e.g., those found in packages/utils/) use spaces. To avoid potential merge conflicts and improve code consistency, standardizing on a single indentation style (preferably spaces, as commonly adopted in modern JavaScript/TypeScript projects) is recommended.

  • File under review: Uses tabs.
  • Other examples: Files like packages/utils/src/index.ts, packages/utils/src/format.ts, etc., use spaces.

Please update the file to align with the predominant project style and consider enforcing this with an automated formatter.

This branch was successfully deployed

2 active deployments
Preview – app — a979935c Deployed Mar 31, 2025 by vercel[bot]
Preview – comp-portal — a979935c Deployed Mar 31, 2025 by vercel[bot]
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