<%--
/**
 * 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" %>

<%
List<LayoutSetBranch> layoutSetBranches = LayoutSetBranchLocalServiceUtil.getLayoutSetBranches(stagingGroup.getGroupId(), privateLayout);

LayoutSetBranch currentLayoutSetBranch = LayoutSetBranchLocalServiceUtil.getUserLayoutSetBranch(themeDisplay.getUserId(), stagingGroup.getGroupId(), privateLayout, 0, 0);

request.setAttribute("view_layout_set_branches.jsp-currentLayoutSetBranchId", String.valueOf(currentLayoutSetBranch.getLayoutSetBranchId()));
%>

<liferay-util:include page="/navigation.jsp" servletContext="<%= application %>">
	<liferay-util:param name="navigationName" value="site-pages-variation" />
</liferay-util:include>

<clay:container-fluid>
	<liferay-ui:success key="sitePageVariationAdded" message="site-page-variation-was-added" />
	<liferay-ui:success key="sitePageVariationDeleted" message="site-page-variation-was-deleted" />
	<liferay-ui:success key="sitePageVariationMerged" message="site-page-variation-was-merged" />
	<liferay-ui:success key="sitePageVariationUpdated" message="site-page-variation-was-updated" />

	<div class="lfr-alert-container"></div>

	<c:if test="<%= GroupPermissionUtil.contains(permissionChecker, stagingGroup, ActionKeys.ADD_LAYOUT_SET_BRANCH) %>">
		<liferay-portlet:renderURL var="addLayoutSetBranchURL">
			<portlet:param name="mvcRenderCommandName" value="editLayoutSetBranch" />
			<portlet:param name="redirect" value="<%= currentURL %>" />
		</liferay-portlet:renderURL>

		<aui:button-row>
			<aui:button href="<%= addLayoutSetBranchURL %>" name="addBranchButton" value="add-site-pages-variation" />
		</aui:button-row>
	</c:if>

	<div class="branch-results">
		<liferay-ui:search-container
			total="<%= layoutSetBranches.size() %>"
		>
			<liferay-ui:search-container-results
				results="<%= layoutSetBranches %>"
			/>

			<liferay-ui:search-container-row
				className="com.liferay.portal.kernel.model.LayoutSetBranch"
				escapedModel="<%= true %>"
				keyProperty="layoutSetBranchId"
				modelVar="curLayoutSetBranch"
			>
				<liferay-ui:search-container-column-text
					name="name"
				>
					<c:if test="<%= currentLayoutSetBranch.equals(curLayoutSetBranch) %>">
						<strong>
					</c:if>

					<liferay-ui:message key="<%= layoutSetBranchDisplayContext.getLayoutSetBranchDisplayName(curLayoutSetBranch) %>" localizeKey="<%= false %>" />

					<c:if test="<%= curLayoutSetBranch.isMaster() %>">
						<i class="icon-asterisk"></i>
					</c:if>

					<c:if test="<%= currentLayoutSetBranch.equals(curLayoutSetBranch) %>">
						</strong>
					</c:if>
				</liferay-ui:search-container-column-text>

				<liferay-ui:search-container-column-text
					property="description"
				/>

				<liferay-ui:search-container-column-jsp
					align="right"
					cssClass="entry-action"
					path="/layout_set_branch_action.jsp"
				/>
			</liferay-ui:search-container-row>

			<liferay-ui:search-iterator
				markupView="lexicon"
				paginate="<%= false %>"
				searchContainer="<%= searchContainer %>"
			/>
		</liferay-ui:search-container>
	</div>
</clay:container-fluid>

<aui:script use="liferay-staging-branch">
	Liferay.StagingBar.init({
		namespace: '<portlet:namespace />',
		portletId: '<%= portletDisplay.getId() %>',
	});
</aui:script>