I want to show the project admin role users in project summary page, though i have written the custom script to show the users under role: projet admin. However, there is a dependency to pass the "issue key" manually to get the users under role "10050" for that perticualler project . Though i dont want to pass the "issue key", it should dynamically get the "project key" from the project summary page. Here is my code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.user.ApplicationUsers
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import com.atlassian.jira.bc.projectroles.DefaultProjectRoleService
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
@BaseScript CustomEndpointDelegate delegate
ProjectAdmins() { MultivaluedMap queryParams ->
// get a reference to the current page...
// def page = getPage(queryParams)
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
long projectRoleId = 10050 // ID of Automatic Watcher project role
def role = projectRoleManager.getProjectRole(projectRoleId)
def issue1 = ComponentAccessor.getIssueManager().getIssueByCurrentKey("INT-1")
def actors = projectRoleManager.getProjectRoleActors(role, issue1.getProjectObject())
def usersInRole = actors.getApplicationUsers();
def projectRoleUsers = new StringBuffer()
for (g in usersInRole) {
projectRoleUsers.append(g.getName()+",")
projectRoleUsers.append("<br>")
}
def dlgHeader = """<div>
<b><u>Project Admins</u></b>
</div>"""
def dialog =
"""<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main"><b>Project Admin User List</b></h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog"><b>Close</b></span>
</a>
</header>
<div class="aui-dialog2-content">
""" + dlgHeader + """
""" + projectRoleUsers + """
</div>
</section>
"""
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}
Rest Endpoint is situated in the server side. It can not know information about the page which is viewd by a user in his/her browser. That is why you need to pass the issue key.
@Alexey Matveev Is there any other way a part from Rest Endpoints? My only requirement is to show the member of project admin role per project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should create a web panel in ScriptRunner. Kindly have a look here:
https://scriptrunner.adaptavist.com/5.3.1/jira/fragments/WebPanel.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev Ok, So if i provide the link into the provider class/script to execute. But still i need to pass the issue key right? So do you have an example code to put into the file where i dont need to pass the issue key in variable? Or second option would be to pass the issue key's in "condition section" but that will be quite difficult. Because there are more then 100 projects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You do not need an issue key. You need to know the project. You can query the project by
jiraHelper.project
You can see it in the example in the ScriptRunner documentation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexey Matveev ,
I made my own script , that made a dialog like in here.
It worked good, until we upgrade the script runner.
Now, the dialog opens in a different page (not as a pop up)..
like this:
I need this dialog to open like a pop up on the view screen of the issue.
Thanks,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.