<%@ page import="com.atlassian.jira.ComponentManager"%>
<%@ page import="com.atlassian.jira.util.EasyList"%>
<%@ page import="com.atlassian.jira.web.action.util.JiraLicenseUtils"%>
<%@ page import="com.atlassian.license.License"%>
<%@ page import="com.atlassian.license.LicenseManager"%>
<%@ page import="com.atlassian.plugin.webresource.WebResourceManager"%>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<%@ taglib uri="webwork" prefix="webwork" %>
<page:applyDecorator name="jirapanel">
    <page:param name="title"><webwork:property value="text('navigator.title')"/><webwork:if test="searchRequest/name"> &mdash; <webwork:property value="searchRequest/name"/></webwork:if></page:param>
    <page:param name="description">
    <div class="perm-link subText">
        [ <a id="permlink" href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?reset=true&<webwork:property value="SRQueryStringWithSorts" />" title="<webwork:text name="'viewissue.permlink.title.navigator'"/>"><webwork:text name="'viewissue.permlink'"/></a> ]
    </div>
    <%-- Test if we have any issues that were found --%>
    <webwork:if test="/searchResults/total > 0">
        <webwork:text name="'navigator.results.displayissues'">
            <webwork:param name="'value0'"><b><webwork:property value="/searchResults/niceStart" /></b></webwork:param>
            <webwork:param name="'value1'"><b><webwork:property value="/searchResults/end" /></b></webwork:param>
            <webwork:param name="'value2'"><b><webwork:property value="/searchResults/total" /></b></webwork:param>
        </webwork:text>.&nbsp;<br>
    </webwork:if>
    </page:param>
    <page:param name="width">100%</page:param>

    <webwork:if test="/searchResults/total == 0">
        <webwork:text name="'navigator.results.nomatchingissues'"/>
    </webwork:if>

    <%-- Only show the views if there are issues that match the search criteria--%>
    <webwork:if test="/searchResults/total > 0">
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td valign="bottom" width="80%"><b><webwork:text name="'navigator.results.currentview'"/>:</b><br>
                    <webwork:if test="'bulk' != $view">
                        <webwork:text name="'navigator.results.currentview.browser'"/>
                    </webwork:if>
                    <webwork:else>
                        <a rel="nofollow" href="<webwork:url><webwork:param name="'view'" value="''" /><webwork:param name="'tempMax'" value="'-1'" /><webwork:param name="'decorator'" value="''" /></webwork:url>"><webwork:text name="'navigator.results.currentview.browser'"/></a>
                    </webwork:else>
                    <%-- all views for the issue navigator --%>


<%
    WebResourceManager webResourceManager = ComponentManager.getInstance().getWebResourceManager();
    webResourceManager.requireResource("jira.webresources:prototype", out);
    webResourceManager.requireResource("jira.webresources:scriptaculous", out);
    webResourceManager.requireResource("com.atlassian.jira.ext.charting:searchrequestview-includes", out);
%>
                    <script type="text/javascript">
                        lbContextPath = '<%=request.getContextPath()%>';
                    </script>

                    <span class="subText">
                        (
                        <strong><webwork:text name="'navigator.results.currentview.browser.current'"/></strong>
                        <webwork:if test="/printable != null">
                            | <a id="printable" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/printable/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.browser.printable'"/></a>
                        </webwork:if>
                        <webwork:if test="/fullContent != null">
                            | <a id="fullContent" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/fullContent/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.browser.full'"/></a>
                        </webwork:if>
                        )
                    </span>
                    <webwork:if test="/xml != null">
                        | <a id="xml" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/xml/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.xml'"/></a>
                    </webwork:if>

                    <webwork:if test="/rssIssues != null || /rssComments !=null">
                        | <webwork:text name="'navigator.results.currentview.rss'"/>
                        <span class="subText">
                            (
                            <webwork:if test="/rssIssues != null">
                                <a id="rssIssues" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/rssIssues/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.rss.issues'"/></a>
                            </webwork:if>
                            <webwork:if test="/rssIssues != null && /rssComments !=null">
                                |
                            </webwork:if>
                            <webwork:if test="/rssComments != null">
                                <a id="rssComments" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/rssComments/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.rss.comments'"/></a>
                            </webwork:if>
                            )
                        </span>
                    </webwork:if>
                    <webwork:if test="/word !=null">
                        | <a id="word" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/word/URLWithoutContextPath(/searchRequest)"/>&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.word'"/></a>
                    </webwork:if>
                    <webwork:if test="/allExcelFields !=null || /currentExcelFields !=null">
                        | <webwork:text name="'navigator.results.currentview.excel'"/>
                        <span class="subText">
                            (
                            <webwork:if test="/allExcelFields != null">
                                <a id="allExcelFields" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/allExcelFields/URLWithoutContextPath(/searchRequest)" />&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.excel.full'"/></a>
                            </webwork:if>
                            <webwork:if test="/allExcelFields !=null && /currentExcelFields !=null">
                            |
                            </webwork:if>
                            <webwork:if test="/currentExcelFields != null">
                                <a id="currentExcelFields" rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="/currentExcelFields/URLWithoutContextPath(/searchRequest)" />&amp;tempMax=1000"><webwork:text name="'navigator.results.currentview.excel.current'"/></a>
                            </webwork:if>
                            )
                        </span>
                    </webwork:if>
                    <!-- We don't want to show this link if you are not logged in since the charting plugin portlets do not show to non-->
                    <webwork:if test="/chart != null && /remoteUser != null" >
                        | <a id="charts" rel="nofollow" class="lbOn" onclick="return false;" href="<%= request.getContextPath() %><webwork:property value="/chart/URLWithoutContextPath(/searchRequest)" />"><webwork:text name="'navigator.results.currentview.charts'"/></a>
                    </webwork:if>
                    <webwork:iterator value="/searchRequestViews" >
                        | <a rel="nofollow" href="<%= request.getContextPath() %><webwork:property value="URLWithoutContextPath(/searchRequest)" />" ><webwork:property value="name" /></a>
                    </webwork:iterator>
                    <br>

                    <webwork:component name="'navigatorviews'" template="help.jsp">
                        <webwork:param name="'align'" value="'middle'"/>
                    </webwork:component>
                </td>
                <td valign="bottom" align="left" width="20%" nowrap>
                    <ul class="square">
                    <webwork:if test="hasBulkChangePermission == true">
                        <li>
                        <webwork:text name="'navigator.results.currentview.bulkchange'"/>
                        <a id="bulkedit_all" href="<webwork:url page="/secure/views/bulkedit/BulkEdit1!default.jspa"><webwork:param name="'reset'" value="'true'"/><webwork:param name="'tempMax'" value="/searchResults/total"/></webwork:url>"><webwork:text name="'navigator.results.currentview.bulkchange.allissues'"><webwork:param name="'value0'" value="/searchResults/total"/></webwork:text></a>
                        <%-- Show the 'All' link if there is more than one pager --%>
                        <webwork:if test="/searchResults/pages/size > 1">
                            | <a id="bulkedit_curr_pg" href="<webwork:url page="/secure/views/bulkedit/BulkEdit1!default.jspa"><webwork:param name="'reset'" value="'true'"/></webwork:url>"><webwork:text name="'navigator.results.currentview.bulkchange.currentpage'"/></a>
                        </webwork:if>
                        </li>
                    </webwork:if>

<%--                Columns related --%>
                    <webwork:if test="/remoteUser != null && /hasPermission('use')">
                        <li>
                        <webwork:if test="/showOverrideColumnLayout == false">
                            <webwork:text name="'navigator.results.configurenavigator'">
                                <webwork:param name="'value0'"><a href="<%= request.getContextPath() %>/secure/ViewUserIssueColumns!default.jspa"><b></webwork:param>
                                <webwork:param name="'value1'"></b></a></webwork:param>
                            </webwork:text>
                        </webwork:if>
                        <webwork:else>
                            <webwork:text name="'navigator.results.useyourcolumns'">
                                <webwork:param name="'value0'"><a href="<%= request.getContextPath() %>/secure/IssueNavigator!columnOverride.jspa"><b></webwork:param>
                                <webwork:param name="'value1'"></b></a></webwork:param>
                            </webwork:text>
                        </webwork:else>
                        </li>
                    </webwork:if>

                    <webwork:if test="/hasSearchRequestColumnLayout == true && /showOverrideColumnLayout == false">
                        <li>
                        <webwork:text name="'navigator.results.usefilterscolumns'">
                            <webwork:param name="'value0'"><a href="<%= request.getContextPath() %>/secure/IssueNavigator!columnOverride.jspa"><b></webwork:param>
                            <webwork:param name="'value1'"></b></a></webwork:param>
                        </webwork:text>
                        </li>
                    </webwork:if>
                    <% License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY);
                     if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
                    <webwork:if test="/searchRequest/id && /ownerOfSearchRequest == true">
                        <webwork:if test="/hasSearchRequestColumnLayout == true">
                            <webwork:if test="/showOverrideColumnLayout == true">
                                <li>
                                    <webwork:text name="'navigator.results.filter.columns.edit'">
                                        <webwork:param name="'value0'"><a id="editFilterColumnsLink" href="<webwork:url value="'ViewSearchRequestIssueColumns!default.jspa'"><webwork:param name="'filterId'" value="/searchRequest/id" /></webwork:url>"></webwork:param>
                                        <webwork:param name="'value1'"></a></webwork:param>
                                    </webwork:text>
                                </li>
                            </webwork:if>
                            <webwork:else>

                            </webwork:else>
                        </webwork:if>
                        <webwork:else>
                            <li>
                                 <webwork:text name="'navigator.results.filter.columns.add'">
                                     <webwork:param name="'value0'"><a id="addFilterColumnsLink" href="<webwork:url value="'ViewSearchRequestIssueColumns!default.jspa'"><webwork:param name="'filterId'" value="/searchRequest/id" /></webwork:url>"></webwork:param>
                                     <webwork:param name="'value1'"></a></webwork:param>
                                 </webwork:text>
                             </li>
                         </webwork:else>
                    </webwork:if>
                    <% } %>
                    </ul>
                </td>
            </tr>
        </table>
    </webwork:if>

</page:applyDecorator>
