Skip to content

Conversation

@luannmoreira
Copy link
Member

@luannmoreira luannmoreira commented Jun 9, 2025

Description

This pull request refactors all direct clipboard copy functionality in the UI to use the reusable CopyWarning component. Previously, each component implemented its own logic to copy text to the clipboard and show snackbar messages. This change consolidates that behavior into a single, maintainable component, improving consistency across the application.
Obsolete methods such as copyText, copyCommand, and copyMacro were removed where applicable.

Why

  • To treat a problem with Permissions API from each browser that prevents using the Clipboard API on non-localhost or unsecure HTTP instances.
  • To centralize and standardize clipboard copy behavior.
  • To reduce code duplication across components.
  • To ensure consistent snackbar messaging on successful copy actions.
  • To simplify maintenance and improve future scalability of clipboard-related logic.

Tests

  • Updated unit tests for components using CopyWarning.
  • Removed tests tied to deprecated methods (e.g., copyCommand()).
  • Verified DOM snapshot updates reflect the new component structure.
  • Manually tested all updated components to ensure clipboard copying and snackbar messages function as expected.

Copy link
Member

@luizhf42 luizhf42 left a comment

Choose a reason for hiding this comment

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

Perfect changes overall! Just please implement the warning component in ConnectorList.vue and DeviceTable.vue too, since they still have their "native" copying methods with no secure context verification.

@luizhf42
Copy link
Member

Also, since snackbar.showInfo is always called in the components' template, don't you think that it could be called inside CopyWarning, just requiring some copyMessage or copiedItem prop from the components instead of a function?

Replaces all direct clipboard interactions with the reusable
CopyWarning component. This standardizes copy-to-clipboard behavior
and ensures consistent user feedback via snackbar messages.
@luannmoreira luannmoreira force-pushed the refactor/use-copy-warning-component branch from 1ca1b11 to 8dfb51d Compare June 16, 2025 13:27
@luannmoreira luannmoreira requested a review from luizhf42 June 16, 2025 14:04
@gustavosbarreto gustavosbarreto merged commit 7e7807c into master Jun 17, 2025
8 checks passed
@gustavosbarreto gustavosbarreto deleted the refactor/use-copy-warning-component branch June 17, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants