JIRA增加自定义导航菜单项---普通用户查看所有项目

一、视图:添加自定义菜单


<web-item key="custom-menu" name="custom Menu" section="system.top.navigation.bar" weight="150">
	<label>CUSTOM</label>
	<link linkId="custom-menu">http://www.j-tricks.com</link>
	<condition class="com.atlassian.jira.plugin.webfragment.conditions.UserLoggedInCondition"/>
</web-item>
<web-section key="custom-menu-section" name="custom-menu Dropdown" location="custom-menu" weight="200"></web-section>
<web-item key="custom-menu-section-item" name="custom-menu-section Item" section="custom-menu/custom-menu-section" weight="210">
	<label>CUSTOM ALL PROJS</label>
	<link linkId="custom.section.link">http://www.j-tricks.com/tutorials</link>
</web-item>


二、参考系统配置:system-top-navigation-plugin.xml / JiraWebActionSupport.properties

2.1 View All Projects

browseprojects.js  、backbone-paginator.js、 backbone-queryparams.js
project-type-keys.js、   autocomplete.js、  projects-api.js、   batch.js

<web-item key="project_view_all_link" name="View All Projects Link" section="browse_link/project_view_all"
              i18n-name-key="webfragments.navigation.bar.project.item.view.all" weight="10">
        <label key="menu.project.view.all"/>
        <tooltip key="menu.project.view.all.title"/>
        <link linkId="project_view_all_link">/secure/BrowseProjects.jspa?selectedCategory=all&selectedProjectType=all</link>
</web-item>


2.2 访问action:actions.xml、system-webresources-plugin.xml

<action name="browser.BrowseProjects" alias="BrowseProjects">
        <view name="success" type="soy">:browseprojects/JIRA.Templates.Project.Browse.page</view>
        <view name="error" type="soy">:browseprojects/JIRA.Templates.Project.Browse.error</view>
</action>

<web-resource key="browseprojects" i18n-name-key="admin.web.resources.plugin.browseprojects.name"
                  name="browseprojects" state='enabled'>
        <dependency>jira.webresources:jira-global</dependency>
        <dependency>jira.webresources:jira-analytics-amd</dependency>
        <dependency>jira.webresources:jira-formatter</dependency>
        <dependency>jira.webresources:jira-metadata</dependency>
        <dependency>jira.webresources:marionette</dependency>
        <dependency>jira.webresources:backbone-paginator</dependency>
        <dependency>jira.webresources:backbone-queryparams</dependency>
        <dependency>jira.webresources:navigation-utils</dependency>
        <dependency>jira.webresources:project-type-keys</dependency>

        <transformation extension="js">
            <transformer key="jsI18n"/>
        </transformation>
        <transformation extension="soy">
            <transformer key="soyTransformer"/>
        </transformation>
        <transformation extension="less">
            <transformer key="lessTransformer"/>
        </transformation>
      <resource type="download" name="browse.soy.js" location="/includes/jira/project/templates/browse.soy">
            <param name="source" value="webContextStatic"/>
        </resource>
</web-resource>

2.3 action返回视图的页面组成:browse.soy

<section id="content" role="main">	
        <header class="aui-page-header">
           <div class="aui-page-header-inner">
                <div class="aui-page-header-main">
                    <h1>Browse Projects</h1>
                </div>
                <!-- .aui-page-header-main -->
                <div class="aui-page-header-actions">
                     <a href="/jira" class="aui-button add-project-trigger" 
                     id="browse-projects-create-project" title="null">Create New Project</a>
                </div><!-- .aui-page-header-actions -->
           </div><!-- .aui-page-header-inner -->
        </header><!-- .aui-page-header -->
        
        <div class="aui-page-panel" id="browse-projects-page">
        
             <div class="aui-page-panel-inner">
             
                 <div class="aui-page-panel-nav">
                      <div class="project-type-nav"></div>
                      <div class="category-nav"></div>
                 </div>                        <!-- .aui-page-panel-nav 左侧items --> 
                 
                 <section class="aui-page-panel-content">
                    <div class="module">
                       <div class="mod-header" id="filter-projects"></div>  <!-- 项目搜索栏-->
                       <div class="mod-content" id="projects"></div>  <!--项目信息表格-->
                    </div>
                    <div id="pagination"></div>         <!--分页-->
                 </section>                  <!-- .aui-page-panel-content  右侧项目信息和搜索-->
                 
             </div><!-- .aui-page-panel-inner -->
             
         </div><!-- .aui-page-panel -->
    </section>
   

三、优化自定义菜单


3.1.更改菜单链接的地址(link),添加菜单显示的条件(自定义condition)。

<web-item key="custom-menu" name="custom Menu" section="system.top.navigation.bar" weight="150">
	<label>CUSTOM</label>
	<link linkId="custom-menu">/secure/BrowseProjects.jspa?selectedCategory=all&selectedProjectType=all</link>
	<!-- 登录并存在项目信息就显示 -->
	<condition class="com.cmbc.proInfo.conditions.VisibleProjectInfoCondition"/>
</web-item>
 <web-section key="custom-menu-section" name="custom-menu Dropdown" location="custom-menu" weight="200"></web-section>
 <web-item key="custom-view-allprojs-item" name="custom-menu-section Item" section="custom-menu/custom-menu-section" weight="210">
	<label>CUSTOM ALL PROJS</label>
	<link linkId="custom-view-allprojs-item">/secure/BrowseProjects.jspa?selectedCategory=all&selectedProjectType=all</link>
	<!-- 登录并存在项目信息就显示 -->
	<condition class="com.cmbc.proInfo.conditions.VisibleProjectInfoCondition"/>
</web-item>
3.2 添加自定义condition类:

public class VisibleProjectInfoCondition extends AbstractWebCondition{
	@Override
	public boolean shouldDisplay(ApplicationUser user, JiraHelper helper) {
		return user!=null&&helper.getProjectObject()!=null;
	}
}


3.3 其他:condition条件限定中的权限信息

<condition class="com.atlassian.jira.plugin.webfragment.conditions.JiraGlobalPermissionCondition">
      <param name="permission">admin</param>
</condition>
permission值的可选内容:

admin,use, sysadmin,project, browse,create,edit, update(same as edit),scheduleissue, assign, assignable,attach,resolv,close, comment,delete, work,worklogdeleteall,worklogdeleteown,worklogeditall,worklogeditown, link, sharefilters,groupsubscriptions,move,setsecurity, pickusers, viewversioncontrol,modifyreporter,
viewvotersandwatchers,managewatcherlist,bulkchange, commenteditall,commenteditown,commentdeleteall,commentdeleteown,attachdeleteall,attachdeleteown,viewworkflowreadonly










阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页