Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-89227 #71457

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public class SoyTemplateResourcesProviderUtil {
public static List<TemplateResource> getBundleTemplateResources(
Bundle bundle, String templatePath) {

return _soyTemplateResourcesProvider.getBundleTemplateResources(
bundle, templatePath);
return _soyTemplateResourcesProvider.getAllTemplateResources();
}

@Reference(unbind = "-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ public String getAssetTypeTitle(SharingEntry sharingEntry, Locale locale)

public String getTitle(SharingEntry sharingEntry);

public boolean isVisible(SharingEntry sharingEntry) throws PortalException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package com.liferay.sharing.document.library.internal.servlet.taglib.ui;

import com.liferay.asset.kernel.AssetRendererFactoryRegistryUtil;
import com.liferay.asset.kernel.model.AssetEntry;
import com.liferay.asset.kernel.model.AssetRenderer;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.service.AssetEntryLocalService;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
Expand Down Expand Up @@ -63,6 +65,10 @@ public Collection<MenuItem> getSharingEntryMenuItems(
return Collections.emptyList();
}

if (!_isVisible(sharingEntry)) {
return Collections.emptyList();
}

return Collections.singleton(
_createDownloadMenuItem(sharingEntry, themeDisplay));
}
Expand Down Expand Up @@ -101,9 +107,23 @@ private AssetRenderer _getAssetEntryRenderer(SharingEntry sharingEntry)
return assetRendererFactory.getAssetRenderer(sharingEntry.getClassPK());
}

private boolean _isVisible(SharingEntry sharingEntry) {
AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(
sharingEntry.getClassNameId(), sharingEntry.getClassPK());

if ((assetEntry != null) && assetEntry.isVisible()) {
return true;
}

return false;
}

private static final Log _log = LogFactoryUtil.getLog(
FileEntrySharingEntryMenuItemContributor.class);

@Reference
private AssetEntryLocalService _assetEntryLocalService;

@Reference
private SharingPermission _sharingPermission;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ public boolean hasEditPermission(long classNameId, long classPK) {
return false;
}

public boolean isVisible(SharingEntry sharingEntry) throws PortalException {
SharingEntryInterpreter sharingEntryInterpreter =
_sharingEntryInterpreterFunction.apply(sharingEntry);

if (sharingEntryInterpreter == null) {
return false;
}

if (sharingEntryInterpreter.isVisible(sharingEntry)) {
return true;
}

return false;
}

public void populateResults(SearchContainer<SharingEntry> searchContainer) {
long classNameId = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.liferay.asset.kernel.model.AssetEntry;
import com.liferay.asset.kernel.model.AssetRenderer;
import com.liferay.asset.kernel.model.AssetRendererFactory;
import com.liferay.asset.kernel.service.AssetEntryLocalService;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.log.Log;
Expand Down Expand Up @@ -91,6 +92,25 @@ public String getTitle(SharingEntry sharingEntry) {
return StringPool.BLANK;
}

@Override
public boolean isVisible(SharingEntry sharingEntry) throws PortalException {
AssetRenderer assetRenderer = AssetRendererSharingUtil.getAssetRenderer(
sharingEntry);

if (!assetRenderer.isDisplayable()) {
return false;
}

AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(
sharingEntry.getClassNameId(), sharingEntry.getClassPK());

if ((assetEntry == null) || !assetEntry.isVisible()) {
return false;
}

return true;
}

@Activate
protected void activate() {
_assetRendererSharingEntryEditRenderer =
Expand All @@ -102,6 +122,9 @@ protected void activate() {
private static final Log _log = LogFactoryUtil.getLog(
AssetRendererSharingEntryInterpreter.class);

@Reference
private AssetEntryLocalService _assetEntryLocalService;

private AssetRendererSharingEntryEditRenderer
_assetRendererSharingEntryEditRenderer;
private AssetRendererSharingEntryViewRenderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sharedAssetsViewDisplayContext.populateResults(sharingEntriesSearchContainer);

<liferay-ui:search-container-column-text
cssClass="table-cell-content"
href="<%= rowURL %>"
href="<%= sharedAssetsViewDisplayContext.isVisible(sharingEntry) ? rowURL : null %>"
name="title"
orderable="<%= false %>"
value="<%= sharedAssetsViewDisplayContext.getTitle(sharingEntry) %>"
Expand All @@ -74,6 +74,18 @@ sharedAssetsViewDisplayContext.populateResults(sharingEntriesSearchContainer);
value="<%= sharedAssetsViewDisplayContext.getAssetTypeTitle(sharingEntry) %>"
/>

<liferay-ui:search-container-column-text
cssClass="table-cell-expand-smallest"
name="status"
orderable="<%= false %>"
>
<span class="label label-info">
<span class="label-item label-item-expand">
<%= sharedAssetsViewDisplayContext.isVisible(sharingEntry) ? LanguageUtil.get(request, "visible") : LanguageUtil.get(request, "not-visible") %>
</span>
</span>
</liferay-ui:search-container-column-text>

<liferay-ui:search-container-column-date
name="shared-date"
orderable="<%= false %>"
Expand Down