From 929b0038835dd81888b3a3a233691447db328f56 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Fri, 5 Sep 2025 09:59:31 +0200 Subject: [PATCH 1/5] fix the missing current chosen value inside the role drop down --- src/components/shared/DropDown.tsx | 13 +++++++++++-- .../modals/ResourceDetailsAccessPolicyTab.tsx | 13 +++++-------- src/utils/aclUtils.ts | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/shared/DropDown.tsx b/src/components/shared/DropDown.tsx index ae464d6521..22414a021b 100644 --- a/src/components/shared/DropDown.tsx +++ b/src/components/shared/DropDown.tsx @@ -41,6 +41,7 @@ const DropDown = ({ optionHeight = 25, customCSS, fetchOptions, + isAclDropDown = false, }: { ref?: React.RefObject> | null> value: T @@ -66,7 +67,8 @@ const DropDown = ({ optionPaddingTop?: number, optionLineHeight?: string }, - fetchOptions?: () => { label: string, value: string}[] + fetchOptions?: () => { label: string, value: string}[], + isAclDropDown?: boolean }) => { const { t } = useTranslation(); @@ -167,7 +169,6 @@ const DropDown = ({ )); }; - const commonProps: Props = { tabIndex: tabIndex, theme: theme => (dropDownSpacingTheme(theme)), @@ -192,6 +193,14 @@ const DropDown = ({ // @ts-expect-error: React-Select typing does not account for the typing of option it itself requires components: { MenuList }, filterOption: createFilter({ ignoreAccents: false }), // To improve performance on filtering + + isOptionSelected: (option, _selectValue) => { + const typedOption = option as DropDownOption; + if (isAclDropDown) { + return false; + } + return typedOption.value === value; + }, }; return creatable ? ( diff --git a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx index 81dfbcbe6d..3686136c76 100644 --- a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx +++ b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx @@ -18,7 +18,7 @@ import { import { getUserInformation } from "../../../selectors/userInfoSelectors"; import { hasAccess } from "../../../utils/utils"; import DropDown from "../DropDown"; -import { filterRoles, getAclTemplateText, handleTemplateChange, policiesFiltered, rolesFilteredbyPolicies } from "../../../utils/aclUtils"; +import { filterRoles, getAclTemplateText, handleTemplateChange, policiesFiltered } from "../../../utils/aclUtils"; import { useAppDispatch, useAppSelector } from "../../../store"; import { removeNotificationWizardForm, addNotification } from "../../../slices/notificationSlice"; import { useTranslation } from "react-i18next"; @@ -310,7 +310,6 @@ const ResourceDetailsAccessPolicyTab = ({ ({ isUserTable, policiesFiltered, - rolesFilteredbyPolicies, header, firstColumnHeader, createLabel, @@ -410,7 +406,6 @@ export const AccessPolicyTable = ({ }: { isUserTable: boolean policiesFiltered: TransformedAcl[] - rolesFilteredbyPolicies: Role[] header?: ParseKeys firstColumnHeader: ParseKeys createLabel: ParseKeys, @@ -541,12 +536,12 @@ export const AccessPolicyTable = ({ text={createPolicyLabel(policy)} options={ roles.length > 0 - ? formatAclRolesForDropdown(rolesFilteredbyPolicies) + ? formatAclRolesForDropdown(filterRoles(roles, formik.values.policies, policy.role)) : [] } fetchOptions={() => roles.length > 0 - ? formatAclRolesForDropdown(rolesFilteredbyPolicies) + ? formatAclRolesForDropdown(filterRoles(roles, formik.values.policies, policy.role)) : [] } required={true} @@ -573,6 +568,7 @@ export const AccessPolicyTable = ({ skipTranslate optionHeight={35} customCSS={{ width: "100%", optionPaddingTop: 5 }} + isAclDropDown /> ) : (

{policy.role}

@@ -811,6 +807,7 @@ export const TemplateSelector = ({ } }} placeholder={t(buttonText)} + isAclDropDown /> )} {!(aclTemplates.length > 0) && diff --git a/src/utils/aclUtils.ts b/src/utils/aclUtils.ts index f1d5066388..ec181f36c4 100644 --- a/src/utils/aclUtils.ts +++ b/src/utils/aclUtils.ts @@ -24,10 +24,18 @@ export const getAclTemplateText = ( } }; -export const filterRoles = (roles: Role[], policies: TransformedAcl[]) => { - return roles.filter( - role => !policies.find(policy => policy.role === role.name), - ); +export const filterRoles = (roles: Role[], policies: TransformedAcl[], currentRole?: string) => { + // Collect all roles currently selected in policies + const selectedRoles = policies + .map(p => p.role) + .filter(Boolean); + + return roles.filter(r => + // keep it if it's not already selected + !selectedRoles.includes(r.name) + // OR it is the current role for this dropdown row + || r.name === currentRole, + ); }; // Get all policies that have user information, or all policies that do not have user information From 6a04ba173626f609e23f2edb46b8ce2bc54b2a5c Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Tue, 9 Sep 2025 23:43:10 +0200 Subject: [PATCH 2/5] fixing the build issue --- .../partials/ModalTabsAndPages/NewAccessPage.tsx | 5 +---- .../users/partials/wizard/AclAccessPage.tsx | 5 +---- src/utils/aclUtils.ts | 14 -------------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/components/events/partials/ModalTabsAndPages/NewAccessPage.tsx b/src/components/events/partials/ModalTabsAndPages/NewAccessPage.tsx index c0efae3087..2619728582 100644 --- a/src/components/events/partials/ModalTabsAndPages/NewAccessPage.tsx +++ b/src/components/events/partials/ModalTabsAndPages/NewAccessPage.tsx @@ -9,7 +9,7 @@ import { fetchRolesWithTarget, } from "../../../../slices/aclSlice"; import { FormikProps } from "formik"; -import { filterRoles, policiesFiltered, rolesFilteredbyPolicies } from "../../../../utils/aclUtils"; +import { policiesFiltered } from "../../../../utils/aclUtils"; import { useAppDispatch, useAppSelector } from "../../../../store"; import { fetchSeriesDetailsAcls } from "../../../../slices/seriesDetailsSlice"; import { getSeriesDetailsAcl } from "../../../../selectors/seriesDetailsSelectors"; @@ -121,7 +121,6 @@ const NewAccessPage = ({ ({ ({ ({ ({ ({ { - roles = filterRoles(roles, policies); - if (byUser) { - return roles.filter(role => role.user !== undefined); - } else { - return roles.filter(role => role.user === undefined); - } -}; - /* fetches the policies for the chosen template and sets the policies in the formik form to those policies */ export const handleTemplateChange = async ( templateId: string, From d87a34b3143c87fa8096286c921050be92b0e09e Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Mon, 29 Sep 2025 13:12:52 +0200 Subject: [PATCH 3/5] fix the conflicts --- src/components/shared/DropDown.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/shared/DropDown.tsx b/src/components/shared/DropDown.tsx index 0681a862ff..1d8c60ad44 100644 --- a/src/components/shared/DropDown.tsx +++ b/src/components/shared/DropDown.tsx @@ -4,7 +4,7 @@ import { dropDownSpacingTheme, dropDownStyle, } from "../../utils/componentStyles"; -import { GroupBase, MenuListProps, Props, SelectInstance } from "react-select"; +import { GroupBase, MenuListProps, Props, SelectInstance, createFilter } from "react-select"; import { isJson } from "../../utils/utils"; import { ParseKeys } from "i18next"; import { FixedSizeList, ListChildComponentProps } from "react-window"; @@ -67,7 +67,8 @@ const DropDown = ({ optionPaddingTop?: number, optionLineHeight?: string }, - fetchOptions?: (inputValue: string) => Promise<{ label: string, value: string }[]> + fetchOptions?: (inputValue: string) => Promise<{ label: string, value: string }[]>, + isAclDropDown?: boolean; }) => { const { t } = useTranslation(); From abca88874e3ba6aab3a245e7291b5c9d1b58dac8 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Mon, 29 Sep 2025 13:17:12 +0200 Subject: [PATCH 4/5] build error --- src/components/shared/wizard/RenderField.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/shared/wizard/RenderField.tsx b/src/components/shared/wizard/RenderField.tsx index 7ca5f4b6b9..f89b3799e4 100644 --- a/src/components/shared/wizard/RenderField.tsx +++ b/src/components/shared/wizard/RenderField.tsx @@ -340,7 +340,6 @@ const EditableSingleValueTime = ({ const EditableSingleSelectSeries = ({ field, metadataField, - text, form: { setFieldValue }, isFirstField, focused, From 6b5e0df5652c204375644dd7dba7153b381c3d11 Mon Sep 17 00:00:00 2001 From: ensiyehe Date: Tue, 30 Sep 2025 11:50:07 +0200 Subject: [PATCH 5/5] build problems --- src/components/shared/DropDown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/shared/DropDown.tsx b/src/components/shared/DropDown.tsx index 837438848e..1d8c60ad44 100644 --- a/src/components/shared/DropDown.tsx +++ b/src/components/shared/DropDown.tsx @@ -4,7 +4,7 @@ import { dropDownSpacingTheme, dropDownStyle, } from "../../utils/componentStyles"; -import { GroupBase, MenuListProps, Props, SelectInstance } from "react-select"; +import { GroupBase, MenuListProps, Props, SelectInstance, createFilter } from "react-select"; import { isJson } from "../../utils/utils"; import { ParseKeys } from "i18next"; import { FixedSizeList, ListChildComponentProps } from "react-window";