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

In the marker schema, support label templates with conditional behavior depending on whether a field is present #5314

Open
mstange opened this issue Jan 14, 2025 · 1 comment
Labels
markers Anything to do with marker data structures, marker chart, or the marker table profile data Issues related to the profile format, data structure, or profile upgraders

Comments

@mstange
Copy link
Contributor

mstange commented Jan 14, 2025

We have custom code for the FileIO marker's tableLabel:

if (data.source) {
description = `(${data.source}) `;
}
description += data.operation;
if (data.filename) {
description = data.operation
? `${description}${data.filename}`
: data.filename;
}

Mostly what's happening is that some fields are optional, and those fields shouldn't be surrounded by brackets or separated by spaces or dashes if they're not present.

It would be nice if we could achieve the same result with some extensions to the label template syntax.

A similar request was made in the past by @fqueze, when he wanted to share the same schema for these two markers, to reduce code duplication at the schema declaration: https://share.firefox.dev/4fWgc0B

┆Issue is synchronized with this Jira Task

@mstange
Copy link
Contributor Author

mstange commented Jan 14, 2025

We could take inspiration from the Jujutsu template syntax. It has functions surround and separate which ignore empty inputs.

For example, the FileIO tableLabel could be {separate(' — ', separate(' ', surround('(', ')', marker.data.source), marker.data.operation), marker.data.filename)}

@canova canova added profile data Issues related to the profile format, data structure, or profile upgraders markers Anything to do with marker data structures, marker chart, or the marker table labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
markers Anything to do with marker data structures, marker chart, or the marker table profile data Issues related to the profile format, data structure, or profile upgraders
Projects
None yet
Development

No branches or pull requests

2 participants