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

LPD-45710 Update poshi tests #157990

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 @@ -207,6 +207,20 @@ public JSONArray getLayoutsJSONArray(
JSONUtil.put(
"active",
_layoutsAdminDisplayContext.isActive(layout.getPlid())
).put(
"addChildLayoutURL",
() -> {
if (_layoutsAdminDisplayContext.
isShowAddChildPageAction(layout)) {

return _layoutsAdminDisplayContext.
getSelectLayoutPageTemplateEntryURL(
0, layout.getPlid(),
layout.isPrivateLayout());
}

return null;
}
).put(
"bulkActions",
StringUtil.merge(
Expand Down Expand Up @@ -271,7 +285,7 @@ public JSONArray getLayoutsJSONArray(
return layoutType.isParentable();
}
).put(
"quickActions", _getQuickActionsJSONArray(layout)
"quickActions", JSONFactoryUtil.createJSONArray()
).put(
"selectable", true
).put(
Expand Down Expand Up @@ -302,43 +316,6 @@ public JSONArray getLayoutsJSONArray(
return layoutsJSONArray;
}

private JSONObject _getAddChildPageActionJSONObject(
Layout layout, String actionType) {

return JSONUtil.put(
actionType, true
).put(
"icon", "plus"
).put(
"id", "add"
).put(
"label", LanguageUtil.get(_httpServletRequest, "add-page")
).put(
"url",
_layoutsAdminDisplayContext.getSelectLayoutPageTemplateEntryURL(
0, layout.getPlid(), layout.isPrivateLayout())
);
}

private JSONObject _getAddRootLayoutActionJSONObject(
boolean privatePages, String actionType)
throws Exception {

return JSONUtil.put(
actionType, true
).put(
"icon", "plus"
).put(
"id", "add"
).put(
"label", LanguageUtil.get(_httpServletRequest, "add-page")
).put(
"url",
_layoutsAdminDisplayContext.getSelectLayoutPageTemplateEntryURL(
privatePages)
);
}

private JSONArray _getBreadcrumbEntriesJSONArray() throws Exception {
JSONArray breadcrumbEntriesJSONArray =
JSONFactoryUtil.createJSONArray();
Expand Down Expand Up @@ -455,6 +432,16 @@ private JSONObject _getFirstLayoutColumnJSONObject(

return JSONUtil.put(
"active", active
).put(
"addChildLayoutURL",
() -> {
if (_layoutsAdminDisplayContext.isShowAddRootLayoutButton()) {
return _layoutsAdminDisplayContext.
getSelectLayoutPageTemplateEntryURL(privatePages);
}

return null;
}
).put(
"hasChild", true
).put(
Expand Down Expand Up @@ -486,12 +473,6 @@ private JSONArray _getFirstLayoutColumnQuickActionsJSONArray(

JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

if (_layoutsAdminDisplayContext.isShowAddRootLayoutButton()) {
jsonArray.put(
_getAddRootLayoutActionJSONObject(
privatePages, "layoutAction"));
}

if (_layoutsAdminDisplayContext.isShowFirstColumnConfigureAction()) {
jsonArray.put(
JSONUtil.put(
Expand Down Expand Up @@ -630,19 +611,6 @@ private String _getMoveLayoutColumnItemURL() {
).buildString();
}

private JSONArray _getQuickActionsJSONArray(Layout layout)
throws Exception {

JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

if (_layoutsAdminDisplayContext.isShowAddChildPageAction(layout)) {
jsonArray.put(
_getAddChildPageActionJSONObject(layout, "layoutAction"));
}

return jsonArray;
}

private boolean _hasScopeGroup(Layout layout) throws Exception {
if (layout.hasScopeGroup()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import ClayButton, {ClayButtonWithIcon} from '@clayui/button';
import ClayDropDown, {ClayDropDownWithItems} from '@clayui/drop-down';
import {ClayDropDownWithItems} from '@clayui/drop-down';
import {ClayCheckbox} from '@clayui/form';
import ClayIcon from '@clayui/icon';
import ClayLabel from '@clayui/label';
Expand Down Expand Up @@ -120,6 +120,7 @@ const MillerColumnsItem = ({
}) => {
const {
active,
addChildLayoutURL,
bulkActions = [],
checked,
description,
Expand Down Expand Up @@ -148,8 +149,6 @@ const MillerColumnsItem = ({

const [dropPosition, setDropPosition] = useState();

const [layoutActionsActive, setLayoutActionsActive] = useState(false);

const [itemActionsActive, setItemActionsActive] = useState(false);

const [dropdownActions, setDropdownActions] = useState([]);
Expand Down Expand Up @@ -227,12 +226,6 @@ const MillerColumnsItem = ({
}
}

const layoutActions = useMemo(() => {
return quickActions.filter(
(action) => action.layoutAction && action.url
);
}, [quickActions]);

const normalizedQuickActions = useMemo(() => {
return quickActions.filter(
(action) => action.quickAction && action.url
Expand Down Expand Up @@ -381,9 +374,7 @@ const MillerColumnsItem = ({
})}
containerElement="li"
data-actions={bulkActions}
onKeyDown={
layoutActionsActive || itemActionsActive ? null : onKeyDown
}
onKeyDown={itemActionsActive ? null : onKeyDown}
ref={ref}
role="none"
verticalAlign="center"
Expand Down Expand Up @@ -528,45 +519,21 @@ const MillerColumnsItem = ({
)}
</ClayLayout.ContentCol>

{!!layoutActions.length && (
{addChildLayoutURL ? (
<ClayLayout.ContentCol className="miller-columns-item-actions">
<ClayDropDown
active={layoutActionsActive}
onActiveChange={setLayoutActionsActive}
onKeyDown={(event) => event.stopPropagation()}
renderMenuOnClick
trigger={
<ClayButtonWithIcon
aria-label={Liferay.Language.get(
'add-child-page'
)}
borderless
displayType="secondary"
size="sm"
symbol="plus"
tabIndex={tabIndex}
title={Liferay.Language.get(
'add-child-page'
)}
/>
}
<ClayLink
aria-label={Liferay.Language.get('add-child-page')}
borderless
button={{monospaced: true}}
displayType="secondary"
href={addChildLayoutURL}
tabIndex={tabIndex}
title={Liferay.Language.get('add-child-page')}
>
<ClayDropDown.ItemList>
{layoutActions.map((action) => (
<ClayDropDown.Item
disabled={!action.url}
href={action.url}
id={action.id}
key={action.id}
onClick={action.handler}
>
{action.label}
</ClayDropDown.Item>
))}
</ClayDropDown.ItemList>
</ClayDropDown>
<ClayIcon symbol="plus" />
</ClayLink>
</ClayLayout.ContentCol>
)}
) : null}

{normalizedQuickActions.map((action) => (
<ClayLayout.ContentCol
Expand Down
11 changes: 4 additions & 7 deletions modules/test/playwright/pages/layout-admin-web/PagesAdminPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,10 @@ export class PagesAdminPage {
// If parent is specified, create child page

else {
await clickAndExpectToBeVisible({
autoClick: true,
target: this.page.getByRole('menuitem', {name: 'Add Page'}),
trigger: this.page
.locator('li', {has: this.page.getByText(parent)})
.getByTitle('Add Child Page'),
});
this.page
.locator('li', {has: this.page.getByText(parent)})
.getByTitle('Add Child Page')
.click();
}

// Select template and fill name
Expand Down
18 changes: 2 additions & 16 deletions modules/test/playwright/tests/layout-admin-web/pagesAdmin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,24 +413,10 @@ test.describe('Keyboard movement and navigation', () => {
trigger: page.getByTitle('Go to Pages'),
});

// Check Add child page dropdown works well

await getItem('Page 1-1')
.getByLabel('Add Child Page')
.press('Enter');

await expect(
page.getByRole('menuitem', {name: 'Add Page'})
).toBeVisible();

await page.keyboard.press('Escape');

await expect(
getItem('Page 1-1').getByLabel('Add Child Page')
).toBeFocused();

// Check item actions dropdown works well

await getItem('Page 1-1').getByLabel('Add Child Page').focus();

await page.keyboard.press('Tab');

await expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ definition {
key_pageName = ${parentPageName},
locator1 = "PagesAdmin#LIST_GROUP_ITEM_PLUS_ICON");

DropdownMenuItem.click(menuItem = "Add Page");

PagesAdmin._addPage(
assertCheckboxMissing = ${assertCheckboxMissing},
navigationMenus = ${navigationMenus},
Expand All @@ -265,8 +263,6 @@ definition {
key_pageName = ${parentPageName},
locator1 = "PagesAdmin#LIST_GROUP_ITEM_PLUS_ICON");

DropdownMenuItem.click(menuItem = "Add Page");

LexiconCard.clickCard(card = "Widget Page");

SelectFrame(locator1 = "IFrame#MODAL_BODY");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ definition {
key_pageName = ${parentPageName},
locator1 = "PagesAdmin#LIST_GROUP_ITEM_PLUS_ICON");

DropdownMenuItem.click(menuItem = "Add Page");

if (!(isSet(sitePageType))) {
var sitePageType = "Widget Page";
}
Expand Down