<%@ page import="com.atlassian.license.License,
                 com.atlassian.license.LicenseManager"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="jiratags" prefix="jira" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>

<html>
<head>
	<title><webwork:text name="'common.concepts.managefilters'"/></title>
</head>

<body>

<table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td class="filterSummaryCell">
    <jsp:include page="/includes/navigator/summary-pane.jsp" />
</td>
<td bgcolor=ffffff valign=top>

<table width="100%" cellpadding=10 cellspacing=0 border=0><tr><td>

<page:applyDecorator name="jirapanel">
    <page:param name="title"><webwork:text name="'common.concepts.managefilters'"/></page:param>
    <page:param name="description">
        <webwork:text name="'managefilters.desc'"/>
    </page:param>
    <page:param name="width">100%</page:param>
</page:applyDecorator>

<p></p>
<webwork:property value="remoteUser">
<webwork:if test=". != null">
<table width="100%" bgcolor="bbbbbb" border="0" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
	<tr bgcolor=f0f0f0>
        <td class="colHeaderLink" width="50%">
			<b><webwork:text name="'managefilters.yourfilters'"/></b>
		</td>
		<td class="colHeaderLink" width="5%">
			<b><webwork:text name="'common.concepts.issues'"/></b>
		</td>
        <% License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY);
        if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
            <td class="colHeaderLink" width="10%">
                <b><webwork:text name="'managefilters.sharing'"/></b>
            </td>
        <% } %>
		<td class="colHeaderLink" width="15%">
			<b><webwork:text name="'managefilters.subscription'"/></b>
		</td>
        <td class="colHeaderLink" width="20%">
			<b><webwork:text name="'common.words.operations'"/></b>
		</td>
	</tr>

    <webwork:if test="myFilters != null && myFilters/size > 0">
        <webwork:iterator value="myFilters" status="'myStatus'">
        <tr bgcolor="#<webwork:if test="@myStatus/modulus(2) == 1">ffffff</webwork:if><webwork:else>fffff0</webwork:else>">
            <td><a href="<webwork:url value="'IssueNavigator.jspa?mode=hide'"><webwork:param name="'requestId'" value="long('id')" /></webwork:url>"><webwork:property value="string('name')"/></a>
            <webwork:if test="string('description') != null && string('description')/length > 0">
                <br>
                <font size=1>
                    <webwork:property value="string('description')"/>
                </font>
            </webwork:if>
            </td>
            <td width="1%">
                &nbsp;<a href="<webwork:url value="'IssueNavigator.jspa?mode=hide'"><webwork:param name="'requestId'" value="long('id')" /></webwork:url>"><webwork:property value="/countsForFilter(.)" /></a>
            </td>
            <% if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
                <td>
                    <table cellpadding=0 cellspacing=0 border=0><tr>
                    <td><%@ include file="/includes/icons/shared.jsp" %></td>
                    <td>
                        <webwork:if test="string('author') == string('user')" ><webwork:text name="'managefilters.private'"/></webwork:if>
                        <webwork:elseIf test="string('group') == null" ><webwork:text name="'managefilters.global'"/></webwork:elseIf>
                        <webwork:else><webwork:text name="'managefilters.group'"/>:<webwork:property value="string('group')"/></webwork:else>
                    </td>
                    </tr></table>
                </td>
            <% } %>
            <td nowrap>
                <%@ include file="/includes/panels/managefilters_subscription.jsp" %>
            </td>
            <td nowrap>
                <a href="<webwork:url value="'IssueNavigator.jspa?mode=hide'"><webwork:param name="'requestId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.view'"/></a>
                    | <a href="<webwork:url value="'IssueNavigator.jspa?mode=show'"><webwork:param name="'requestId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.edit'"/></a>
                    | <a id="delete_<webwork:property value = "string('name')"/>" href="<webwork:url value="'DeleteFilter!default.jspa'"><webwork:param name="'filterId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.delete'"/></a>
                    <%-- Shared filters are not available in Standard Edition --%>
                    <% if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
                        <webwork:if test="hasPermissionOnFilter('sharefilters',.) == true">
                            | <a href="<webwork:url value="'ShareFilter!default.jspa'"><webwork:param name="'requestId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.share'"/></a>
                        </webwork:if>
                    <% } %>
                    <%-- Serach Request column layouts are only available in Enterprise Version --%>
                    <% if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
                        <webwork:if test="/usingDefaultColumns(./long('id')) == true">
                            | <a id="colOrder_<webwork:property value = "string('name')"/>" href="<webwork:url value="'ViewSearchRequestIssueColumns!default.jspa'"><webwork:param name="'filterId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.addcolumns'"/></a>
                        </webwork:if>
                        <webwork:else>
                            | <a id="colOrder_<webwork:property value = "string('name')"/>" href="<webwork:url value="'ViewSearchRequestIssueColumns!default.jspa'"><webwork:param name="'filterId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.editcolumns'"/></a>
                        </webwork:else>
                    <% } %>
                    <% if (license !=null && !license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
                        <webwork:if test="subscriptions(.) && subscriptions(.)/empty == false">
                            | <a href="<webwork:url value="'ViewSubscriptions.jspa'"><webwork:param name="'filterId'" value="long('id')" /></webwork:url>"><webwork:text name="'subscriptions.edit'"/></a>
                        </webwork:if>
                        <webwork:else>
                            | <a href="<webwork:url value="'FilterSubscription!default.jspa'"><webwork:param name="'filterId'" value="long('id')" /></webwork:url>"><webwork:text name="'managefilters.subscribe'"/></a>
                        </webwork:else>
                    <% } %>
            </td>
        </tr>
        </webwork:iterator>
    </webwork:if>
    <webwork:else>
        <tr>
            <td colspan=5 bgcolor=ffffff>
                <webwork:text name="'managefilters.nosavedfilters'"/>
                <p>
                <webwork:text name="'managefilters.createnew'">
                    <webwork:param name="'value0'"><a href="<%= request.getContextPath() %>/secure/IssueNavigator.jspa?mode=show&createNew=true"></webwork:param>
                    <webwork:param name="'value1'"></a></webwork:param>
                </webwork:text>
            </td>
        </tr>
    </webwork:else>
    </table>
</td></tr></table>
</webwork:if>

<% License license = LicenseManager.getInstance().getLicense(JiraLicenseUtils.JIRA_LICENSE_KEY);
if (license !=null && license.isLicenseLevel(EasyList.build(JiraLicenseUtils.JIRA_PROFESSIONAL_LEVEL, JiraLicenseUtils.JIRA_ENTERPRISE_LEVEL))) { %>
<p></p>

<jsp:include page="/includes/panels/filter/managefilters_shared.jsp" />
<% } %>

</webwork:property>

</td></tr></table>
</td></tr></table>

</body>
</html>

