This is an automated email from the ASF dual-hosted git repository. dhavalshah9131 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 622a1dacbdd39ec08783fd3d411bedb66f1407b1 Author: Brijesh Bhalala <brijeshbhalala2...@gmail.com> AuthorDate: Wed Sep 6 19:33:29 2023 +0530 RANGER-4383: In Audit, Plugin Status tab if the record of respective service is in second page then Service Type filter for that service would show no result --- .../react-webapp/src/components/Editable.jsx | 16 ++--- .../react-webapp/src/components/XATableLayout.jsx | 9 ++- .../main/webapp/react-webapp/src/utils/fetchAPI.js | 2 +- .../src/views/AuditEvent/AdminLogs/UserLogs.jsx | 6 +- .../src/views/AuditEvent/PluginStatusLogs.jsx | 9 +-- .../src/views/Encryption/KeyManager.jsx | 72 +++++++++++----------- .../role_details/RoleListing.jsx | 8 +-- .../users_details/UserFormComp.jsx | 26 +++----- 8 files changed, 65 insertions(+), 83 deletions(-) diff --git a/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx b/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx index 4e98134ab..4d6d7d265 100644 --- a/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx @@ -17,13 +17,7 @@ * under the License. */ -import React, { - useEffect, - useReducer, - useRef, - useState, - useCallback -} from "react"; +import React, { useEffect, useReducer, useRef, useState } from "react"; import { OverlayTrigger, Popover, @@ -33,7 +27,7 @@ import { Col, Badge } from "react-bootstrap"; -import { find, findIndex, isArray, isEmpty, map } from "lodash"; +import { find, findIndex, isArray, isEmpty, sortBy } from "lodash"; import { isObject } from "Utils/XAUtils"; import CreatableSelect from "react-select/creatable"; import Select from "react-select"; @@ -82,7 +76,7 @@ const CheckboxComp = (props) => { return ( <> - {options.map((obj, index) => ( + {options.map((obj) => ( <Form.Group className="mb-3" controlId={obj.label} key={obj.label}> <Form.Check checked={isChecked(obj)} @@ -409,7 +403,7 @@ const Editable = (props) => { const policyConditionDisplayValue = () => { let ipRangVal, uiHintVal; if (selectVal) { - return _.sortBy(Object.keys(selectVal)).map((property, index) => { + return sortBy(Object.keys(selectVal)).map((property, index) => { let conditionObj = find(conditionDefVal, function (m) { if (m.name == property) { return m; @@ -651,7 +645,7 @@ const Editable = (props) => { const handleApply = (e) => { let errors, uiHintVal; if (selectValRef?.current) { - _.sortBy(Object.keys(selectValRef.current)).map((property) => { + sortBy(Object.keys(selectValRef.current)).map((property) => { let conditionObj = find(conditionDefVal, function (m) { if (m.name == property) { return m; diff --git a/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx b/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx index d275598ce..71a33f1c7 100644 --- a/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx @@ -59,6 +59,7 @@ function XATableLayout({ loading, data, fetchData, + showPagination = true, pageCount: controlledPageCount, currentpageIndex, currentpageSize, @@ -85,6 +86,7 @@ function XATableLayout({ : []; return filterColVal; }; + const { getTableProps, getTableBodyProps, @@ -160,6 +162,7 @@ function XATableLayout({ }); } ); + const currentPageValRef = useRef(); const [currentPageVal, setCurrentPageVal] = useState(""); @@ -317,7 +320,7 @@ function XATableLayout({ </tbody> ) : ( <tbody {...getTableBodyProps()}> - {rows.map((row, index) => { + {rows.map((row) => { prepareRow(row); return ( <tr @@ -339,7 +342,7 @@ function XATableLayout({ </> </Table> </div> - {totalCount > 25 && ( + {showPagination && totalCount > 25 && ( <div className="row mt-2"> <div className="col-md-12 m-b-sm"> <div className="text-center d-flex justify-content-end align-items-center pb-2"> @@ -406,7 +409,7 @@ function XATableLayout({ currPage > pageOptions.length || !Number.isInteger(Number(currPage)) ) { - return (currPage = currPage); + return currPage; } else { const page = currPage ? Number(currPage) - 1 : 0; gotoPage(page); diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js index 135182b40..fbdd91737 100644 --- a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js +++ b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js @@ -89,7 +89,7 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) { window.location.replace("login.jsp?sessionTimeout=true"); } } - if (config.skipNavigate !== undefined && config.skipNavigate) { + if (config?.skipNavigate) { throw error; } if ( diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx index a856187af..5eb26825c 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx @@ -21,7 +21,7 @@ import React from "react"; import { Table, Badge } from "react-bootstrap"; import dateFormat from "dateformat"; import { ClassTypes, UserRoles } from "../../../utils/XAEnums"; -import { isEmpty, unionBy, difference, isEqual } from "lodash"; +import { isEmpty, unionBy, difference, isEqual, without } from "lodash"; export const UserLogs = ({ data, reportdata }) => { const { objectName, objectClassType, createDate, owner, action } = data; @@ -48,11 +48,11 @@ export const UserLogs = ({ data, reportdata }) => { return obj.attributeName == "Group Name"; }); - const updateGrpOld = _.without( + const updateGrpOld = without( updateUserGrp.map((obj) => obj.previousValue), "" ); - const updateGrpNew = _.without( + const updateGrpNew = without( updateUserGrp.map((obj) => obj.newValue), "" ); diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx index ea0e550a7..cf4727514 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx @@ -39,7 +39,7 @@ import { } from "../../components/CommonComponents"; import StructuredFilter from "../../components/structured-filter/react-typeahead/tokenizer"; import { fetchApi } from "Utils/fetchAPI"; -import { isEmpty, isUndefined, map, sortBy, toUpper, filter } from "lodash"; +import { isUndefined, map, sortBy, toUpper, filter } from "lodash"; import { getServiceDef } from "../../utils/appState"; function Plugin_Status() { @@ -48,7 +48,6 @@ function Plugin_Status() { const servicesAvailable = context.servicesAvailable; const [pluginStatusListingData, setPluginStatusLogs] = useState([]); const [loader, setLoader] = useState(true); - const [pageCount, setPageCount] = React.useState(0); const [entries, setEntries] = useState([]); const [updateTable, setUpdateTable] = useState(moment.now()); const fetchIdRef = useRef(0); @@ -90,11 +89,9 @@ function Plugin_Status() { if (servicesAvailable !== null) { let logsResp = []; let logs = []; - let totalCount = 0; const fetchId = ++fetchIdRef.current; let params = { ...searchFilterParams }; if (fetchId === fetchIdRef.current) { - params["pageSize"] = pageSize; params["startIndex"] = pageIndex * pageSize; try { logsResp = await fetchApi({ @@ -102,7 +99,6 @@ function Plugin_Status() { params: params }); logs = logsResp.data.pluginInfoList; - totalCount = logsResp.data.totalCount; } catch (error) { serverError(error); console.error( @@ -111,7 +107,6 @@ function Plugin_Status() { } setPluginStatusLogs(logs); setEntries(logsResp.data); - setPageCount(Math.ceil(totalCount / pageSize)); setResetpage({ page: gotoPage }); setLoader(false); } @@ -576,9 +571,9 @@ function Plugin_Status() { loading={loader} totalCount={entries && entries.totalCount} fetchData={fetchPluginStatusInfo} - pageCount={pageCount} columnSort={true} clientSideSorting={true} + showPagination={false} /> </React.Fragment> </div> diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx index 401c960b2..98ea88280 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx @@ -30,7 +30,7 @@ import { Row, Col, Button, Modal } from "react-bootstrap"; import { fetchApi } from "Utils/fetchAPI"; import dateFormat from "dateformat"; import moment from "moment-timezone"; -import { find, sortBy, isUndefined, isEmpty } from "lodash"; +import { find, sortBy, isUndefined, isEmpty, reject } from "lodash"; import StructuredFilter from "../../components/structured-filter/react-typeahead/tokenizer"; import AsyncSelect from "react-select/async"; import { isKeyAdmin, parseSearchFilter } from "../../utils/XAUtils"; @@ -140,7 +140,7 @@ function reducer(state, action) { } } -const KeyManager = (props) => { +const KeyManager = () => { const navigate = useNavigate(); const { state } = useLocation(); const params = useParams(); @@ -505,40 +505,36 @@ const KeyManager = (props) => { Header: "Action", accessor: "action", Cell: (rawValue) => { - if (isKeyAdmin()) { - return ( - <div className="text-center"> - <Button - className="btn btn-outline-dark btn-sm m-r-5" - size="sm" - title="Edit" - onClick={() => { - editModal(rawValue.row.original.name); - }} - data-name="rolloverKey" - data-id={rawValue.row.original.name} - data-cy={rawValue.row.original.name} - > - <i className="fa-fw fa fa-edit"></i> - </Button> - <Button - variant="danger" - size="sm" - title="Delete" - onClick={() => { - deleteModal(rawValue.row.original.name); - }} - data-name="deleteKey" - data-id={rawValue.row.original.name} - data-cy={rawValue.row.original.name} - > - <i className="fa-fw fa fa-trash"></i> - </Button> - </div> - ); - } else { - return <div className="text-center">--</div>; - } + return ( + <div className="text-center"> + <Button + className="btn btn-outline-dark btn-sm m-r-5" + size="sm" + title="Edit" + onClick={() => { + editModal(rawValue.row.original.name); + }} + data-name="rolloverKey" + data-id={rawValue.row.original.name} + data-cy={rawValue.row.original.name} + > + <i className="fa-fw fa fa-edit"></i> + </Button> + <Button + variant="danger" + size="sm" + title="Delete" + onClick={() => { + deleteModal(rawValue.row.original.name); + }} + data-name="deleteKey" + data-id={rawValue.row.original.name} + data-cy={rawValue.row.original.name} + > + <i className="fa-fw fa fa-trash"></i> + </Button> + </div> + ); }, width: 80 } @@ -622,7 +618,9 @@ const KeyManager = (props) => { <XATableLayout loading={loader} data={keydata || []} - columns={columns} + columns={ + isKeyAdmin() ? columns : reject(columns, ["Header", "Action"]) + } fetchData={selectServices} pageCount={pagecount} currentPageIndex={currentPageIndex} diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx index dbd195c1d..8caecf058 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx @@ -28,7 +28,7 @@ import { useSearchParams } from "react-router-dom"; import moment from "moment-timezone"; -import { find, isEmpty } from "lodash"; +import { find, isEmpty, map } from "lodash"; import { fetchApi } from "Utils/fetchAPI"; import { toast } from "react-toastify"; import { @@ -267,7 +267,7 @@ function Roles() { Header: "Users", accessor: "users", accessor: (raw) => { - let usersList = _.map(raw.users, "name"); + let usersList = map(raw.users, "name"); return !isEmpty(usersList) ? ( <MoreLess data={usersList} key={raw.id} /> ) : ( @@ -279,7 +279,7 @@ function Roles() { Header: "Groups", accessor: "groups", accessor: (raw) => { - let groupsList = _.map(raw.groups, "name"); + let groupsList = map(raw.groups, "name"); return !isEmpty(groupsList) ? ( <MoreLess data={groupsList} key={raw.id} /> ) : ( @@ -291,7 +291,7 @@ function Roles() { Header: "Roles", accessor: "roles", accessor: (raw) => { - let rolesList = _.map(raw.roles, "name"); + let rolesList = map(raw.roles, "name"); return !isEmpty(rolesList) ? ( <MoreLess data={rolesList} key={raw.id} /> diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx index 23bc1b169..64a536c0c 100644 --- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx +++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx @@ -33,16 +33,15 @@ import { import { toast } from "react-toastify"; import { getUserAccessRoleList, serverError } from "Utils/XAUtils"; import { getUserProfile } from "Utils/appState"; -import _, { isEmpty, isUndefined } from "lodash"; +import { has, isEmpty, isUndefined } from "lodash"; import { SyncSourceDetails } from "../SyncSourceDetails"; import { BlockUi } from "../../../components/CommonComponents"; -import { InfoIcon, commonBreadcrumb } from "../../../utils/XAUtils"; +import { InfoIcon } from "../../../utils/XAUtils"; import { RegexMessage, roleChngWarning } from "../../../utils/XAMessages"; -import { useLocation, useNavigate, useParams } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; import usePrompt from "Hooks/usePrompt"; const initialState = { - loader: true, blockUI: false }; @@ -54,11 +53,6 @@ const PromtDialog = (props) => { function reducer(state, action) { switch (action.type) { - case "SET_LOADER": - return { - ...state, - loader: action.loader - }; case "SET_BLOCK_UI": return { ...state, @@ -70,11 +64,10 @@ function reducer(state, action) { } function UserFormComp(props) { - const params = useParams(); const { state } = useLocation(); const navigate = useNavigate(); const [userFormState, dispatch] = useReducer(reducer, initialState); - const { loader, blockUI } = userFormState; + const { blockUI } = userFormState; const { isEditView, userInfo } = props; const [preventUnBlock, setPreventUnblock] = useState(false); const toastId = React.useRef(null); @@ -178,8 +171,8 @@ function UserFormComp(props) { navigate("/users/usertab"); }; - const groupNameList = ({ input, ...rest }) => { - const loadOptions = async (inputValue, callback) => { + const groupNameList = ({ input }) => { + const loadOptions = async (inputValue) => { let params = {}, op = []; if (inputValue) { @@ -354,7 +347,7 @@ function UserFormComp(props) { if ( values && - _.has(values, "password") && + has(values, "password") && !RegexValidation.PASSWORD.regexExpression.test(values.password) ) { errors.password = RegexValidation.PASSWORD.message; @@ -362,8 +355,8 @@ function UserFormComp(props) { if ( values && - _.has(values, "password") && - _.has(values, "passwordConfirm") && + has(values, "password") && + has(values, "passwordConfirm") && values.password !== values.passwordConfirm ) { errors.passwordConfirm = "Password must be match with new password"; @@ -393,7 +386,6 @@ function UserFormComp(props) { values, invalid, errors, - pristine, dirty }) => ( <div className="wrap user-role-grp-form">