Modify plugin

en:https://developer.atlassian.com/server/framework/atlassian-sdk/modify-the-plugin/

In the previous steps , you have created a framework for the JIRA plugin. In this wizard, you will modify your plugin to add a link on the JIRA menu. To accomplish this, you need to create a  Web Section Plugin Module  and a  Web Item Plugin Module using the Atlassian SDK  .

Step 1. Update the organization information that appears in the plugin

  1. After closing JIRA, you should still be in the myPlugin directory.
  2. Open the pom.xml file in your favorite editor.
  3. Navigate to the <organization> node in the file, it should look like this:

        <organization>
            <name>Example Company</name>
            <url>http://www.example.com/</url>
        </organization>
  4. Update the node to include some personal information like:

        <organization>
            <name>Atlassian SDK Tutorial</name>
            <url>http://developer.atlassian.com/</url>
        </organization>
  5. Save and close the file.

  6. Go back to the command line window, type atlas-run, and wait for JIRA to restart.

  7. If prompted to log in, complete the login.

  8. Open the Manage add-ons page in your browser using localhost:2990/jira/plugins/servlet/upm .

  9. Expand myPlugin to see your changes.

  10. When done, use Ctrl+D to close JIRA.

Step 2. Add custom menu in JIRA

  1. In your favorite text editor, open the  /src/main/resources/atlassian-plugin.xml file in the myPlugin directory.
  2. The atlassian-plugin.xml file should look like this:

    <atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
        <plugin-info>
            <description>${project.description}</description>
            <version>${project.version}</version>
            <vendor name="${project.organization.name}" url="${project.organization.url}" />
            <param name="plugin-icon">images/pluginIcon.png</param>
            <param name="plugin-logo">images/pluginLogo.png</param>
        </plugin-info>
        <!-- add our i18n resource -->
        <resource type="i18n" name="i18n" location="myPlugin"/>
        <!-- add our web resources -->
        <web-resource key="myPlugin-resources" name="myPlugin Web Resources">
            <dependency>com.atlassian.auiplugin:ajs</dependency>
            <resource type="download" name="myPlugin.css" location="/css/myPlugin.css"/>
            <resource type="download" name="myPlugin.js" location="/js/myPlugin.js"/>
            <resource type="download" name="images/" location="/images"/>
            <context>myPlugin</context>
        </web-resource>
    </atlassian-plugin>
  3. Next, in the command line window, make sure you are in the myPlugin directory, then run the following command:

    atlas-create-jira-plugin-module

    You will be prompted to select a plugin module from a list of possible module types ( see Plugin Modules for more information).

  4. Enter 30 to select the Web Section plugin module type.

  5. Now, you will be prompted to answer a few configuration questions, the answers are as follows:

    Enter Plugin Module Name My Web Section: : mySection
    Enter Location (e.g. system.admin/mynewsection): my-item-link
    Show Advanced Setup? (Y/y/N/n) N: : N

    At this point, the location my-item-link does not exist yet, but we will create it in the next step.

  6. Next, you will be asked if you need other plugin modules. Type Y to create another module.

  7. Type 25 to select  Web Item  the plugin module and answer the configuration questions as follows:

    Enter Plugin Module Name My Web Item: : myItem
    Enter Section (e.g. system.admin/globalsettings): system.top.navigation.bar
    Enter Link URL (eg /secure/CreateIssue!default.jspa) : deleteMe
    Show Advanced Setup? (Y/y/N/n) N: : N
  8. When prompted if you need additional plugin modules, enter N.
    The system will complete the creation of the module, and you will receive a confirmation message after the creation is successful.

Step 3. Customize the menu

  1. Open the atlassian-plugin.xml file and you will find that it has changed a little:

    <?xml version="1.0" encoding="UTF-8"?>
    
    
    <atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
      <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}"/>
        <param name="plugin-icon">images/pluginIcon.png</param>
        <param name="plugin-logo">images/pluginLogo.png</param>
      </plugin-info>
      <!-- add our i18n resource -->
      <resource type="i18n" name="i18n" location="myPlugin"/>
      <!-- add our web resources -->
      <web-resource key="myPlugin-resources" name="myPlugin Web Resources">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <resource type="download" name="myPlugin.css" location="/css/myPlugin.css"/>
        <resource type="download" name="myPlugin.js" location="/js/myPlugin.js"/>
        <resource type="download" name="images/" location="/images"/>
        <context>myPlugin</context>
      </web-resource>
      <web-section name="mySection" i18n-name-key="my-section.name" key="my-section" location="my-item-link" 
    weight="1000">
        <description key="my-section.description">The mySection Plugin</description>
        <label key="my-section.label"/>
      </web-section>
      <web-item name="myItem" i18n-name-key="my-item.name" key="my-item" section="system.top.navigation.bar" 
    weight="1000">
        <description key="my-item.description">The myItem Plugin</description>
        <label key="my-item.label"></label>
        <link linkId="my-item-link">deleteMe</link>
      </web-item>
    </atlassian-plugin>
  2. In the web-section, delete the following information:

    • <label key="my-section.label"/> 这一行
    • <link linkId="my-item-link">中的deleteMe字段

    In this wizard, we don't want the 'myItem' menu to be linked anywhere, and we don't want to see the 'mySection' label in our menu.

  3. Save your changes.

  4. Go back to the command line window, execute atlas-run, and wait for JIRA to start up.

  5. Once you log in successfully, you will see this new JIRA menu.

  6. Close JIRA with Ctrl+D.

Next step

Every time you start and close JIRA it will take some time. QuickReload significantly reduces your plugin development iteration time, so in the next part of the tutorial, you'll learn how to use it to test a change to your plugin without restarting JIRA.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325215374&siteId=291194637