Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Display HTML as option/parameter in User Macro

Matt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2022

Hi community!

I’m trying to create a custom user macro for my org and I’d like the ability to display rendered HTML as a parameter for selection. The macro will basically be a custom button creator for end users. I’d like to have the ability for them to add an icon to the button based off of the icons available through AUI - Icons - AUI Documentation (atlassian.com)

How can I render those icons within a select/enum option for the custom user macro?

1 answer

1 accepted

0 votes
Answer accepted
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2022

Hello fellow user macro enthusiast, @Matt ! Here is how I would do it. From that page you linked, pick out the icons you want. When you hover over the icon, it will display the type name.

Now use those names in whatever order you want (probably alphabetic would be best) to populate your param

## @param IconType:title=Type of icon|type=enum|enumValues=check,arrow-right-circle,camera-take-picture

<span class="aui-icon aui-icon-SIZE aui-iconfont-$paramIconType">Alternative Text</span>

The size you can also have as an option (I think default is small). I think the options are small and large.

If you wanted to be really fancy, you could come up with better names, then use a key-value structure to convert fancy name to machine name.

Matt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2022

Thanks Bill for your response! 

Rather than plain text for selecting the type of icon, I'd like have the user select from the rendered icon itself.  I tried passing the params as the html string but that's not working. Maybe prevent to any type of RCE I'm assuming?


@param Icon:title=Button Icon|type=enum|enumValues=<span class="aui-icon aui-icon-small aui-iconfont-activity" original-title="activity">Activity</span>,<span class="aui-icon aui-icon-small aui-iconfont-add-circle" original-title="add-circle">Add</span>|required=false

I'm not sure if this is possible or if there's any way, within User Macros, to display/use JS/HTML as a method of input for the macro's parameters/option?

Is what I'm looking to do outside of the User Macro scope and more in the custom add-on area?

Thanks again!

Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2022

it is outside the simple user macro. User should be able to select from the text pull-down, then refresh the view before insertion to see what it is.

There are more options available to you if you package a user macro as a plugin (basically the Velocity code is wrapped with normal plugin attributes. You do get more options (for example, being able to make the macro available on the Insert menu), but I am not sure you can change the display.

Information is here: user-macro-module Be advised that much of the info has not been updated in years.

Like Matt likes this
Matt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2022

Thanks Bill for confirming! Looks like I'll go with your original suggestion an only include the most useful options and inform users to use refresh to preview what it will look like. Thanks again!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events