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

allow for modifying Alert copy-button behavior #555

Merged
merged 2 commits into from
Mar 9, 2023

Conversation

emillen
Copy link
Contributor

@emillen emillen commented Mar 4, 2023

Use nunjucks-templates to modify AlertDetail copy-button behavior

Description
Sometimes you want the ability to copy an alert so you can paste into a third party system (slack, email, etc) in human-readable way. This PR allows for setting a nunjuck-template used for formatting the JSON before putting it in the clipboard.

Fixes #522

Changes

  • Install Nunjucks (jinja2-like templating engine)
  • When clipboard_template setting is set, the webui uses its contents as template for the AlertDetail copy button
  • If clipboard_template is not set, it defaults to previous behavior

If you think this is a good idea and merge this, I will add PR's for adding the setting in the backend, and also add it to the docs.


Ex:

Provided following alert-json

{
  "text": "this is a major alert",
  "environment": "prod"
}

and this template

{
  "clipboard_template": "[{{environment | upper}}] Alert!\n{{text}}"
}

would put the following text in your clipboard

[PROD] Alert!
this is a major alert

Use nunjucks-templates to modify AlertDetail copy-button behaviour
@netlify
Copy link

netlify bot commented Mar 4, 2023

Deploy Preview for peaceful-beignet-dcf974 ready!

Name Link
🔨 Latest commit 21b8569
🔍 Latest deploy log https://app.netlify.com/sites/peaceful-beignet-dcf974/deploys/640836de6048cb0008b4e346
😎 Deploy Preview https://deploy-preview-555--peaceful-beignet-dcf974.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

emillen added a commit to emillen/alerta that referenced this pull request Mar 4, 2023
to allow for configuring this web console setting in the backend: alerta/alerta-webui#555
kennhardy
kennhardy previously approved these changes Mar 6, 2023
Copy link

@kennhardy kennhardy left a comment

Choose a reason for hiding this comment

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

Looks good. Approved together with alerta/alerta#1814 (dependent)

satterly pushed a commit to alerta/alerta that referenced this pull request Mar 7, 2023
* Add CLIPBOARD_TEMPLATE setting

to allow for configuring this web console setting in the backend: alerta/alerta-webui#555

* fix lintin errors

* Add test for CLIPBOARD_TEMPLATE setting

demonstrate that clipboard_template is returned by the api when
CLIPBOARD_TEMPLATE is set in the backend

---------

Co-authored-by: Kenneth Hardy <kenneth@hardy.se>
src/components/AlertDetail.vue Outdated Show resolved Hide resolved
@satterly satterly added the needs work This pull request needs work label Mar 7, 2023
@emillen
Copy link
Contributor Author

emillen commented Mar 9, 2023

What do you say - does this need more work, or are we fine like this?

@satterly
Copy link
Member

satterly commented Mar 9, 2023

Can you include a screenshot in the PR description? Thanks.

@satterly
Copy link
Member

satterly commented Mar 9, 2023

Actually ignore that. There's probably nothing different. I'll merge.

@satterly satterly merged commit 9e376cc into alerta:master Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs work This pull request needs work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to format "copy alert" functionality
3 participants