Skip to content

Commit

Permalink
LPS-110059 Add "Permissions" action to entry dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfopa committed Mar 10, 2020
1 parent b9d8be0 commit a467732
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Expand Up @@ -92,6 +92,21 @@ public List<DropdownItem> getActionDropdownItems() {
_httpServletRequest, "delete"));
});
}

if (_hasPermissionsPermission()) {
add(
dropdownItem -> {
dropdownItem.putData(
"action", "permissionsDepotEntry");
dropdownItem.putData(
"permissionsDepotEntryURL",
DepotEntryURLUtil.getDepotEntryPermissionsURL(
_depotEntry, _liferayPortletRequest));
dropdownItem.setLabel(
LanguageUtil.get(
_httpServletRequest, "permissions"));
});
}
}
};

Expand All @@ -118,6 +133,22 @@ private boolean _hasDeletePermission() {
}
}

private boolean _hasPermissionsPermission() {
try {
if (!DepotEntryPermission.contains(
_themeDisplay.getPermissionChecker(),
_depotEntry.getDepotEntryId(), ActionKeys.PERMISSIONS)) {

return false;
}

return true;
}
catch (PortalException portalException) {
throw new SystemException(portalException);
}
}

private boolean _hasUpdatePermission() {
try {
return DepotEntryPermission.contains(
Expand Down
Expand Up @@ -16,9 +16,13 @@

import com.liferay.depot.model.DepotEntry;
import com.liferay.depot.web.internal.constants.DepotPortletKeys;
import com.liferay.petra.string.StringPool;
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.portlet.LiferayWindowState;
import com.liferay.portal.kernel.util.PortalUtil;
import com.liferay.taglib.security.PermissionsURLTag;

import javax.portlet.ActionRequest;
import javax.portlet.ActionURL;
Expand Down Expand Up @@ -58,6 +62,19 @@ public static ActionURL getDeleteDepotEntryActionURL(
return deleteDepotEntryActionURL;
}

public static String getDepotEntryPermissionsURL(
DepotEntry depotEntry, LiferayPortletRequest liferayPortletRequest)
throws Exception {

Group group = depotEntry.getGroup();

return PermissionsURLTag.doTag(
StringPool.BLANK, DepotEntry.class.getName(), group.getName(), null,
String.valueOf(depotEntry.getDepotEntryId()),
LiferayWindowState.POP_UP.toString(), null,
liferayPortletRequest.getHttpServletRequest());
}

public static ActionURL getDisconnectSiteActionURL(
long depotEntryGroupRelId, String redirect,
LiferayPortletResponse liferayPortletResponse) {
Expand Down
Expand Up @@ -22,6 +22,27 @@ class DepotEntryDropdownDefaultEventHandler extends DefaultEventHandler {
submitForm(document.hrefFm, itemData.deleteDepotEntryURL);
}
}

permissionsDepotEntry(itemData) {
this._openWindow(
Liferay.Language.get('permissions'),
itemData.permissionsDepotEntryURL
);
}

_openWindow(label, url) {
Liferay.Util.openWindow({
dialog: {
destroyOnHide: true,
modal: true,
},
dialogIframe: {
bodyCssClass: 'dialog-with-footer',
},
title: Liferay.Language.get(label),
uri: url,
});
}
}

export default DepotEntryDropdownDefaultEventHandler;

0 comments on commit a467732

Please sign in to comment.