Forums

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

Javascript update UI componet

Avinash Singh
Contributor
June 7, 2019 edited

Hi,

Im trying to update an UI element through javascript from Jira announcement banner. 

When the page is already loaded it easy to disable the elements i need, however been able to do this on page load its difficult. I seems that the page is loaded in sections and the UI element that I require is not available when the page load event fires.

https://jiratest.example.com/servicedesk/admin/QISP/confluence-kb

Im trying to disable one of the radio box in these options:

{noformat}

Access

Viewing

- Define who can view knowledge base articles through the portal and in the linked Confluence space.

- All active users and customers can access the knowledge base without a Confluence license.Only licensed users who have access to the space

{noformat}

What event should i use to listen to when all elements are loaded or the panel that I require is loaded?

 

Regards,

Avinash

1 answer

1 vote
Andy Heinzer
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.
June 20, 2019

Hi Avinash,

I see that you are looking to customize the displayed options for setting up a Service Desk to Confluence integration.   While this page is designed to be managed by any Jira Administrator, I could see a use case here as to why you might want to restrict this from Jira Admins in some way.

I found a way to do this in Jira Server, but I should preface this response to explain that this can only be done in Jira Server (Jira Cloud does not permit this kind of customization), and that any Jira System level administrator would be able to undo these changes by removing this from the announcement banner.

I can see how trying to load a javascript here to hide such elements could be problematic.  You are correct that when first configuring this integration, not all the elements are loaded to the page right away.  Instead of trying to use javascript to do this, I found I could hide certain radio boxes from being selected by customizing the css instead.

Which option did you want to hide here?  All active users...  or the Only licensed users?

If you want to disable the all active users, you can use this:

<style type="text/css">
input#sd-kb-access-option-any {display:none}
</style>

 Or if you want to hide the option of only licensed users you could use:

<style type="text/css">
input#sd-kb-access-option-space-users {display:none}
</style>

But I would recommend not trying to use both at the same time. 

I hope this helps.

Andy

Avinash Singh
Contributor
June 21, 2019

Thanks for this Andrew.

This is what I have done. I put together some yukky javascript to disable the option and we also put a restriction on our reverse proxy to drop the following requests:

https://jira.xxx.com/rest/servicedesk/1/knowledgebase/permissions/{spaceId}/unlicensed/enable

 

<script type="text/javascript">
(function($)
{


$(document).ready(function() {

var reg = /https:\/\/jira.xxx.com\/servicedesk\/admin\/[A-Za-z][A-Za-z0-9]*\/confluence-kb/

if (document.getElementsByClassName("aui-page-panel-content").length > 0)
{

function hideKbAccessOption(){
if (reg.test(window.location.href))
{

AJS.$('#sd-kb-access-option-any')[0].disabled = true;
AJS.$('#sd-kb-access-option-any')[0].title = "Security Restriction by Admin";
}
}

document.getElementsByClassName("aui-page-panel-content")[0].addEventListener("mouseover", hideKbAccessOption);
}

});
})(AJS.$);
</script>

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery learning path, product discovery training, idea prioritization, align stakeholders, discovery to delivery, product collaboration, atlassian learning, dev process, roadmap planning, insight capture, team alignment

Elevate Your Skills with Jira Product Discovery!

Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!

Start Learning
AUG Leaders

Atlassian Community Events