diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx index d20fafb04bd..73e50c41f0e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ManageTab/ManageTab.component.tsx @@ -65,6 +65,7 @@ const ManageTab: FunctionComponent = ({ deletEntityMessage, handleIsJoinable, afterDeleteAction, + manageSectionType, }: ManageProps) => { const { userPermissions, isAdminUser } = useAuth(); const { isAuthDisabled } = useAuthContext(); @@ -396,6 +397,7 @@ const ManageTab: FunctionComponent = ({ isListLoading={isUserLoading} listOwners={listOwners} listVisible={listVisible} + manageSectionType={manageSectionType} owner={owner || ({} as EntityReference)} ownerName={currentUser?.displayName || currentUser?.name || ''} ownerSearchText={searchText} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetails.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetails.tsx index 6794eda248d..78264aff7b1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetails.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetails.tsx @@ -24,7 +24,9 @@ import { getUserPath, PAGE_SIZE_MEDIUM, TITLE_FOR_NON_ADMIN_ACTION, + TITLE_FOR_NON_OWNER_ACTION, } from '../../constants/constants'; +import { ADMIN_ONLY_ACCESSIBLE_SECTION } from '../../enums/common.enum'; import { OwnerType } from '../../enums/user.enum'; import { Operation } from '../../generated/entity/policies/policy'; import { Team } from '../../generated/entity/teams/team'; @@ -315,8 +317,9 @@ const TeamDetails = ({ {currentTeamUsers.length > 0 && isActionAllowed() && (
+ title={TITLE_FOR_NON_OWNER_ACTION}>
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerWidget/OwnerWidget.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerWidget/OwnerWidget.tsx index 574e8962743..944522ed002 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerWidget/OwnerWidget.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/OwnerWidget/OwnerWidget.tsx @@ -13,11 +13,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; -import { isUndefined } from 'lodash'; +import { isUndefined, lowerCase } from 'lodash'; import React, { Fragment } from 'react'; +import { ADMIN_ONLY_ACCESSIBLE_SECTION } from '../../../enums/common.enum'; import { Operation } from '../../../generated/entity/policies/policy'; import { EntityReference } from '../../../generated/type/entityReference'; import { useAuth } from '../../../hooks/authHooks'; +import { hasEditAccess } from '../../../utils/CommonUtils'; import { getTitleCase } from '../../../utils/EntityUtils'; import { isCurrentUserAdmin } from '../../../utils/UserDataUtils'; import { Button } from '../../buttons/Button/Button'; @@ -36,6 +38,7 @@ interface OwnerWidgetProps { allowTeamOwner?: boolean; ownerName: string; entityType?: string; + manageSectionType?: string; statusOwner: Status; owner?: EntityReference; listOwners: { @@ -56,10 +59,10 @@ interface OwnerWidgetProps { } const OwnerWidget = ({ + manageSectionType, isJoinableActionAllowed, teamJoinable, isAuthDisabled, - hasEditAccess, ownerName, entityType, listVisible, @@ -74,7 +77,7 @@ const OwnerWidget = ({ handleOwnerSelection, handleSearchOwnerDropdown, }: OwnerWidgetProps) => { - const { userPermissions } = useAuth(); + const { userPermissions, isAdminUser } = useAuth(); const getOwnerGroup = () => { return allowTeamOwner ? ['Teams', 'Users'] : ['Users']; @@ -100,6 +103,26 @@ const OwnerWidget = ({ } }; + const isOwnerEditable = () => { + if (!isAuthDisabled && !isAdminUser) { + if (ownerName) { + return hasEditAccess(owner?.type || '', owner?.id || ''); + } else { + if ( + Object.values(ADMIN_ONLY_ACCESSIBLE_SECTION).find( + (s) => s === lowerCase(manageSectionType) + ) + ) { + return false; + } + + return userPermissions[Operation.UpdateOwner]; + } + } + + return true; + }; + const ownerDescription = entityType === 'team' ? 'The owner of the team can manage the team by adding or removing users. Add or update Team ownership here' @@ -124,22 +147,12 @@ const OwnerWidget = ({

You do not have permissions to update the owner.

} - isOwner={hasEditAccess} - permission={Operation.UpdateOwner} + isOwner={isOwnerEditable()} position="left">