Skip to content

Commit

Permalink
Hide content type in cotf which are hidden by config (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
dew326 authored Feb 1, 2022
1 parent 74355d5 commit 484c1f9
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ const ContentCreateWidget = () => {
const selectLanguageLabel = Translator.trans(
/*@Desc("Select a language")*/ 'create_content.select_language',
{},
'universal_discovery_widget'
'universal_discovery_widget',
);
const selectContentType = Translator.trans(
/*@Desc("Select a Content Type")*/ 'create_content.select_content_type',
{},
'universal_discovery_widget'
'universal_discovery_widget',
);
const createLabel = Translator.trans(/*@Desc("Create new")*/ 'create_content.create', {}, 'universal_discovery_widget');
const closeLabel = Translator.trans(/*@Desc("Close")*/ 'popup.close.label', {}, 'universal_discovery_widget');
Expand All @@ -79,12 +79,12 @@ const ContentCreateWidget = () => {
const filtersDescLabel = Translator.trans(
/*@Desc("Or choose from list")*/ 'content.create.filters.desc',
{},
'universal_discovery_widget'
'universal_discovery_widget',
);
const createUnderLabel = Translator.trans(
/*@Desc("under %content_name%")*/ 'content.create.editing_details',
{ content_name: selectedLocation?.location?.ContentInfo.Content.TranslatedName },
'universal_discovery_widget'
'universal_discovery_widget',
);
const widgetClassName = createCssClassNames({
'ibexa-extra-actions': true,
Expand Down Expand Up @@ -114,7 +114,8 @@ const ContentCreateWidget = () => {
className="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--close"
onClick={close}
title={closeLabel}
data-tooltip-container-selector=".c-udw-tab">
data-tooltip-container-selector=".c-udw-tab"
>
<Icon name="discard" extraClasses="ibexa-icon--small" />
</button>
<div className="ibexa-extra-actions__header-subtitle">{createUnderLabel}</div>
Expand Down Expand Up @@ -154,8 +155,9 @@ const ContentCreateWidget = () => {
restrictedContentTypeIds.length && !restrictedContentTypeIds.includes(groupItem.id.toString());
const isNotAllowedContentType =
allowedContentTypes && !allowedContentTypes.includes(groupItem.identifier);
const isHiddenByConfig = groupItem.isHidden;

return isNotSearchedName || hasNotPermission || isNotAllowedContentType;
return isNotSearchedName || hasNotPermission || isNotAllowedContentType || isHiddenByConfig;
});

if (isHidden) {
Expand All @@ -165,14 +167,15 @@ const ContentCreateWidget = () => {
return (
<div className="ibexa-instant-filter__group" key={groupName}>
<div className="ibexa-instant-filter__group-name">{groupName}</div>
{groupItems.map(({ name, thumbnail, identifier, id }) => {
{groupItems.map(({ name, thumbnail, identifier, id, isHidden: isHiddenByConfig }) => {
const isHidden =
isHiddenByConfig ||
(filterQuery && !name.toLowerCase().includes(filterQuery)) ||
(selectedLocation &&
selectedLocation.permissions &&
selectedLocation.permissions.create.restrictedContentTypeIds.length &&
!selectedLocation.permissions.create.restrictedContentTypeIds.includes(
id.toString()
id.toString(),
)) ||
(allowedContentTypes && !allowedContentTypes.includes(identifier));
const className = createCssClassNames({
Expand All @@ -190,7 +193,8 @@ const ContentCreateWidget = () => {
hidden={isHidden}
key={identifier}
className={className}
onClick={updateSelectedContentType}>
onClick={updateSelectedContentType}
>
<Icon customPath={thumbnail} extraClasses="ibexa-icon--small" />
<div className="form-check">
<div className="ibexa-label ibexa-label--checkbox-radio form-check-label">
Expand All @@ -210,7 +214,8 @@ const ContentCreateWidget = () => {
<button
className="c-content-create__confirm-button btn ibexa-btn ibexa-btn--primary"
onClick={createContent}
disabled={isConfirmDisabled}>
disabled={isConfirmDisabled}
>
{createLabel}
</button>
<button className="btn ibexa-btn ibexa-btn--secondary" onClick={close}>
Expand Down

0 comments on commit 484c1f9

Please sign in to comment.