Skip to content

feat: sender component complements upload logic#118

Closed
SonyLeo wants to merge 3 commits intodevelopfrom
feat/sender-file-upload
Closed

feat: sender component complements upload logic#118
SonyLeo wants to merge 3 commits intodevelopfrom
feat/sender-file-upload

Conversation

@SonyLeo
Copy link
Copy Markdown
Collaborator

@SonyLeo SonyLeo commented Jun 18, 2025

sender 组件附件按钮增加上传逻辑并更新案例代码

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a file upload popup to the sender component, allowing users to choose between local file upload and online file selection.
    • Introduced a customizable tooltip for the upload button.
    • New events are emitted when files are selected or an online upload is triggered.
    • Added a demo component showcasing file upload with event logging and file details display.
  • Documentation

    • Expanded and clarified documentation for the sender component's file upload features, including new props, events, and usage examples.
  • Style

    • Added new styles for the upload popup and overlay to enhance the user interface.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 18, 2025

Walkthrough

A file upload popup feature is introduced to the sender component, including UI, tooltip customization, and new events for local and online file uploads. Supporting documentation, type declarations, and styles are updated. A new demo component showcases file upload, and the documentation is expanded to describe the new functionality and events.

Changes

File(s) Change Summary
docs/demos/sender/FileUpload.vue New Vue 3 demo component for file upload using tr-sender, with reactive state, event logging, and UI.
docs/src/components/sender.md Expanded documentation: describes file upload popup, new events, new prop, and usage demo.
packages/components/src/sender/components/ActionButtons.vue Adds uploadTooltip prop, emits show-upload-popup event, and handles upload button click for popup display.
packages/components/src/sender/index.less Adds CSS for upload popup, overlay, and related UI elements.
packages/components/src/sender/index.type.ts Adds uploadTooltip prop and new event signatures to type declarations for sender and action buttons.
packages/components/src/sender/index.vue Integrates upload popup logic, file dialog handling, new props, new events, and passes tooltip to child button.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SenderComponent
    participant ActionButtons
    participant FileDialog

    User->>ActionButtons: Click Upload Button
    ActionButtons->>SenderComponent: Emit show-upload-popup(true)
    SenderComponent->>SenderComponent: Show Upload Popup

    User->>SenderComponent: Click "Local Upload"
    SenderComponent->>FileDialog: Open file dialog
    FileDialog-->>SenderComponent: Return selected files
    SenderComponent->>SenderComponent: Close Upload Popup
    SenderComponent->>SenderComponent: Emit files-selected(files)

    User->>SenderComponent: Click "Online File"
    SenderComponent->>SenderComponent: Close Upload Popup
    SenderComponent->>SenderComponent: Emit upload-online()
Loading

Poem

A popup appears with a gentle glow,
"Upload your files!"—now options show.
Local or online, you get to decide,
With tooltips and logs, nothing to hide.
Sender’s new tricks, so easy and neat—
Hopping ahead, these features can’t be beat!
🐇✨

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.

docs/demos/sender/FileUpload.vue

Oops! Something went wrong! :(

ESLint: 9.29.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:770:23)
at async /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:760:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:757:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/bin/eslint.js:175:19)

packages/components/src/sender/index.type.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:770:23)
at async /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:760:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:757:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/bin/eslint.js:175:19)

packages/components/src/sender/index.vue

Oops! Something went wrong! :(

ESLint: 9.29.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:145:10
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:144:3)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:266:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:589:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/config/config-loader.js:770:23)
at async /node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:760:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/eslint/eslint.js:757:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/lib/cli.js:632:14)
at async main (/node_modules/.pnpm/eslint@9.29.0/node_modules/eslint/bin/eslint.js:175:19)


📜 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 3470015 and 4aa2594.

📒 Files selected for processing (4)
  • docs/demos/sender/FileUpload.vue (1 hunks)
  • docs/src/components/sender.md (3 hunks)
  • packages/components/src/sender/index.type.ts (3 hunks)
  • packages/components/src/sender/index.vue (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/components/src/sender/index.type.ts
  • docs/demos/sender/FileUpload.vue
  • docs/src/components/sender.md
  • packages/components/src/sender/index.vue
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/sender-file-upload

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.
    • 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 auto-generate unit tests to generate unit tests for 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.

@SonyLeo SonyLeo force-pushed the feat/sender-file-upload branch from e130888 to 3470015 Compare June 18, 2025 01:31
@SonyLeo SonyLeo marked this pull request as ready for review June 18, 2025 01:32
Copy link
Copy Markdown

@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 (10)
packages/components/src/sender/index.less (1)

824-833: Nit: make overlay non-interactive if it’s only a backdrop

If you intentionally block scrolling but not clicks, add:

.pointer-events-none();

Otherwise ignore.

packages/components/src/sender/components/ActionButtons.vue (1)

84-86: uploadButtonRef is declared but never used

The local ref isn’t referenced elsewhere and will trigger an unused-var lint error.

-// 文件上传按钮引用
-const uploadButtonRef = ref<HTMLElement | null>(null)
docs/demos/sender/FileUpload.vue (2)

194-205: Dead CSS selector

.event-type.local is never applied – the code uses 'files' and 'online' only. Remove or rename:

-.event-type.local {
-  color: #1890ff;
-}

(or push a 'local' log entry if planned).


48-66: Minor: slice once instead of twice

You already converted the FileList to an array – reuse it.

-    selectedFiles.value = Array.from(files)
+    selectedFiles.value = [...files]

Purely cosmetic.

packages/components/src/sender/index.vue (4)

52-57: Expose accept & multiple as configurable props

accept: '*' and multiple: true are hard-coded. Different integrations (images-only, single PDF, etc.) will need flexibility.

-const { files, open: openFileDialog } = useFileDialog({
-  multiple: true,
-  accept: '*',
+const { files, open: openFileDialog } = useFileDialog({
+  multiple: props.uploadMultiple ?? true,
+  accept: props.uploadAccept ?? '*',
   reset: true,
 })

Add the corresponding optional props (uploadAccept, uploadMultiple) with sensible defaults.


65-86: Provide keyboard & accessibility support for the popup

The upload popup can only be closed with a mouse click. Consider:

  1. Listening for the Escape key to close.
  2. Adding role="dialog" and aria-modal="true" so screen-readers recognise it.
  3. Setting tabindex="-1" and moving focus into the popup on open, then restoring focus on close.

This improves a11y and aligns with WCAG.


48-50: Minor: co-locate reactive state with related handlers

showUploadPopup is defined far from its handlers, breaking locality.
Moving the declaration directly above the popup helpers (handleShowUploadPopup, handleUploadPopupLocalUpload, etc.) improves readability.


12-13: Tree-shaking friendly icon imports

If your bundler doesn’t tree-shake ESM properly, consider importing only the used icons:

-import { IconAssociate, IconUploadCloud, IconUploadLocal } from '@opentiny/tiny-robot-svgs'
+import IconAssociate from '@opentiny/tiny-robot-svgs/es/IconAssociate'
+import IconUploadCloud from '@opentiny/tiny-robot-svgs/es/IconUploadCloud'
+import IconUploadLocal from '@opentiny/tiny-robot-svgs/es/IconUploadLocal'

This can shave a few KB off the bundle.

docs/src/components/sender.md (2)

120-125: Unify terminology for file upload feature.

The section header is “文件上传” but the description starts with “附件上传功能”. For consistency, consider using “文件上传功能” in the description to match the header and other occurrences.


127-131: Use inline code formatting for default tooltip value.

In the sentence “默认为"上传文件"”, wrap the default value in backticks—e.g. 上传文件—to align with other prop descriptions and improve readability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf54e9 and 3470015.

⛔ Files ignored due to path filters (3)
  • packages/components/src/assets/svgs/folder-empty.svg is excluded by !**/*.svg
  • packages/svgs/src/assets/upload-cloud.svg is excluded by !**/*.svg
  • packages/svgs/src/assets/upload-local.svg is excluded by !**/*.svg
📒 Files selected for processing (6)
  • docs/demos/sender/FileUpload.vue (1 hunks)
  • docs/src/components/sender.md (3 hunks)
  • packages/components/src/sender/components/ActionButtons.vue (5 hunks)
  • packages/components/src/sender/index.less (3 hunks)
  • packages/components/src/sender/index.type.ts (3 hunks)
  • packages/components/src/sender/index.vue (8 hunks)
🔇 Additional comments (10)
packages/components/src/sender/index.type.ts (3)

31-33: Prop addition looks consistent

uploadTooltip follows the existing camel-case naming and is optional, mirroring the rest of SenderProps. No issues spotted.


62-64: Keep type definitions in sync with defaults

ActionButtonsProps.uploadTooltip is optional here but a non-undefined default is provided in ActionButtons.vue. ✅


83-85: Event contracts LGTM

Both new events are declared with correct payload signatures and match the implementation.

packages/components/src/sender/index.less (2)

110-116: Good call making .tiny-sender__input-row relatively positioned

Needed for the absolutely-positioned upload popup. ✔️


373-420: ```shell
#!/bin/bash

Search for the definition of --tr-z-index-dropdown to verify its default value

rg --context 3 "--tr-z-index-dropdown" -n


</details>
<details>
<summary>packages/components/src/sender/components/ActionButtons.vue (2)</summary>

`54-59`: **Default value aligns with type definition**

The default of `'上传文件'` matches the optional prop – all good.

---

`146-152`: **Consider emitting `false` to hide popup**

Only the “show” side of the state is emitted.  If the parent closes the popup internally it’s fine, otherwise you may want a counterpart:

```ts
emit('show-upload-popup', false)

from inside the parent or on backdrop click, to keep the API symmetrical.

packages/components/src/sender/index.vue (1)

577-590: Prop drilling looks good – ensure ActionButtons actually emits show-upload-popup

The new prop/emit wiring is clean, but double-check ActionButtons.vue emits show-upload-popup with a boolean payload that matches handleShowUploadPopup.

Also applies to: 629-642

docs/src/components/sender.md (2)

245-245: Props table addition looks good.

The new uploadTooltip prop is clearly documented with its type and default value in the props table.


279-280: Verify the files-selected event signature.

Confirm whether the component can emit null when no file is selected; if not, consider narrowing the callback type to FileList only.

Comment thread packages/components/src/sender/index.vue
@SonyLeo SonyLeo marked this pull request as draft July 10, 2025 02:39
@SonyLeo SonyLeo closed this Jul 14, 2025
@SonyLeo SonyLeo deleted the feat/sender-file-upload branch July 21, 2025 11:10
@SonyLeo SonyLeo restored the feat/sender-file-upload branch July 21, 2025 11:10
@SonyLeo SonyLeo deleted the feat/sender-file-upload branch July 21, 2025 11:13
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