Transforms: Add 'Format String' Transform (#73624)

* Format String Implementation

* Prettier

* Unify Every/Pascal/Camel cases

* Reformat + add new cases

* Add Trim and Substring to the transform options

* Trim/Substring tests+formatting

* refactor

* docs + feature toggle

* add category

* docs. add svg. change description

* revert weird add from merge

* readd config. change description

* docs change

* Adding experimental shortcode

* Add code formatting

* change shortcode

---------

Co-authored-by: Victor Marin <victor.marin@grafana.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
This commit is contained in:
Sol
2023-10-13 19:17:12 +01:00
committed by GitHub
parent 48ef88aed7
commit 889576ac1d
15 changed files with 408 additions and 1 deletions

View File

@@ -1007,6 +1007,23 @@ This transformation is available in Grafana 10.1+ as an alpha feature.
Use this transformation to format the output of a time field. Output can be formatted using (Moment.js format strings)[https://momentjs.com/docs/#/displaying/]. For instance, if you would like to display only the year of a time field the format string `YYYY` can be used to show the calendar year (e.g. 1999, 2012, etc.).
### Format string
> **Note:** This transformation is an experimental feature. Engineering and on-call support is not available. Documentation is either limited or not provided outside of code comments. No SLA is provided. Enable the `formatString` in Grafana to use this feature. Contact Grafana Support to enable this feature in Grafana Cloud.
Use this transformation to format the output of a string field. You can format output in the following ways:
- Upper case - Formats the entire string in upper case characters.
- Lower case - Formats the entire string in lower case characters.
- Sentence case - Formats the the first character of the string in upper case.
- Title case - Formats the first character of each word in the string in upper case.
- Pascal case - Formats the first character of each word in the string in upper case and doesn't include spaces between words.
- Camel case - Formats the first character of each word in the string in upper case, except the first word, and doesn't include spaces between words.
- Snake case - Formats all characters in the string in lower case and uses underscores instead of spaces between words.
- Kebab case - Formats all characters in the string in lower case and uses dashes instead of spaces between words.
- Trim - Removes all leading and trailing spaces from the string.
- Substring - Returns a substring of the string, using the specified start and end positions.
{{% docs/reference %}}
[Table panel]: "/docs/grafana/ -> /docs/grafana/<GRAFANA VERSION>/panels-visualizations/visualizations/table"
[Table panel]: "/docs/grafana-cloud/ -> /docs/grafana/<GRAFANA VERSION>/panels-visualizations/visualizations/table"