From f15b5f6b93848f59650d57a752bc4040f4eb06e2 Mon Sep 17 00:00:00 2001 From: Daniel Bonasser Date: Tue, 25 Jun 2024 16:17:49 -0300 Subject: [PATCH 1/5] LPD-29276 Change the definition of the RolesGroup interface by replacing LabelValueObject with LabelNameObject --- .../js/components/SettingsContainer/rolesUtils.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts index dc5cb137368330..e0d16a538b9c06 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts @@ -23,9 +23,9 @@ export interface Roles { totalCount: number; } interface RolesGroup { - accountRoles: LabelValueObject[]; - organizationRoles: LabelValueObject[]; - regularRoles: LabelValueObject[]; + accountRoles: LabelNameObject[]; + organizationRoles: LabelNameObject[]; + regularRoles: LabelNameObject[]; } const roleGroupLabels = { @@ -48,15 +48,15 @@ export async function getEmailNotificationRoles(baseResourceURL: string) { ( Object.entries(rolesResponse) as [ keyof RolesGroup, - LabelValueObject[], + LabelNameObject[], ][] ).forEach(([roleGroupKey, roleValues]) => { roles.push({ - children: roleValues.map(({label, value}) => { + children: roleValues.map(({label, name}) => { return { checked: false, label, - value, + value: name, }; }), label: roleGroupLabels[roleGroupKey], From f2f77158400011d27ba3ea480b52c5c8dbd5079e Mon Sep 17 00:00:00 2001 From: Daniel Bonasser Date: Tue, 25 Jun 2024 16:34:35 -0300 Subject: [PATCH 2/5] LPD-29276 Extract handleMultiSelectRoleItemsChange function to a util file and reuse it to avoid code repetition --- .../SettingsContainer/PrimaryRecipients.tsx | 39 +++++++------------ .../SettingsContainer/SecondaryRecipients.tsx | 26 ++++--------- .../SettingsContainer/rolesUtils.ts | 23 +++++++++-- 3 files changed, 39 insertions(+), 49 deletions(-) diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx index 4a328bd84b392a..83f8513bd88f4b 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx @@ -21,7 +21,7 @@ import { import React, {useEffect, useState} from 'react'; import {NotificationTemplateError} from '../EditNotificationTemplate'; -import {getCheckedChildren} from './rolesUtils'; +import {getCheckedChildren, handleMultiSelectRoleItemsChange} from './rolesUtils'; interface PrimaryRecipientProps { emailNotificationRoles: MultiSelectItem[]; @@ -45,30 +45,6 @@ export function PrimaryRecipient({ const [recipient] = values.recipients as EmailRecipients[]; const [toRolesList, setToRolesList] = useState([]); - const handleMultiSelectItemsChange = (itemsGroup: MultiSelectItem[]) => { - const newRecipients: EmailNotificationRecipients[] = []; - - if (itemsGroup.length) { - itemsGroup.forEach((itemGroup) => { - itemGroup.children.forEach((child) => { - if (child.checked) { - newRecipients.push({['roleName']: child.value}); - } - }); - }); - } - - setValues({ - ...values, - recipients: [ - { - ...recipient, - to: newRecipients, - }, - ], - }); - }; - useEffect(() => { if (emailNotificationRoles.length && !toRolesList.length) { setToRolesList(emailNotificationRoles); @@ -171,7 +147,18 @@ export function PrimaryRecipient({ )} selectAllOption setOptions={(items) => { - handleMultiSelectItemsChange(items); + const newRecipients = handleMultiSelectRoleItemsChange(items); + + setValues({ + ...values, + recipients: [ + { + ...recipient, + to: newRecipients, + }, + ], + }); + setToRolesList(items); }} /> diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx index 16dce250c5f075..8d48b3cbf9ca63 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx @@ -17,7 +17,7 @@ import { } from 'frontend-js-components-web'; import React, {useEffect, useState} from 'react'; -import {getCheckedChildren} from './rolesUtils'; +import {getCheckedChildren, handleMultiSelectRoleItemsChange} from './rolesUtils'; interface SecondaryRecipientsProps { emailNotificationRoles: MultiSelectItem[]; @@ -38,22 +38,6 @@ export function SecondaryRecipient({ const [ccRolesList, setCCRolesList] = useState([]); const [recipient] = values.recipients as EmailRecipients[]; - const handleMultiSelectItemsChange = (itemsGroup: MultiSelectItem[]) => { - const newRecipients: EmailNotificationRecipients[] = []; - - if (itemsGroup.length) { - itemsGroup.forEach((itemGroup) => { - itemGroup.children.forEach((child) => { - if (child.checked) { - newRecipients.push({['roleName']: child.value}); - } - }); - }); - } - - return newRecipients; - }; - useEffect(() => { if (emailNotificationRoles.length && !ccRolesList.length) { setCCRolesList(emailNotificationRoles); @@ -200,9 +184,10 @@ export function SecondaryRecipient({ selectAllOption setOptions={(items) => { const newRecipients = - handleMultiSelectItemsChange( + handleMultiSelectRoleItemsChange( items ); + setValues({ ...values, recipients: [ @@ -212,6 +197,7 @@ export function SecondaryRecipient({ }, ], }); + setCCRolesList(items); }} /> @@ -318,9 +304,10 @@ export function SecondaryRecipient({ selectAllOption setOptions={(items) => { const newRecipients = - handleMultiSelectItemsChange( + handleMultiSelectRoleItemsChange( items ); + setValues({ ...values, recipients: [ @@ -330,6 +317,7 @@ export function SecondaryRecipient({ }, ], }); + setBCCRolesList(items); }} /> diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts index e0d16a538b9c06..08f13321198707 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts @@ -46,10 +46,7 @@ export async function getEmailNotificationRoles(baseResourceURL: string) { const roles = [] as MultiSelectItem[]; ( - Object.entries(rolesResponse) as [ - keyof RolesGroup, - LabelNameObject[], - ][] + Object.entries(rolesResponse) as [keyof RolesGroup, LabelNameObject[]][] ).forEach(([roleGroupKey, roleValues]) => { roles.push({ children: roleValues.map(({label, name}) => { @@ -117,3 +114,21 @@ export function getCheckedChildren( }; }); } + +export function handleMultiSelectRoleItemsChange( + itemsGroup: MultiSelectItem[] +) { + const newRecipients: EmailNotificationRecipients[] = []; + + if (itemsGroup.length) { + itemsGroup.forEach((itemGroup) => { + itemGroup.children.forEach((child) => { + if (child.checked) { + newRecipients.push({['roleName']: child.value}); + } + }); + }); + } + + return newRecipients; +} From 2f079f8b8aff7d38ca9aaf6ecab88e07d5b5f89b Mon Sep 17 00:00:00 2001 From: Daniel Bonasser Date: Tue, 25 Jun 2024 16:48:32 -0300 Subject: [PATCH 3/5] LPD-29276 Rename rolesUtil file --- .../js/components/EditNotificationTemplate.tsx | 2 +- .../SettingsContainer/PrimaryRecipients.tsx | 10 +++++++--- .../SettingsContainer/SecondaryRecipients.tsx | 11 +++++++---- .../SettingsContainer/UserNotificationSettings.tsx | 2 +- .../SettingsContainer/{rolesUtils.ts => rolesUtil.ts} | 0 .../META-INF/resources/js/tests/RoleUtils.spec.ts | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) rename modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/{rolesUtils.ts => rolesUtil.ts} (100%) diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/EditNotificationTemplate.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/EditNotificationTemplate.tsx index 76684e7bb0c392..007a437b7f83e5 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/EditNotificationTemplate.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/EditNotificationTemplate.tsx @@ -23,7 +23,7 @@ import {BasicInfoContainer} from './BasicInfoContainer/BasicInfoContainer'; import ContentContainer from './ContentContainer/ContentContainer'; import DefinitionOfTermsContainer from './DefinitionOfTermsContainer/DefinitionOfTermsContainer'; import {SettingsContainer} from './SettingsContainer/SettingsContainer'; -import {getEmailNotificationRoles} from './SettingsContainer/rolesUtils'; +import {getEmailNotificationRoles} from './SettingsContainer/rolesUtil'; import './EditNotificationTemplate.scss'; diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx index 83f8513bd88f4b..c4b721c33a904f 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/PrimaryRecipients.tsx @@ -21,7 +21,10 @@ import { import React, {useEffect, useState} from 'react'; import {NotificationTemplateError} from '../EditNotificationTemplate'; -import {getCheckedChildren, handleMultiSelectRoleItemsChange} from './rolesUtils'; +import { + getCheckedChildren, + handleMultiSelectRoleItemsChange, +} from './rolesUtil'; interface PrimaryRecipientProps { emailNotificationRoles: MultiSelectItem[]; @@ -147,7 +150,8 @@ export function PrimaryRecipient({ )} selectAllOption setOptions={(items) => { - const newRecipients = handleMultiSelectRoleItemsChange(items); + const newRecipients = + handleMultiSelectRoleItemsChange(items); setValues({ ...values, @@ -158,7 +162,7 @@ export function PrimaryRecipient({ }, ], }); - + setToRolesList(items); }} /> diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx index 8d48b3cbf9ca63..430382cdf6bc67 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/SecondaryRecipients.tsx @@ -17,7 +17,10 @@ import { } from 'frontend-js-components-web'; import React, {useEffect, useState} from 'react'; -import {getCheckedChildren, handleMultiSelectRoleItemsChange} from './rolesUtils'; +import { + getCheckedChildren, + handleMultiSelectRoleItemsChange, +} from './rolesUtil'; interface SecondaryRecipientsProps { emailNotificationRoles: MultiSelectItem[]; @@ -184,7 +187,7 @@ export function SecondaryRecipient({ selectAllOption setOptions={(items) => { const newRecipients = - handleMultiSelectRoleItemsChange( + handleMultiSelectRoleItemsChange( items ); @@ -304,7 +307,7 @@ export function SecondaryRecipient({ selectAllOption setOptions={(items) => { const newRecipients = - handleMultiSelectRoleItemsChange( + handleMultiSelectRoleItemsChange( items ); @@ -317,7 +320,7 @@ export function SecondaryRecipient({ }, ], }); - + setBCCRolesList(items); }} /> diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/UserNotificationSettings.tsx b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/UserNotificationSettings.tsx index 4d1dba225ac8ce..1bfa9f15d78219 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/UserNotificationSettings.tsx +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/UserNotificationSettings.tsx @@ -13,7 +13,7 @@ import {fetch} from 'frontend-js-web'; import React, {useEffect, useState} from 'react'; import {HEADERS} from '../../util/constants'; -import {getRoles, getUserNotificationRoles} from './rolesUtils'; +import {getRoles, getUserNotificationRoles} from './rolesUtil'; interface User { alternateName: string; diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtil.ts similarity index 100% rename from modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtils.ts rename to modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/components/SettingsContainer/rolesUtil.ts diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts index be40021fdc7d11..a13531026d6613 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts @@ -8,7 +8,7 @@ import '@testing-library/jest-dom/extend-expect'; import { getCheckedChildren, getUserNotificationRoles, -} from '../components/SettingsContainer/rolesUtils'; +} from '../components/SettingsContainer/rolesUtil'; it('Assert role names checked items', () => { const children = [ From 8c106bdba53070677ab981b6e0cb33a14f0653e6 Mon Sep 17 00:00:00 2001 From: Daniel Bonasser Date: Tue, 25 Jun 2024 17:10:29 -0300 Subject: [PATCH 4/5] LPD-29276 Create unit test to handleMultiSelectRoleItemsChange function --- .../{RoleUtils.spec.ts => RolesUtil.spec.ts} | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) rename modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/{RoleUtils.spec.ts => RolesUtil.spec.ts} (64%) diff --git a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RolesUtil.spec.ts similarity index 64% rename from modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts rename to modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RolesUtil.spec.ts index a13531026d6613..9384971651f311 100644 --- a/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RoleUtils.spec.ts +++ b/modules/apps/notification/notification-web/src/main/resources/META-INF/resources/js/tests/RolesUtil.spec.ts @@ -4,10 +4,12 @@ */ import '@testing-library/jest-dom/extend-expect'; +import {MultiSelectItem} from '@liferay/object-js-components-web'; import { getCheckedChildren, getUserNotificationRoles, + handleMultiSelectRoleItemsChange, } from '../components/SettingsContainer/rolesUtil'; it('Assert role names checked items', () => { @@ -137,3 +139,80 @@ it('Assert roles in User Notification', () => { }, ]); }); + +it('verify that handleMultiSelectRoleItemsChange generates new recipients in the correct data structure', () => { + const itemsGroupMock = [ + { + children: [ + { + checked: true, + label: 'Account Administrator', + value: 'Account Administrator', + }, + { + checked: false, + label: 'Account Member', + value: 'Account Member', + }, + { + checked: true, + label: 'Account Supplier', + value: 'Account Supplier', + }, + { + checked: true, + label: 'Buyer', + value: 'Buyer', + }, + ], + label: 'Account Roles', + value: 'accountRoles', + }, + { + children: [ + { + checked: false, + label: 'Administrator', + value: 'Administrator', + }, + { + checked: false, + label: 'Owner', + value: 'Owner', + }, + { + checked: true, + label: 'Power User', + value: 'Power User', + }, + { + checked: true, + label: 'Supplier', + value: 'Supplier', + }, + ], + label: 'Regular Roles', + value: 'regularRoles', + }, + ] as MultiSelectItem[]; + + const newRecipients = handleMultiSelectRoleItemsChange(itemsGroupMock); + + expect(newRecipients).toStrictEqual([ + { + roleName: 'Account Administrator', + }, + { + roleName: 'Account Supplier', + }, + { + roleName: 'Buyer', + }, + { + roleName: 'Power User', + }, + { + roleName: 'Supplier', + }, + ]); +}); From 3e544b106746ce8bfae3ed39e482ba065da849ea Mon Sep 17 00:00:00 2001 From: Dante Wang Date: Fri, 21 Jun 2024 10:22:49 +0800 Subject: [PATCH 5/5] LPD-29270 Add missing --add-opens to DBUpgradeClient according to latest tools/servers/tomcat/bin/setenv.sh --- .../liferay/portal/tools/db/upgrade/client/DBUpgradeClient.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/util/portal-tools-db-upgrade-client/src/main/java/com/liferay/portal/tools/db/upgrade/client/DBUpgradeClient.java b/modules/util/portal-tools-db-upgrade-client/src/main/java/com/liferay/portal/tools/db/upgrade/client/DBUpgradeClient.java index 7ad04fb5be371b..75aeb1e89718f3 100644 --- a/modules/util/portal-tools-db-upgrade-client/src/main/java/com/liferay/portal/tools/db/upgrade/client/DBUpgradeClient.java +++ b/modules/util/portal-tools-db-upgrade-client/src/main/java/com/liferay/portal/tools/db/upgrade/client/DBUpgradeClient.java @@ -805,9 +805,11 @@ private void _verifyPortalUpgradeExtProperties() throws IOException { private static File _jarDir; private static final List _reflectionOpens = Arrays.asList( "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.lang.invoke=ALL-UNNAMED", "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED", "--add-opens=java.base/java.net=ALL-UNNAMED", "--add-opens=java.base/sun.net.www.protocol.http=ALL-UNNAMED", + "--add-opens=java.base/sun.net.www.protocol.https=ALL-UNNAMED", "--add-opens=java.base/sun.util.calendar=ALL-UNNAMED", "--add-opens=jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED");