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

Button to copy service response as json for templates #21226

Merged
merged 4 commits into from
Jul 22, 2024

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Jun 29, 2024

Proposed change

Button to format service action response as json, for use with the template editor. Discussed a bit before at #18866.

image

Copies:

{% set action_response = {"calendar.calendar_1":{"events":[{"start":"2024-06-26T09:40:36.093296-07:00","end":"2024-06-26T10:40:36.093296-07:00","summary":"Future Event","description":"Future Description","location":"Future Location"}]},"calendar.calendar_2":{"events":[{"start":"2024-06-26T08:40:36.093461-07:00","end":"2024-06-26T09:40:36.093461-07:00","summary":"Current Event"}]}} %}

and can be directly pasted in the template editor.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a slot element named "extra-actions" to the YAML editor component, allowing for additional UI actions to be conditionally rendered.
    • Enhanced developer tools panel with a button to copy templates to the clipboard and display a toast notification upon success.
  • Localization

    • Introduced a new translation key for "Copy to clipboard (template)" to improve user interface support.

This comment was marked as off-topic.

silamon
silamon previously approved these changes Jul 8, 2024
coderabbitai[bot]

This comment was marked as off-topic.

@@ -107,6 +107,7 @@ export class HaYamlEditor extends LitElement {
"ui.components.yaml-editor.copy_to_clipboard"
)}
</mwc-button>
<slot name="extra-actions"></slot>
Copy link
Member

@bramkragten bramkragten Jul 19, 2024

Choose a reason for hiding this comment

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

This one should be outside of the copyClipboard ternary, it is not possible to add extra actions now without adding the copy clipboard action.

Copy link
Contributor Author

@karwosts karwosts Jul 19, 2024

Choose a reason for hiding this comment

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

Changed, is another property the best way to solve? I don't want to create the card-actions div if there aren't any actions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah looks good! 👍

@silamon silamon merged commit 811c34b into home-assistant:dev Jul 22, 2024
13 checks passed
@karwosts karwosts deleted the copy-service-template branch July 22, 2024 17:03
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.

3 participants