Skip to content

[Dashboard] Add ecosystem logo upload functionality #7113

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

Merged

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented May 21, 2025


PR-Codex overview

This PR enhances the EcosystemHeader component by adding image upload functionality and fetching team details to ensure valid team IDs for updates. It also improves error handling and user notifications during the image upload process.

Detailed summary

  • Added fetching of team details using getTeamBySlug.
  • Redirects if the team is not found.
  • Introduced state management for image upload (isDialogOpen, selectedFile).
  • Implemented image upload logic with validation for file types.
  • Added a dialog for updating the ecosystem logo with a preview.
  • Integrated success and error notifications using toast.
  • Updated EcosystemHeader props to include authToken and teamId.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Added the ability to upload and update the ecosystem logo image directly from the dashboard.
    • Users receive feedback via notifications for successful uploads, errors, and validation issues.
    • The ecosystem header now displays an overlay button to trigger the image upload dialog.
  • Bug Fixes

    • Improved handling when a team is not found by redirecting users appropriately.

Copy link

vercel bot commented May 21, 2025

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2025 5:57pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) May 21, 2025 5:57pm
login ⬜️ Skipped (Inspect) May 21, 2025 5:57pm
thirdweb_playground ⬜️ Skipped (Inspect) May 21, 2025 5:57pm
wallet-ui ⬜️ Skipped (Inspect) May 21, 2025 5:57pm

@vercel vercel bot temporarily deployed to Preview – wallet-ui May 21, 2025 17:49 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 21, 2025 17:49 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 21, 2025 17:49 Inactive
Copy link

changeset-bot bot commented May 21, 2025

⚠️ No Changeset found

Latest commit: 4165f4f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel vercel bot temporarily deployed to Preview – login May 21, 2025 17:49 Inactive
Copy link
Contributor

coderabbitai bot commented May 21, 2025

Walkthrough

The changes introduce an image upload feature for the ecosystem logo within the dashboard's ecosystem header component. The header now requires authentication and team ID props, manages upload dialogs, validates file types, performs uploads, updates the ecosystem, and provides user feedback. The layout component fetches team details and redirects if not found.

Changes

File(s) Change Summary
.../EcosystemSlugLayout.tsx Updated to fetch team details by slug, redirect if not found, and pass authToken and team.id as props to the header component.
.../ecosystem-header.client.tsx Added image upload feature for the ecosystem logo, including dialog state, file validation, upload logic, toast notifications, and UI updates. Extended EcosystemHeader props to require authToken and teamId.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EcosystemHeader
    participant StorageUploadHook
    participant UpdateEcosystemHook
    participant Toast
    participant Page

    User->>EcosystemHeader: Clicks pencil icon on image
    EcosystemHeader->>User: Opens upload dialog
    User->>EcosystemHeader: Selects image file and clicks upload
    EcosystemHeader->>EcosystemHeader: Validate file type
    alt Valid file
        EcosystemHeader->>StorageUploadHook: Upload image
        StorageUploadHook-->>EcosystemHeader: Return image URL
        EcosystemHeader->>UpdateEcosystemHook: Update ecosystem with new image
        UpdateEcosystemHook-->>EcosystemHeader: Success
        EcosystemHeader->>Toast: Show success notification
        EcosystemHeader->>Page: Refresh page
    else Invalid file
        EcosystemHeader->>Toast: Show error notification
    end
Loading
sequenceDiagram
    participant EcosystemSlugLayout
    participant Auth
    participant EcosystemData
    participant TeamData
    participant Router
    participant EcosystemHeader

    EcosystemSlugLayout->>Auth: Retrieve auth token
    EcosystemSlugLayout->>EcosystemData: Fetch ecosystem data
    EcosystemSlugLayout->>TeamData: Fetch team by slug
    alt Team found
        EcosystemSlugLayout->>EcosystemHeader: Pass teamId and authToken as props
    else Team not found
        EcosystemSlugLayout->>Router: Redirect to ecosystem layout path
    end
Loading

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label May 21, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codecov bot commented May 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.60%. Comparing base (a1c432c) to head (4165f4f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7113   +/-   ##
=======================================
  Coverage   55.60%   55.60%           
=======================================
  Files         901      901           
  Lines       58121    58121           
  Branches     4067     4067           
=======================================
  Hits        32320    32320           
  Misses      25696    25696           
  Partials      105      105           
Flag Coverage Δ
packages 55.60% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joaquim-verges joaquim-verges marked this pull request as ready for review May 21, 2025 17:53
@joaquim-verges joaquim-verges requested review from a team as code owners May 21, 2025 17:53
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 56.57 KB (0%) 1.2 s (0%) 109 ms (+201.43% 🔺) 1.3 s
thirdweb (cjs) 309.52 KB (0%) 6.2 s (0%) 333 ms (+15.37% 🔺) 6.6 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 40 ms (+1774.65% 🔺) 154 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 18 ms (+1279.8% 🔺) 29 ms
thirdweb/react (minimal + tree-shaking) 19.5 KB (0%) 390 ms (0%) 69 ms (+1023.58% 🔺) 459 ms

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 (2)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx (2)

2-2: Consider removing the eslint-disable comment.

Adding a blanket eslint-disable at the file level is generally not recommended. It's better to address specific issues or use more targeted disables.

-/* eslint-disable */

200-209: Improve error handling specificity.

The catch block logs the error but gives a generic message to the user. Consider extracting and displaying more specific error information when possible.

try {
  const [uri] = await storageUpload.mutateAsync([selectedFile]);
  await updateEcosystem({
    ...ecosystem,
    imageUrl: uri,
  });
} catch (err) {
  console.error(err);
-  toast.error("Failed to upload image");
+  const errorMessage = err instanceof Error ? err.message : "Failed to upload image";
+  toast.error(`Upload failed: ${errorMessage}`);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a1c432c and 4165f4f.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx (3 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx (1)
apps/dashboard/src/@/api/team.ts (1)
  • getTeamBySlug (11-30)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx (3)
apps/dashboard/src/@/lib/DashboardRouter.tsx (1)
  • useDashboardRouter (22-45)
apps/dashboard/src/@/components/ui/dialog.tsx (7)
  • Dialog (130-130)
  • DialogTrigger (134-134)
  • DialogContent (135-135)
  • DialogHeader (136-136)
  • DialogTitle (138-138)
  • DialogFooter (137-137)
  • DialogClose (133-133)
apps/dashboard/src/@/components/ui/button.tsx (1)
  • Button (67-67)
🔇 Additional comments (9)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx (3)

1-1: Good addition of the required import.

The import of getTeamBySlug is correctly added to support the new functionality for fetching team details.


29-35: Well-implemented team fetch with proper error handling.

The code correctly fetches team details and includes appropriate redirection if the team is not found. The comment also explains the purpose clearly.


46-47: Proper prop passing for authentication.

The authToken and teamId props are correctly passed to the EcosystemHeader component, enabling the logo upload functionality.

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx (6)

8-16: Well-organized import structure for Dialog components.

The Dialog components are properly imported and structured for building the upload modal interface.


25-45: Complete set of required imports for the new functionality.

All necessary components and hooks are imported to support the image upload functionality, including UI components, state management, and API integrations.


134-135: Added required props for authenticated uploads.

The new props authToken and teamId are correctly added to the component interface, enabling authenticated ecosystem updates.


158-161: Well-structured state management for the upload dialog.

The state variables for dialog visibility and file selection are correctly defined and organized with a helpful comment section.


162-183: Well-implemented hooks with proper error handling.

The upload and update hooks are well configured with appropriate success and error callbacks. The toast notifications provide good user feedback.


236-290: Well-structured dialog implementation with good UX considerations.

The dialog implementation is comprehensive with appropriate triggers, content organization, and action buttons. The loading state is properly handled with a spinner during upload.

Comment on lines +187 to +210
async function handleUpload() {
if (!selectedFile) {
toast.error("Please select an image to upload");
return;
}

// Validate file type
const validTypes = ["image/png", "image/jpeg", "image/webp"];
if (!validTypes.includes(selectedFile.type)) {
toast.error("Only PNG, JPG or WEBP images are allowed");
return;
}

try {
const [uri] = await storageUpload.mutateAsync([selectedFile]);
await updateEcosystem({
...ecosystem,
imageUrl: uri,
});
} catch (err) {
console.error(err);
toast.error("Failed to upload image");
}
}
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

Consider adding file size validation.

The file type validation is good, but there's no check for file size limits, which could lead to issues with large files.

function handleUpload() {
  if (!selectedFile) {
    toast.error("Please select an image to upload");
    return;
  }

  // Validate file type
  const validTypes = ["image/png", "image/jpeg", "image/webp"];
  if (!validTypes.includes(selectedFile.type)) {
    toast.error("Only PNG, JPG or WEBP images are allowed");
    return;
  }

+ // Validate file size (e.g., max 5MB)
+ const maxSizeInBytes = 5 * 1024 * 1024; // 5MB
+ if (selectedFile.size > maxSizeInBytes) {
+   toast.error("Image size should be less than 5MB");
+   return;
+ }

  try {
    // rest of the function...
📝 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
async function handleUpload() {
if (!selectedFile) {
toast.error("Please select an image to upload");
return;
}
// Validate file type
const validTypes = ["image/png", "image/jpeg", "image/webp"];
if (!validTypes.includes(selectedFile.type)) {
toast.error("Only PNG, JPG or WEBP images are allowed");
return;
}
try {
const [uri] = await storageUpload.mutateAsync([selectedFile]);
await updateEcosystem({
...ecosystem,
imageUrl: uri,
});
} catch (err) {
console.error(err);
toast.error("Failed to upload image");
}
}
async function handleUpload() {
if (!selectedFile) {
toast.error("Please select an image to upload");
return;
}
// Validate file type
const validTypes = ["image/png", "image/jpeg", "image/webp"];
if (!validTypes.includes(selectedFile.type)) {
toast.error("Only PNG, JPG or WEBP images are allowed");
return;
}
// Validate file size (e.g., max 5MB)
const maxSizeInBytes = 5 * 1024 * 1024; // 5MB
if (selectedFile.size > maxSizeInBytes) {
toast.error("Image size should be less than 5MB");
return;
}
try {
const [uri] = await storageUpload.mutateAsync([selectedFile]);
await updateEcosystem({
...ecosystem,
imageUrl: uri,
});
} catch (err) {
console.error(err);
toast.error("Failed to upload image");
}
}
🤖 Prompt for AI Agents
In
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx
around lines 187 to 210, the handleUpload function lacks validation for the file
size of the selected image. Add a check after the file type validation to ensure
the selectedFile size does not exceed a defined limit (e.g., 5MB). If the file
is too large, show an error toast message and return early to prevent uploading
oversized files.

@joaquim-verges joaquim-verges merged commit 72cc27a into main May 21, 2025
27 checks passed
@joaquim-verges joaquim-verges deleted the _Dashboard_Add_ecosystem_logo_upload_functionality branch May 21, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant