From 64f6ec4e650812265f09debc19d2e29155df1821 Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Sat, 23 Apr 2022 13:54:59 -0700 Subject: [PATCH] Fix #4422: UI: Fix ownership text in Manage tab (#4423) --- .../auth-provider/AuthProvider.tsx | 2 +- .../ManageTab/ManageTab.component.tsx | 1 + .../EntityDeleteModal/EntityDeleteModal.tsx | 5 ++- .../common/DeleteWidget/DeleteWidget.tsx | 13 +++++--- .../common/OwnerWidget/OwnerWidget.tsx | 11 +++++-- .../src/main/resources/ui/src/jsons/en.ts | 4 +-- .../resources/ui/src/utils/EntityUtils.tsx | 31 +++++++++---------- 7 files changed, 41 insertions(+), 26 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx index ef1406fe23e..cf6ed4d8eb0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/authentication/auth-provider/AuthProvider.tsx @@ -93,7 +93,7 @@ export const AuthProvider = ({ const oidcUserToken = localStorage.getItem(oidcTokenKey); const [isUserAuthenticated, setIsUserAuthenticated] = useState( - Boolean(oidcUserToken || localStorage.getItem('okta-token-storage')) + Boolean(oidcUserToken) ); const [isAuthDisabled, setIsAuthDisabled] = useState(false); const [loading, setLoading] = useState(true); 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 d12513ddce5..021364f7fd9 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 @@ -309,6 +309,7 @@ const ManageTab: FunctionComponent = ({ {!hideOwner && ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx index 93f7e4914a7..e8eb18c60e4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Modals/EntityDeleteModal/EntityDeleteModal.tsx @@ -19,6 +19,7 @@ import React, { useCallback, useState, } from 'react'; +import { getTitleCase } from '../../../utils/EntityUtils'; import { Button } from '../../buttons/Button/Button'; import Loader from '../../Loader/Loader'; @@ -74,7 +75,9 @@ const EntityDeleteModal: FC = ({

{bodyText || - `Once you delete this ${entityType}, it will be removed permanently`} + `Once you delete this ${getTitleCase( + entityType + )}, it will be removed permanently`}

Type DELETE to confirm diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.tsx index 1f26797a59a..b9a6fc398bb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DeleteWidget/DeleteWidget.tsx @@ -18,6 +18,7 @@ import { deleteEntity } from '../../../axiosAPIs/miscAPI'; import { ENTITY_DELETE_STATE } from '../../../constants/entity.constants'; import { EntityType } from '../../../enums/entity.enum'; import jsonData from '../../../jsons/en'; +import { getTitleCase } from '../../../utils/EntityUtils'; import { showErrorToast, showSuccessToast } from '../../../utils/ToastUtils'; import EntityDeleteModal from '../../Modals/EntityDeleteModal/EntityDeleteModal'; import DeleteWidgetBody from './DeleteWidgetBody'; @@ -48,8 +49,12 @@ const DeleteWidget = ({ useState(ENTITY_DELETE_STATE); const prepareDeleteMessage = (softDelete = false) => { - const softDeleteText = `Soft deleting will deactivate the ${entityName}. This will disable any discovery, read or write operations on ${entityName}`; - const hardDeleteText = `Once you delete this ${entityType}, it will be removed permanently`; + const softDeleteText = `Soft deleting will deactivate the ${getTitleCase( + entityName + )}. This will disable any discovery, read or write operations on ${entityName}`; + const hardDeleteText = `Once you delete this ${getTitleCase( + entityType + )}, it will be removed permanently`; return softDelete ? softDeleteText : hardDeleteText; }; @@ -146,7 +151,7 @@ const DeleteWidget = ({ buttonText="Soft delete" description={prepareDeleteMessage(true)} hasPermission={hasPermission} - header={`Soft delete ${entityType} ${entityName}`} + header={`Soft delete ${getTitleCase(entityType)} ${entityName}`} isOwner={isAdminUser} onClick={() => handleOnEntityDelete(true)} /> @@ -157,7 +162,7 @@ const DeleteWidget = ({ buttonText="Delete" description={prepareDeleteMessage()} hasPermission={hasPermission} - header={`Delete ${entityType} ${entityName}`} + header={`Delete ${getTitleCase(entityType)} ${entityName}`} isOwner={isAdminUser} onClick={() => handleOnEntityDelete(false)} /> 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 d6b4f1ac26a..dbea24aa76e 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 @@ -17,6 +17,7 @@ import { isUndefined } from 'lodash'; import React, { Fragment } from 'react'; import { Operation } from '../../../generated/entity/policies/policy'; import { useAuth } from '../../../hooks/authHooks'; +import { getTitleCase } from '../../../utils/EntityUtils'; import { Button } from '../../buttons/Button/Button'; import DropDownList from '../../dropdown/DropDownList'; import Loader from '../../Loader/Loader'; @@ -32,6 +33,7 @@ interface OwnerWidgetProps { teamJoinable?: boolean; allowTeamOwner?: boolean; ownerName: string; + entityType?: string; statusOwner: Status; owner: string; listOwners: { @@ -54,6 +56,7 @@ const OwnerWidget = ({ isAuthDisabled, hasEditAccess, ownerName, + entityType, listVisible, owner, allowTeamOwner, @@ -89,6 +92,11 @@ const OwnerWidget = ({ } }; + const ownerDescription = + entityType === 'team' + ? 'The owner of the team can manage the team by adding or removing users. Add or update Team ownership here' + : `Add or update ${getTitleCase(entityType)} ownership here`; + return (

@@ -97,8 +105,7 @@ const OwnerWidget = ({

Owner

- The Team owner details are found here. Team ownership can be - changed + {ownerDescription}

diff --git a/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts b/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts index d680b7415b4..29d45b82930 100644 --- a/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts +++ b/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts @@ -154,11 +154,11 @@ const jsonData = { }, label: { 'delete-entity-text': - 'Once you delete this entity, it would be removed permanently.', + 'Once you delete this entity, it will be removed permanently.', }, message: { 'no-services': 'No services', - 'fail-to-deploy-pipeline': 'Failed to deploy Ingestion Pipeline', + 'fail-to-deploy-pipeline': 'Failed to deploy Ingestion Pipeline!', }, }; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx index 3d2df150bba..0ba6ad0f492 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx @@ -12,7 +12,14 @@ */ import classNames from 'classnames'; -import { isEmpty, isNil, isString, isUndefined } from 'lodash'; +import { + camelCase, + isEmpty, + isNil, + isString, + isUndefined, + startCase, +} from 'lodash'; import { Bucket, ExtraInfo, LeafNodes, LineagePos } from 'Models'; import React from 'react'; import Avatar from '../components/common/avatar/Avatar'; @@ -128,11 +135,7 @@ export const getEntityOverview = ( name: 'Owner', value: ownerValue?.displayName || ownerValue?.name || '--', url: getTeamAndUserDetailsPath(owner?.name || ''), - isLink: ownerValue - ? ownerValue.type === 'team' - ? true - : false - : false, + isLink: ownerValue ? ownerValue.type === 'team' : false, }, { name: 'Tier', @@ -206,11 +209,7 @@ export const getEntityOverview = ( name: 'Owner', value: ownerValue?.displayName || ownerValue?.name || '--', url: getTeamAndUserDetailsPath(owner?.name || ''), - isLink: ownerValue - ? ownerValue.type === 'team' - ? true - : false - : false, + isLink: ownerValue ? ownerValue.type === 'team' : false, }, { name: 'Tier', @@ -254,11 +253,7 @@ export const getEntityOverview = ( name: 'Owner', value: ownerValue?.displayName || ownerValue?.name || '--', url: getTeamAndUserDetailsPath(owner?.name || ''), - isLink: ownerValue - ? ownerValue.type === 'team' - ? true - : false - : false, + isLink: ownerValue ? ownerValue.type === 'team' : false, }, { name: 'Tier', @@ -543,3 +538,7 @@ export const isColumnTestSupported = (dataType: string) => { getDataTypeString(dataType) as PrimaryTableDataTypes ); }; + +export const getTitleCase = (text?: string) => { + return text ? startCase(camelCase(text)) : ''; +};