Skip to content
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

Kraken UI improvements #3150

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Feb 13, 2025

Summary by Sourcery

Improve the Kraken extension management UI. Add a copy config button to the extension creation/edit modal, and replace the permissions text area with a JSON editor. Add a version field to network interface settings. Introduce a clipboard utility function.

Enhancements:

  • Improve Kraken extension creation and editing experience by adding a copy configuration button and a JSON editor for permissions.
  • Add a version field to the network interface settings in Cable Guy and set the initial version to 0.
  • Add a utility function to copy text to the clipboard with permission handling and fallback behavior using a temporary input element or Clipboard API

Copy link

sourcery-ai bot commented Feb 13, 2025

Reviewer's Guide by Sourcery

This pull request introduces several UI improvements to the Kraken extension creation modal, including a copy configuration feature and a JSON editor for managing extension permissions. It also updates the settings loading mechanism in the cable guy service to include a version number in the settings root. The copy configuration feature allows users to easily copy the extension's configuration as JSON to the clipboard, while the JSON editor provides a more user-friendly interface for managing JSON data. The settings loading mechanism update ensures that the settings root includes a version number.

Sequence diagram for copying extension configuration

sequenceDiagram
  participant User
  participant ExtensionCreationModal
  participant Clipboard

  User->>ExtensionCreationModal: Clicks 'Copy configuration'
  ExtensionCreationModal->>ExtensionCreationModal: Retrieves extension configuration
  ExtensionCreationModal->>ExtensionCreationModal: Formats configuration as JSON
  ExtensionCreationModal->>Clipboard: copyToClipboard(jsonString)
  alt Success
    Clipboard-->>ExtensionCreationModal: Returns success
    ExtensionCreationModal->>ExtensionCreationModal: Sets copySuccess to true
    ExtensionCreationModal-->>User: Visual feedback (e.g., checkmark)
  else Failure
    Clipboard-->>ExtensionCreationModal: Returns failure
    ExtensionCreationModal-->>User: Visual feedback (e.g., error message)
  end
Loading

Sequence diagram for pasting extension configuration

sequenceDiagram
  participant User
  participant ExtensionCreationModal

  User->>ExtensionCreationModal: Pastes JSON configuration
  ExtensionCreationModal->>ExtensionCreationModal: handlePaste(event)
  ExtensionCreationModal->>ExtensionCreationModal: Parses JSON
  alt Valid Configuration
    ExtensionCreationModal->>ExtensionCreationModal: Updates form data
    ExtensionCreationModal-->>User: Form fields updated
  else Invalid Configuration
    ExtensionCreationModal->>ExtensionCreationModal: Logs error
    ExtensionCreationModal-->>User: No change
  end
Loading

File-Level Changes

Change Details Files
Introduced a copy configuration feature to the extension creation modal, allowing users to copy the extension's configuration as JSON to the clipboard.
  • Added a copy button with an icon to the extension creation modal.
  • Implemented a copyConfig method to handle the copying of the extension configuration to the clipboard.
  • Added a copySuccess data property to indicate whether the copy operation was successful.
  • Added a new utility function copyToClipboard to handle clipboard operations with permission handling and fallback.
  • The copy button provides visual feedback upon successful copy.
  • The button copies the identifier, name, docker, tag, and permissions.
  • Added a handlePaste method to allow pasting of JSON configurations into the modal.
core/frontend/src/components/kraken/modals/ExtensionCreationModal.vue
core/frontend/src/utils/clipboard.ts
Replaced the text area with a JSON editor component for editing extension permissions, providing a more user-friendly interface for managing JSON data.
  • Replaced v-textarea with json-editor component for editing permissions.
  • Added a reset button to revert permissions to default values.
  • Implemented onEditingPermissionsSave to save permissions from the JSON editor.
  • Implemented resetToDefaultPermissions to reset permissions to default values.
  • Added is_reset_editing_permissions_visible computed property to control the visibility of the reset button.
  • The JSON editor is now used for both creating and editing extensions.
core/frontend/src/components/kraken/modals/ExtensionCreationModal.vue
Updated the settings loading mechanism in the cable guy service to include a version number in the settings root.
  • Added a version key to the settings root when loading default configurations.
  • The version is set to 0.
core/services/cable_guy/api/manager.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

* @param text - The text to copy to clipboard
* @returns Promise<boolean> indicating if the copy operation succeeded
*/
export const copyToClipboard = async (text: string): Promise<boolean> => {
Copy link
Collaborator

@JoaoMario109 JoaoMario109 Feb 17, 2025

Choose a reason for hiding this comment

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

You can put this util on cosmo.ts. And check if is using HTTP just override the navigator.clipboard with the fallback implementation, otherwise will be a secure context and copy will be available by default.

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.

2 participants