import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)
def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []
if ("Тестировщик" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение"] })
}
if ("Релиз-инженер" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение"] })
}
if ("Диспетчер" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение"] })
}
if ("Администратор" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение", "Epic"] })
}
if ("Менеджер" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение", "Epic"] })
}
if ("Разработчик" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll {
it.name in ["Подзадача", "Дефект", "Улучшение", "Epic"] })
}
issueTypeField.setFieldOptions(availableIssueTypes)