Skip to content

Commit

Permalink
Merge branch 'main' into 30923-relationship-field-listing-content-wit…
Browse files Browse the repository at this point in the history
…h-dynamic-columns
  • Loading branch information
nicobytes authored Dec 18, 2024
2 parents a1990af + 9bd0ce7 commit 4644fab
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 34 deletions.
4 changes: 2 additions & 2 deletions core-web/libs/dotcms-scss/shared/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ $success: $color-accessible-text-green;
--color-palette-primary-800: hsl(var(--color-primary-h) var(--color-primary-s) 27%);
--color-palette-primary-900: hsl(var(--color-primary-h) var(--color-primary-s) 21%);

--color-palette-primary-op-10: var(--color-palette-primary-op-10);
--color-palette-primary-op-10: hsla(var(--color-primary-h), var(--color-primary-s), 60%, 0.1);
--color-palette-primary-op-20: hsla(var(--color-primary-h), var(--color-primary-s), 60%, 0.2);
--color-palette-primary-op-30: hsla(var(--color-primary-h), var(--color-primary-s), 60%, 0.3);
--color-palette-primary-op-40: hsla(var(--color-primary-h), var(--color-primary-s), 60%, 0.4);
Expand Down Expand Up @@ -428,7 +428,7 @@ $success: $color-accessible-text-green;
--color-background: #3a3847;
--empty-message: "";

/* primeflex */
/* primeflex https://primeflex.org/theming */

--primary-100: var(--color-palette-primary-100);
--primary-200: var(--color-palette-primary-200);
Expand Down
13 changes: 13 additions & 0 deletions core-web/libs/portlets/edit-ema/portlet/src/lib/shared/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const MOCK_RESPONSE_HEADLESS: DotPageApiResponse = {
inode: '123-i',
canEdit: true,
canRead: true,
canSeeRules: true,
contentType: 'htmlpageasset',
canLock: true,
locked: false,
Expand Down Expand Up @@ -212,6 +213,7 @@ export const MOCK_RESPONSE_VTL: DotPageApiResponse = {
inode: '123-i',
canEdit: true,
canRead: true,
canSeeRules: true,
rendered: '<html><body><h1>Hello, World!</h1></body></html>',
contentType: 'htmlpageasset',
canLock: true,
Expand Down Expand Up @@ -427,6 +429,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -455,6 +458,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -483,6 +487,7 @@ export const PAGE_RESPONSE_BY_LANGUAGE_ID = {
inode: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'index',
liveInode: '1234',
stInode: '12345',
Expand Down Expand Up @@ -757,6 +762,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canLock: false,
isLocked: true,
Expand Down Expand Up @@ -785,6 +791,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canLock: true,
locked: true,
Expand All @@ -811,6 +818,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canEdit: false
},
Expand All @@ -836,6 +844,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: 'i-have-a-running-experiment',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>New Content - Hello World</div>',
canEdit: true
Expand All @@ -862,6 +871,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>New Content - Hello World</div>',
canEdit: true
Expand All @@ -888,6 +898,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
rendered: '<div>hello world</div>',
canEdit: true
Expand All @@ -914,6 +925,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
inode: PAGE_INODE_MOCK,
identifier: '123',
canRead: true,
canSeeRules: true,
pageURI: 'page-one',
canEdit: true
},
Expand All @@ -939,6 +951,7 @@ export const UVE_PAGE_RESPONSE_MAP = {
identifier: '123',
canEdit: true,
canRead: true,
canSeeRules: true,
pageURI: 'page-one'
},
site: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface DotPage {
inode: string;
canEdit: boolean;
canRead: boolean;
canSeeRules: boolean;
canLock?: boolean;
locked?: boolean;
lockedBy?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export const UVEStore = signalStore(
label: 'editema.editor.navbar.rules',
id: 'rules',
href: `rules/${page?.identifier}`,
isDisabled: !page?.canEdit || !isEnterpriseLicense
isDisabled:
!page?.canSeeRules || !page?.canEdit || !isEnterpriseLicense
},
{
iconURL: 'experiments',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ public void setLive ( final Versionable versionable ) throws DotDataException, D
newInfo.setLiveInode(versionable.getInode());
newInfo.setPublishDate(new Date());
versionableFactory.saveContentletVersionInfo( newInfo, true );

uniqueFieldValidationStrategyResolver.get().afterPublish(versionable.getInode());
} else {

final VersionInfo info = versionableFactory.getVersionInfo( versionable.getVersionId() );
Expand All @@ -534,8 +536,6 @@ public void setLive ( final Versionable versionable ) throws DotDataException, D
info.setLiveInode( versionable.getInode() );
this.versionableFactory.saveVersionInfo( info, true );
}

uniqueFieldValidationStrategyResolver.get().afterPublish(versionable.getInode());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ protected Map<String, Object> transform(final HTMLPageAsset page, final Map<Stri
map.put("canEdit", toolBox.permissionAPI.doesUserHavePermission(page, PermissionLevel.EDIT.getType(), user, false));
map.put("canRead", toolBox.permissionAPI.doesUserHavePermission(page, PermissionLevel.READ.getType(), user, false));
map.put("canLock", canLock(page, user));
map.put("canSeeRules", toolBox.permissionAPI.doesUserHavePermissions(page, "RULES: " + PermissionLevel.READ.getType(), user, false));


if(info.isPresent() && info.get().getLockedBy()!=null) {
map.put("lockedOn", info.get().getLockedOn());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<%@ page import="com.liferay.portal.language.LanguageUtil"%>
<%@ page import="java.util.stream.Collectors" %>
<%@ page import="com.dotcms.publisher.business.PublishQueueElementTransformer" %>
<%@ page import="com.dotcms.publisher.bundle.bean.Bundle" %>
<%@ page import="com.dotmarketing.exception.DotDataException" %>
<%@ page import="com.dotmarketing.util.Logger" %>
<%@ page import="com.liferay.util.StringPool" %>
<%@ page import="com.dotcms.publishing.FilterDescriptor" %>
<%@ include file="/html/portlet/ext/contentlet/publishing/init.jsp" %>
<%
final int MAX_ASSETS_TO_SHOW = 3;
Expand Down Expand Up @@ -288,6 +293,7 @@


<th nowrap="nowrap" ><strong><%= LanguageUtil.get(pageContext, "publisher_Identifier") %></strong></th>
<th nowrap="nowrap" ><strong><%= LanguageUtil.get(pageContext, "Filter") %></strong></th>
<th style="width:100%" nowrap="nowrap" ><strong><%= LanguageUtil.get(pageContext, "publisher_Contents") %></strong></th>
<th style="width:100px" nowrap="nowrap" ><strong><%= LanguageUtil.get(pageContext, "publisher_Status") %></strong></th>
<th style="width:40px" nowrap="nowrap" ><strong><%= LanguageUtil.get(pageContext, "publisher_Date_Entered") %></strong></th>
Expand Down Expand Up @@ -322,6 +328,18 @@
}
shortBundleId.append("-").append(bundleIdParts[i]);
}
String filterName = "";
try {
final Bundle bundle = APILocator.getBundleAPI().getBundleById(c.getBundleId());
if ( UtilMethods.isSet(bundle) && UtilMethods.isSet(bundle.getFilterKey()) ) {
final FilterDescriptor filterDescriptor =
APILocator.getPublisherAPI().getFilterDescriptorByKey(bundle.getFilterKey());
filterName = filterDescriptor != null ? filterDescriptor.getTitle() : "";
}
} catch (DotDataException e) {
Logger.error(this, "Error getting bundle id: " + c.getBundleId(), e);
}
%>
<tr <%=errorclass%>>
<td style="width:30px;text-align:center;" valign="top">
Expand All @@ -336,7 +354,11 @@
<td valign="top" nowrap="nowrap" style="cursor: pointer" onclick="javascript: showDetail('<%=c.getBundleId()%>')">
<%=shortBundleId.toString()%>
</td>
<%--BundleTitle--%>
<%--BundleFilter--%>
<td valign="top" nowrap="nowrap" style="cursor: pointer" onclick="javascript: showDetail('<%=c.getBundleId()%>')">
<%= filterName %>
</td>
<%--BundleContents--%>
<%try{ %>
<% if(bundleAssets.keySet().size()>0){ %>
<td valign="top" style="cursor: pointer" onclick="showDetail('<%=c.getBundleId()%>', event)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.dotcms.IntegrationTestBase;
import com.dotcms.api.web.HttpServletRequestThreadLocal;
import com.dotcms.content.elasticsearch.ESQueryCache;
import com.dotcms.content.elasticsearch.business.ESContentletAPIImpl;
import com.dotcms.contenttype.model.type.ContentType;
import com.dotcms.datagen.*;
import com.dotcms.rendering.velocity.viewtools.DotTemplateTool;
Expand Down Expand Up @@ -63,6 +64,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.quartz.JobExecutionException;

import javax.servlet.http.HttpServletRequest;

Expand Down Expand Up @@ -317,6 +319,39 @@ public void publishTemplate_expects_live_true() throws Exception {
assertTrue(templateSaved.isLive());
}


/**
* Method to test: {@link TemplateAPIImpl#publishTemplate(Template, User, boolean)}
* When: Publish a Template with the UniqueField Database Validation set to true
* should: Template should be live true
*/
@Test
public void publishTemplateWithUniqueFieldDatbaseValidationEnabled() throws Exception {
final boolean oldEnabledDataBaseValidation = ESContentletAPIImpl.getFeatureFlagDbUniqueFieldValidation();

try {
ESContentletAPIImpl.setFeatureFlagDbUniqueFieldValidation(true);
final Host host = hostAPI.findDefaultHost(user, false);
final String body = "<html><body> I'm mostly empty </body></html>";
final String title = "empty test template " + UUIDGenerator.generateUuid();
final Template template = new Template();
template.setTitle(title);
template.setBody(body);
final Template templateSaved = templateAPI.saveTemplate(template, host, user, false);
assertTrue(UtilMethods.isSet(templateSaved.getInode()));
assertTrue(UtilMethods.isSet(templateSaved.getIdentifier()));
assertEquals(templateSaved.getBody(), body);
assertEquals(templateSaved.getTitle(), title);
assertFalse(templateSaved.isLive());

templateAPI.publishTemplate(templateSaved, user, false);
assertTrue(templateSaved.isLive());
} finally {

ESContentletAPIImpl.setFeatureFlagDbUniqueFieldValidation(oldEnabledDataBaseValidation);
}
}

/**
* Method to test: unpublishTemplate
* Given Scenario: Create a template, publish and unpublish it
Expand Down
5 changes: 5 additions & 0 deletions e2e/dotcms-e2e-node/frontend/locators/globalLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const contentGeneric = {
label: "Content (Generic)"
}

export const fileAsset = {
locator: "attach_fileFile Asset",
label: "File Asset"
}

export {
} from './navigation/menuLocators';

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@ export const contentProperties = {
deleteWfAction: "Delete"
}

export const fileAssetContent = {
title: "File Asset title",
body: "This is a sample file asset content",
fromURL:"https://upload.wikimedia.org/wikipedia/commons/0/03/DotCMS-logo.svg",
newFileName:"New file asset",
newFileText:"This is a new file asset content",
host:"default"
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {expect, test} from '@playwright/test';
import {expect, Page, test} from '@playwright/test';
import {dotCMSUtils, waitForVisibleAndCallback} from '../../utils/dotCMSUtils';
import {
GroupEntriesLocators,
MenuEntriesLocators,
ToolEntriesLocators
} from '../../locators/navigation/menuLocators';
import {ContentUtils} from "../../utils/contentUtils";
import {iFramesLocators, contentGeneric} from "../../locators/globalLocators";
import {genericContent1, contentProperties} from "./contentData";
import {iFramesLocators, contentGeneric, fileAsset} from "../../locators/globalLocators";
import {genericContent1, contentProperties, fileAssetContent} from "./contentData";
import {assert} from "console";

const cmsUtils = new dotCMSUtils();
Expand Down Expand Up @@ -35,14 +35,18 @@ test.beforeEach('Navigate to content portlet', async ({page}) => {
await waitForVisibleAndCallback(breadcrumbLocator, () => expect(breadcrumbLocator).toContainText('Search All'));
});


/**
* test to add a new piece of content (generic content)
*/
test('Add a new pice of content', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe);

// Adding new rich text content
await contentUtils.addNewContentAction(page, contentGeneric.locator, contentGeneric.label);
await contentUtils.fillRichTextForm(page, genericContent1.title, genericContent1.body, contentProperties.publishWfAction);
await contentUtils.workflowExecutionValidationAndClose(page, 'Content saved');

await waitForVisibleAndCallback(iframe.locator('#results_table tbody tr').first(), async () => {});

await contentUtils.validateContentExist(page, genericContent1.title).then(assert);
Expand Down Expand Up @@ -73,5 +77,44 @@ test('Delete a piece of content', async ({ page }) => {
}
);

/**
* Test to make sure we are validating the required of text fields on the content creation
* */
test('Validate required on text fields', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe).first();

await contentUtils.addNewContentAction(page, contentGeneric.locator, contentGeneric.label);
await contentUtils.fillRichTextForm(page, '', genericContent1.body, contentProperties.publishWfAction);
await expect(iframe.getByText('Error x')).toBeVisible();
await expect(iframe.getByText('The field Title is required.')).toBeVisible();
});

/** Please enable after fixing the issue #30748
* Test to make sure we are validating the required of blockEditor fields on the content creation
*/
/**
test('Validate required on blockContent fields', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe).first();
await contentUtils.addNewContentAction(page, contentGeneric.locator, contentGeneric.label);
await contentUtils.fillRichTextForm(page, genericContent1.title, '', contentProperties.publishWfAction);
await expect(iframe.getByText('Error x')).toBeVisible();
await expect(iframe.getByText('The field Title is required.')).toBeVisible();
});
*/

/**
* Test to validate you are able to add file assets importing from url
*/
test('Validate you are able to add file assets importing from url', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe);

await contentUtils.addNewContentAction(page, fileAsset.locator, fileAsset.label);
await contentUtils.fillFileAssetForm(page, fileAssetContent.host, fileAssetContent.title, contentProperties.publishWfAction, null, fileAssetContent.fromURL );
//fileName?: string, fromURL?: string, newFileName?: string, newFileText?: string) {
await contentUtils.workflowExecutionValidationAndClose(page, 'Content saved');
await contentUtils.validateContentExist(page, fileAssetContent.title).then(assert);
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test('Search filter', async ({page}) => {
// Adding new rich text content
await contentUtils.addNewContentAction(page, contentGeneric.locator, contentGeneric.label);
await contentUtils.fillRichTextForm(page, genericContent1.title, genericContent1.body, contentProperties.publishWfAction);
await contentUtils.workflowExecutionValidationAndClose(page, 'Content saved');

// Validate the content has been created
await expect.soft(iframe.getByRole('link', {name: genericContent1.title}).first()).toBeVisible();
Expand Down
Loading

0 comments on commit 4644fab

Please sign in to comment.