<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/init.jsp" %>

<%
RedirectNotFoundEntriesDisplayContext redirectNotFoundEntriesDisplayContext = new RedirectNotFoundEntriesDisplayContext(request, liferayPortletRequest, liferayPortletResponse);

SearchContainer<RedirectNotFoundEntry> redirectNotFoundEntriesSearchContainer = redirectNotFoundEntriesDisplayContext.searchContainer();

RedirectNotFoundEntriesManagementToolbarDisplayContext redirectNotFoundEntriesManagementToolbarDisplayContext = new RedirectNotFoundEntriesManagementToolbarDisplayContext(request, liferayPortletRequest, liferayPortletResponse, redirectNotFoundEntriesSearchContainer);
%>

<clay:management-toolbar
	displayContext="<%= redirectNotFoundEntriesManagementToolbarDisplayContext %>"
/>

<aui:form action="<%= redirectNotFoundEntriesSearchContainer.getIteratorURL() %>" cssClass="container-fluid-1280" name="fm">

	<%
	List<RedirectNotFoundEntry> results = redirectNotFoundEntriesSearchContainer.getResults();
	%>

	<c:choose>
		<c:when test="<%= results.size() > 0 %>">
			<aui:input name="redirect" type="hidden" value="<%= currentURL %>" />
			<aui:input name="ignored" type="hidden" />

			<liferay-ui:search-container
				id="<%= redirectNotFoundEntriesDisplayContext.getSearchContainerId() %>"
				searchContainer="<%= redirectNotFoundEntriesSearchContainer %>"
			>
				<liferay-ui:search-container-row
					className="com.liferay.redirect.model.RedirectNotFoundEntry"
					keyProperty="redirectNotFoundEntryId"
					modelVar="redirectNotFoundEntry"
				>

					<%
					row.setData(
						HashMapBuilder.<String, Object>put(
							"actions", redirectNotFoundEntriesManagementToolbarDisplayContext.getAvailableActions(redirectNotFoundEntry)
						).build());
					%>

					<liferay-ui:search-container-column-text
						cssClass="table-cell-content"
						name="not-found-urls"
					>
						<%= HtmlUtil.escape(RedirectUtil.getGroupBaseURL(themeDisplay) + StringPool.SLASH + redirectNotFoundEntry.getUrl()) %>
					</liferay-ui:search-container-column-text>

					<c:if test='<%= StringUtil.equals("all", ParamUtil.getString(request, "filterType")) %>'>
						<liferay-ui:search-container-column-text
							cssClass="table-cell-minw-200 table-cell-smallest table-column-text-center"
							name="ignored-urls"
						>
							<c:if test="<%= redirectNotFoundEntry.isIgnored() %>">
								<clay:icon
									symbol="hidden"
								/>
							</c:if>
						</liferay-ui:search-container-column-text>
					</c:if>

					<liferay-ui:search-container-column-text
						cssClass="table-cell-expand-smallest table-column-text-end"
						name="requests"
					>
						<%= redirectNotFoundEntry.getRequestCount() %>
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text>
						<clay:dropdown-actions
							dropdownItems="<%= redirectNotFoundEntriesDisplayContext.getActionDropdownItems(redirectNotFoundEntry) %>"
						/>
					</liferay-ui:search-container-column-text>
				</liferay-ui:search-container-row>

				<liferay-ui:search-iterator
					markupView="lexicon"
					searchContainer="<%= redirectNotFoundEntriesSearchContainer %>"
				/>
			</liferay-ui:search-container>
		</c:when>
		<c:otherwise>
			<liferay-frontend:empty-result-message
				animationType="<%= EmptyResultMessageKeys.AnimationType.SEARCH %>"
				description="<%= LanguageUtil.get(request, redirectNotFoundEntriesSearchContainer.getEmptyResultsMessage()) %>"
				title='<%= LanguageUtil.get(request, "all-is-in-order") %>'
			/>
		</c:otherwise>
	</c:choose>
</aui:form>

<liferay-frontend:component
	componentId="<%= redirectNotFoundEntriesManagementToolbarDisplayContext.getDefaultEventHandler() %>"
	context="<%= redirectNotFoundEntriesManagementToolbarDisplayContext.getComponentContext() %>"
	module="js/RedirectNotFoundEntriesManagementToolbarDefaultEventHandler.es"
/>