Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to show a string the center of a cell in a wiki style table

I am using the following code to show table in Jira. You can notice that the text is not centered. For example, the cross and the checkmark are not centered. How can I make them centered? Here is my code below: 

 

Capture.PNG

 
package SuperFeature

import com.atlassian.jira.issue.Issue

import org.apache.log4j.Logger

import com.atlassian.jira.project.version.Version

import com.atlassian.jira.bc.project.component.ProjectComponent

import com.atlassian.jira.bc.project.component.ProjectComponentManager

import com.atlassian.jira.security.JiraAuthenticationContext

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.label.LabelManager

import SuperFeature.Configuration_SuperFeature

   

def log = Logger.getLogger('atlassian-jira.log')

List < String > componentList = new ArrayList < String > ()

if (issue.getComponents().size() == 0) {

    issue.update {

         String text = "*(x){color:red} Sub issue features cannot be generated given that the super feature "+issue+" has 0 components.{color}*\n"+

        "(on) *If you want to generate sub features, you should specify at least 1 component for the super feature "+issue+" and retry.* "

         

       

        setCustomFieldValue('Execution Summary', text )

    }

} else if (issue.getFixVersions().size() == 0) {

    issue.update {

        String text = "Issue does not have any fix versions\n"

        setCustomFieldValue('Execution Summary', text)

    }

} else {

    int componentSize = issue.getComponents().size()

   

    int generatedIssuesCounter= 0

    int nonGeneratedIssuesCounter= 0

    componentList.add("||COMPONENT NAME||EXECUTION INFORMATION||EXPLANATION||")

     for (ProjectComponent component: issue.getComponents()) {

                      String componentName = component.getName()

                       

                      if (!componentName.contains("-") || componentName.startsWith("-")) {

                            componentList.add("|*"+componentName+"*|   (x) |A valid component should be under the form *PROJ-COMP* "+

                            "where *PROJ* is the project name and *COMP* is an existing component name within *PROJ*.|")

                            nonGeneratedIssuesCounter++

                        } else{

                       

                    def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)

                    def projectName = componentName.substring(0, componentName.indexOf("-"))

               

                       

                        if(Configuration_SuperFeature.projectNames.contains(projectName)){

                       

                       

                        def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)

                        List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());

                        def found = newList.any {

                            it.getName().equals(shortenedComponentName)

                        }

                        if (found) {

                            componentList.add("|*"+componentName+"* |  (/) |"+" "+"|")

                            generatedIssuesCounter++

                        } else{

                            componentList.add("|*"+componentName+"* |  (x) | The component *" +shortenedComponentName+ "* is not present within the project *"+projectName+"*.|")

                            nonGeneratedIssuesCounter++

                        }

                        }

                        }

           

     }

     

    issue.update {

        String text = " *The super feature* " + issue + " *will be split as follows:*\n"+

        "* (/) " + generatedIssuesCounter + " sub feature(s) will be generated - 1 sub feature for each component.\n"+

        "* (x) "+nonGeneratedIssuesCounter+" sub feature(s) cannot be generated.\n"+

        " (on) More detailed information is displayed below: \n"

       

       text = text + componentList.join("\n")    ;

       

        setCustomFieldValue('Execution Summary', text)

    }

}

   

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events