diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Permissions/PermissionsForm/PermissionsForm.tsx b/frontend/libs/console/legacy-ce/src/lib/features/Permissions/PermissionsForm/PermissionsForm.tsx index 03d06dcd46a..1d77e0babdc 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/Permissions/PermissionsForm/PermissionsForm.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/Permissions/PermissionsForm/PermissionsForm.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; import { useConsoleForm } from '../../../new-components/Form'; import { Button } from '../../../new-components/Button'; import { IndicatorCard } from '../../../new-components/IndicatorCard'; @@ -21,11 +21,11 @@ import { RowPermissionsSectionWrapper, } from './components'; -import { ReturnValue, useFormData, useUpdatePermissions } from './hooks'; +import { useFormData, useUpdatePermissions } from './hooks'; import ColumnRootFieldPermissions from './components/RootFieldPermissions/RootFieldPermissions'; import { useListAllTableColumns } from '../../Data'; import { useMetadataSource } from '../../MetadataAPI'; -import { omit } from 'lodash'; +import useScrollIntoView from './hooks/useScrollIntoView'; export interface ComponentProps { dataSourceName: string; @@ -37,17 +37,6 @@ export interface ComponentProps { data: ReturnType['data']; } -const getCanSave = ( - defaultValues: ReturnValue['defaultValues'], - newValues: Record -) => { - const cloneWithoutClonePermissions = omit(newValues, 'clonePermissions'); - return ( - JSON.stringify(cloneWithoutClonePermissions) === - JSON.stringify(defaultValues) - ); -}; - const Component = (props: ComponentProps) => { const { dataSourceName, @@ -58,6 +47,8 @@ const Component = (props: ComponentProps) => { handleClose, data, } = props; + const permissionSectionRef = useRef(null); + useScrollIntoView(permissionSectionRef, [roleName], { behavior: 'smooth' }); const { data: metadataTables } = useMetadata( MetadataSelector.getTables(dataSourceName) @@ -199,7 +190,12 @@ const Component = (props: ComponentProps) => { tables={tables} roles={roles} /> -
+ +