Skip to content

Conversation

@khushi19099
Copy link
Contributor

@khushi19099 khushi19099 commented May 5, 2025

What's Changed

  • Added a visible Download button below shared file thumbnails in the Webex Activity component.
  • Updated the WebexActivity component to render a with accessible attributes (aria-label, role, etc.).
  • Introduced a downloadFile() utility inside the component to trigger native download behavior.
  • Minor CSS tweaks to display the button properly and align within attachment UI.

Issue Addressed
Previously, the shared screenshots or file thumbnails were not accompanied by any visible or accessible download option.

@coderabbitai
Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

This update introduces file sharing capabilities within the WebexActivity component, allowing users to view and download shared files attached to an activity. It adds supporting CSS styles for the file sharing UI, including interactive elements for file download actions. Additionally, the update removes the hint property from the display objects in both the microphone and speaker switch controls, and refactors the dropdown expansion logic for improved clarity.

Changes

File(s) Change Summary
src/components/WebexActivity/WebexActivity.jsx, src/components/WebexActivity/WebexActivity.scss Adds file sharing and download functionality to activities, including accessible UI and new CSS styles for file previews and actions.
src/adapters/MeetingsJSONAdapter/controls/SwitchMicrophoneControl.js,
src/adapters/MeetingsJSONAdapter/controls/SwitchSpeakerControl.js
Removes the hint property from the display objects in microphone and speaker switch controls.
src/components/inputs/Dropdown/Dropdown.jsx Refactors the toggleExpanded function to use explicit collapse() and expand(withKey) calls instead of direct state assignment.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebexActivity
    participant Browser

    User->>WebexActivity: View activity with attached files
    WebexActivity->>User: Render file previews and download buttons

    User->>WebexActivity: Click download button for a file
    WebexActivity->>Browser: Trigger file download via anchor element
    Browser-->>User: File is downloaded
Loading

Possibly related PRs

Suggested labels

released

Poem

A file to share, a button to press,
With previews and downloads—no more, no less!
Microphone hints have said goodbye,
Dropdowns now toggle, clear as the sky.
New features bloom, old hints depart,
Code hops forward, a rabbit’s art!
🐇✨

✨ 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.

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.

Copy link

@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 (3)
src/components/WebexActivity/WebexActivity.scss (1)

28-58: Good accessibility implementation, but inconsistent naming convention

The CSS implementation correctly handles both hover and keyboard focus states for the download button, ensuring accessibility. The transitions and positioning create a clean user experience.

However, the class naming doesn't follow the BEM pattern used elsewhere in the codebase (e.g., .#{$C}__content).

Consider refactoring the class names to match the existing BEM convention:

-.share-file-wrapper {
+.#{$C}__share-file-wrapper {
  position: relative;
  display: inline-block;
  margin-top: 8px;
  outline: none;
}

-.shared-screenshot {
+.#{$C}__shared-screenshot {
  max-width: 100%;
  border-radius: 4px;
  display: block;
}

// Download button initially hidden, appears on hover or keyboard focus
-.webex-share-item-actions {
+.#{$C}__share-item-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  padding: 4px;
}

-.share-file-wrapper:hover .webex-share-item-actions,
-.share-file-wrapper:focus-within .webex-share-item-actions {
+.#{$C}__share-file-wrapper:hover .#{$C}__share-item-actions,
+.#{$C}__share-file-wrapper:focus-within .#{$C}__share-item-actions {
  opacity: 1;
  visibility: visible;
}
src/components/WebexActivity/WebexActivity.jsx (2)

50-78: Replace emoji with proper icon from design system

The implementation provides good accessibility with proper ARIA attributes and keyboard navigation, but uses an emoji instead of a proper icon.

<button
  type="button"
  className="md-button md-button--32"
  aria-label={`Download ${file.displayName}`}
  onClick={() => downloadFile(file.url, file.displayName)}
>
-  ⬇️
+  <Icon name="download" />
</button>

Also, ensure the button class names match the project's design system - "md-button" suggests Material Design, but verify if this is the correct convention for this project.


54-58: Ensure consistent class naming with component CSS

To match the class naming used in the SCSS file with the JSX implementation:

<div
-  className="share-file-wrapper"
+  className={sc("share-file-wrapper")}
  tabIndex="0"
  role="group"
  key={file.url}
>
  <img
    src={file.url}
    alt={file.displayName || "shared file"}
-    className="shared-screenshot"
+    className={sc("shared-screenshot")}
  />
-  <div className="webex-share-item-actions">
+  <div className={sc("share-item-actions")}>

This would make the styling consistent with your component helper function and make refactoring easier in the future.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 86573e0 and cd0a324.

📒 Files selected for processing (5)
  • src/adapters/MeetingsJSONAdapter/controls/SwitchMicrophoneControl.js (0 hunks)
  • src/adapters/MeetingsJSONAdapter/controls/SwitchSpeakerControl.js (0 hunks)
  • src/components/WebexActivity/WebexActivity.jsx (2 hunks)
  • src/components/WebexActivity/WebexActivity.scss (1 hunks)
  • src/components/inputs/Dropdown/Dropdown.jsx (1 hunks)
💤 Files with no reviewable changes (2)
  • src/adapters/MeetingsJSONAdapter/controls/SwitchSpeakerControl.js
  • src/adapters/MeetingsJSONAdapter/controls/SwitchMicrophoneControl.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test_and_storybook
🔇 Additional comments (1)
src/components/inputs/Dropdown/Dropdown.jsx (1)

57-64: Improved code clarity through explicit conditional handling

The refactoring from a ternary expression to explicit if/else conditions with dedicated function calls makes the toggle behavior more readable and maintainable.

Comment on lines +27 to +34
function downloadFile(url, name) {
const link = document.createElement("a");
link.href = url;
link.download = name;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider error handling for the download functionality

The download function correctly creates and triggers a temporary link, but lacks error handling for potential failures.

function downloadFile(url, name) {
+  try {
    const link = document.createElement("a");
    link.href = url;
    link.download = name;
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
+  } catch (error) {
+    console.error('Failed to download file:', error);
+    // Consider showing user-friendly error notification
+  }
}
📝 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 downloadFile(url, name) {
const link = document.createElement("a");
link.href = url;
link.download = name;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function downloadFile(url, name) {
try {
const link = document.createElement("a");
link.href = url;
link.download = name;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Failed to download file:', error);
// Consider showing user-friendly error notification
}
}

Copy link
Contributor

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

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

Comment on lines +31 to +33
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid using document.body, you can directly add this to component being returned

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.

3 participants