com.liferay.fragment.web.internal.display.context.GroupFragmentEntryUsageManagementToolbarDisplayContext Maven / Gradle / Ivy
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.fragment.web.internal.display.context;
import com.liferay.fragment.constants.FragmentActionKeys;
import com.liferay.fragment.web.internal.security.permission.resource.FragmentPermission;
import com.liferay.frontend.taglib.clay.servlet.taglib.display.context.SearchContainerManagementToolbarDisplayContext;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.DropdownItem;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.DropdownItemListBuilder;
import com.liferay.portal.kernel.dao.search.SearchContainer;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.WebKeys;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
/**
* @author Jürgen Kappler
*/
public class GroupFragmentEntryUsageManagementToolbarDisplayContext
extends SearchContainerManagementToolbarDisplayContext {
public GroupFragmentEntryUsageManagementToolbarDisplayContext(
HttpServletRequest httpServletRequest,
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse,
SearchContainer searchContainer) {
super(
httpServletRequest, liferayPortletRequest, liferayPortletResponse,
searchContainer);
}
@Override
public List getActionDropdownItems() {
ThemeDisplay themeDisplay =
(ThemeDisplay)httpServletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
return DropdownItemListBuilder.add(
() -> FragmentPermission.contains(
themeDisplay.getPermissionChecker(),
themeDisplay.getScopeGroupId(),
FragmentActionKeys.MANAGE_FRAGMENT_ENTRIES),
dropdownItem -> {
dropdownItem.putData("action", "propagate");
dropdownItem.setIcon("propagation");
dropdownItem.setLabel(
LanguageUtil.get(httpServletRequest, "propagate"));
dropdownItem.setQuickAction(true);
}
).build();
}
@Override
public String getComponentId() {
return "groupFragmentEntryUsageManagementToolbar";
}
@Override
protected String[] getOrderByKeys() {
return new String[] {"name"};
}
}