From bf079a019e5a3a9743b2f843f16f11b39701a74a Mon Sep 17 00:00:00 2001 From: darth-coder00 <86726556+darth-coder00@users.noreply.github.com> Date: Tue, 8 Mar 2022 21:51:48 +0530 Subject: [PATCH] Fixes/08 03 2022 (#3273) * Fixes: Misc issue fixes * Fixed issues for adding Glossary terms as tags * Fixed UI unit tests --- .../AddGlossary/AddGlossary.component.tsx | 25 ++-- .../AddGlossaryTerm.component.tsx | 25 ++-- .../AddGlossaryTermPage.component.tsx | 4 +- .../src/components/AddWebhook/AddWebhook.tsx | 26 ++-- .../DashboardDetails.component.tsx | 29 ++-- .../DashboardDetails.test.tsx | 12 ++ .../DatasetDetails.component.tsx | 4 +- .../DatasetDetails/DatasetDetails.test.tsx | 12 ++ .../EntityLineage/EntityLineage.component.tsx | 4 +- .../EntityTable/EntityTable.component.tsx | 1 + .../src/components/Explore/Explore.test.tsx | 12 ++ .../Glossary/Glossary.component.tsx | 4 +- .../Glossary/GlossaryV1.component.tsx | 4 +- .../Ingestion/Ingestion.component.tsx | 4 +- .../components/Ingestion/Ingestion.test.tsx | 12 ++ .../ManageTab/ManageTab.component.tsx | 4 +- .../components/ManageTab/ManageTab.test.tsx | 12 ++ .../MyAssetStats/MyAssetStats.test.tsx | 12 ++ .../ui/src/components/MyData/MyData.test.tsx | 12 ++ .../PipelineDetails.component.tsx | 21 +-- .../TableProfiler/TableProfiler.component.tsx | 4 +- .../TopicDetails/TopicDetails.component.tsx | 21 +-- .../components/Webhooks/Webhooks.interface.ts | 4 +- .../ui/src/components/Webhooks/Webhooks.tsx | 132 ++++++++++++------ .../common/entityPageInfo/EntityPageInfo.tsx | 33 ++++- .../ErrorPlaceHolderES.tsx | 4 +- .../non-admin-action/NonAdminAction.test.tsx | 12 ++ .../non-admin-action/NonAdminAction.tsx | 4 +- .../webhook-data-card/WebhookDataCardBody.tsx | 1 + .../dropdown/AnchorDropDownList.tsx | 4 +- .../dropdown/CheckBoxDropDownList.tsx | 4 +- .../src/components/dropdown/DropDown.test.tsx | 12 ++ .../src/components/dropdown/DropDownList.tsx | 2 +- .../my-data-details/SchemaTable.test.tsx | 12 ++ .../tags-container/tags-container.tsx | 2 +- .../AddGlossary/AddGlossaryPage.component.tsx | 4 +- .../AddWebhookPage.component.tsx | 6 +- .../AddWebhookPage/AddWebhookPage.test.tsx | 12 ++ .../DashboardDetailsPage.component.tsx | 2 +- .../EditWebhookPage.component.tsx | 10 +- .../GlossaryPage/GlossaryPageV1.component.tsx | 12 +- .../GlossaryTermPage.component.tsx | 4 +- .../GlossaryTermPage.test.tsx | 12 ++ .../pages/RolesPage/RolesPage.component.tsx | 4 +- .../ui/src/pages/RolesPage/RolesPage.test.tsx | 12 ++ .../WebhooksPage/WebhooksPage.component.tsx | 9 +- .../src/pages/database-details/index.test.tsx | 12 ++ .../ui/src/pages/service/index.test.tsx | 12 ++ .../resources/ui/src/pages/service/index.tsx | 4 +- .../ui/src/pages/services/index.test.tsx | 12 ++ .../resources/ui/src/pages/services/index.tsx | 4 +- .../ui/src/pages/tags/index.test.tsx | 12 ++ .../resources/ui/src/pages/tags/index.tsx | 4 +- .../ui/src/pages/teams/UserCard.test.tsx | 12 ++ .../resources/ui/src/pages/teams/UserCard.tsx | 4 +- .../ui/src/pages/teams/index.test.tsx | 12 ++ .../resources/ui/src/pages/teams/index.tsx | 4 +- .../resources/ui/src/utils/CommonUtils.tsx | 14 +- .../src/main/resources/ui/tailwind.config.js | 8 +- 59 files changed, 491 insertions(+), 200 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossary/AddGlossary.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossary/AddGlossary.component.tsx index 076a1c286a8..18ef2a13f3c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossary/AddGlossary.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossary/AddGlossary.component.tsx @@ -162,25 +162,16 @@ const AddGlossary = ({ const fetchRightPanel = () => { return ( <> -
Configure Your Glossary
+
Configure Glossary
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. -
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. + A Glossary is a controlled vocabulary used to define the concepts and + terminology in an organization. Glossaries can be specific to a + certain domain (for e.g., Business Glossary, Technical Glossary). In + the glossary, the standard terms and concepts can be defined along + with the synonyms, and related terms. Control can be established over + how and who can add the terms in the glossary.
- {/* {getDocButton('Read Webhook Doc', '', 'webhook-doc')} */} + {/* {getDocButton('Read Glossary Doc', '', 'glossary-doc')} */} ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx index 6c0cee91008..e22e269874c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx @@ -249,25 +249,16 @@ const AddGlossaryTerm = ({ const fetchRightPanel = () => { return ( <> -
Configure Your Glossary
+
Configure Glossary Term
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. -
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. + Every term in the glossary has a unique definition. Along with + defining the standard term for a concept, the synonyms as well as + related terms (for e.g., parent and child terms) can be specified. + References can be added to the assets related to the terms. New terms + can be added or updated to the Glossary. The glossary terms can be + reviewed by certain users, who can accept or reject the terms.
- {/* {getDocButton('Read Webhook Doc', '', 'webhook-doc')} */} + {/* {getDocButton('Read Glossary Term Doc', '', 'glossary-term-doc')} */} ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx index 66b9812ffe7..1491d4962c4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx @@ -15,6 +15,7 @@ import { AxiosError, AxiosResponse } from 'axios'; import { LoadingState } from 'Models'; import React, { useEffect, useState } from 'react'; import { useHistory, useParams } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { addGlossaryTerm, getGlossariesByName, @@ -35,7 +36,8 @@ const AddGlossaryTermPage = () => { useParams<{ [key: string]: string }>(); const showToast = useToastContext(); const history = useHistory(); - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [status, setStatus] = useState('initial'); const [isLoading, setIsLoading] = useState(true); const [glossaryData, setGlossaryData] = useState(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddWebhook/AddWebhook.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddWebhook/AddWebhook.tsx index c2d5618ce3e..5e2cfa4a5e9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddWebhook/AddWebhook.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/AddWebhook/AddWebhook.tsx @@ -439,23 +439,17 @@ const AddWebhook: FunctionComponent = ({ const fetchRightPanel = () => { return ( <> -
Configure Your Webhook
+
Configure Webhooks
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. -
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad - minim veniam, quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla - pariatur. Excepteur sint occaecat cupidatat non proident, sunt in - culpa qui officia deserunt mollit anim id est laborum. + OpenMetadata can be configured to automatically send out event + notifications to registered webhooks. Enter the webhook name, and an + Endpoint URL to receive the HTTP call back on. Use Event Filters to + only receive notifications based on events of interest, like when an + entity is created, updated, or deleted; and for the entities your + application is interested in. Add a description to help people + understand the purpose of the webhook and to keep track of the use + case. Use advanced configuration to set up a shared secret key to + verify the webhook events using HMAC signature.
{getDocButton('Read Webhook Doc', '', 'webhook-doc')} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx index ca4d08414b7..2d5f54ebc90 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DashboardDetails/DashboardDetails.component.tsx @@ -16,13 +16,13 @@ import { compare } from 'fast-json-patch'; import { EntityTags } from 'Models'; import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { getTeamDetailsPath } from '../../constants/constants'; import { EntityType } from '../../enums/entity.enum'; import { Dashboard } from '../../generated/entity/data/dashboard'; import { Operation } from '../../generated/entity/policies/accessControl/rule'; import { EntityReference, User } from '../../generated/entity/teams/user'; import { LabelType, State, TagLabel } from '../../generated/type/tagLabel'; -import { useAuth } from '../../hooks/authHooks'; import { getCurrentUserId, getHtmlForNonAdminAction, @@ -92,7 +92,7 @@ const DashboardDetails = ({ createThread, dashboardFQN, }: DashboardDetailsProps) => { - const { isAuthDisabled } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [isEdit, setIsEdit] = useState(false); const [followersCount, setFollowersCount] = useState(0); const [isFollowing, setIsFollowing] = useState(false); @@ -245,22 +245,9 @@ const DashboardDetails = ({ } }; - const onTagUpdate = (selectedTags?: Array) => { + const onTagUpdate = (selectedTags?: Array) => { if (selectedTags) { - const prevTags = - dashboardDetails?.tags?.filter((tag) => - selectedTags.includes(tag?.tagFQN as string) - ) || []; - const newTags = selectedTags - .filter((tag) => { - return !prevTags?.map((prevTag) => prevTag.tagFQN).includes(tag); - }) - .map((tag) => ({ - labelType: LabelType.Manual, - state: State.Confirmed, - tagFQN: tag, - })); - const updatedTags = [...prevTags, ...newTags]; + const updatedTags = [...(tier ? [tier] : []), ...selectedTags]; const updatedDashboard = { ...dashboardDetails, tags: updatedTags }; tagUpdateHandler(updatedDashboard); } @@ -304,7 +291,10 @@ const DashboardDetails = ({ } }; - const handleChartTagSelection = (selectedTags?: Array) => { + const handleChartTagSelection = ( + selectedTags?: Array, + allTags?: Array + ) => { if (selectedTags && editChartTags) { const prevTags = editChartTags.chart.tags?.filter((tag) => selectedTags.some((selectedTag) => selectedTag.tagFQN === tag.tagFQN) @@ -319,6 +309,7 @@ const DashboardDetails = ({ .map((tag) => ({ labelType: 'Manual', state: 'Confirmed', + source: (allTags || []).includes(tag.tagFQN) ? 'Tag' : 'Glossary', tagFQN: tag.tagFQN, })); @@ -554,7 +545,7 @@ const DashboardDetails = ({ handleChartTagSelection(); }} onSelectionChange={(tags) => { - handleChartTagSelection(tags); + handleChartTagSelection(tags, tagList); }}> {chart.tags?.length ? ( - - - {data.map((webhook, index) => ( -
- -
- ))} - {Boolean(!isNil(paging.after) || !isNil(paging.before)) && ( - - )} - - - ) : ( - + const fetchErrorPlaceHolder = (message: string) => { + return ( -

No webhooks found

+

{message}

+ ); + }; + + useEffect(() => { + setFilteredData(getFilteredWebhooks()); + }, [data, selectedStatus]); + + return data.length ? ( + +
+ {filteredData.length ? ( + <> +
+ + + +
+ {filteredData.map((webhook, index) => ( +
+ +
+ ))} + {Boolean(!isNil(paging.after) || !isNil(paging.before)) && ( + + )} + + ) : ( + fetchErrorPlaceHolder('No webhooks found for applied filters') + )} +
+ ) : ( + {fetchErrorPlaceHolder('No webhooks found')} ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.tsx index 45c58cc5a1c..4ca694632a0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/entityPageInfo/EntityPageInfo.tsx @@ -18,7 +18,7 @@ import React, { Fragment, useEffect, useState } from 'react'; import { FOLLOWERS_VIEW_CAP, LIST_SIZE } from '../../../constants/constants'; import { Operation } from '../../../generated/entity/policies/accessControl/rule'; import { User } from '../../../generated/entity/teams/user'; -import { TagLabel } from '../../../generated/type/tagLabel'; +import { LabelType, State, TagLabel } from '../../../generated/type/tagLabel'; import { getHtmlForNonAdminAction } from '../../../utils/CommonUtils'; import { getEntityFeedLink, getInfoElements } from '../../../utils/EntityUtils'; import SVGIcons, { Icons } from '../../../utils/SvgUtils'; @@ -53,7 +53,7 @@ type Props = { entityFieldThreads?: EntityFieldThreads[]; onThreadLinkSelect?: (value: string) => void; followHandler?: () => void; - tagsHandler?: (selectedTags?: Array) => void; + tagsHandler?: (selectedTags?: Array) => void; versionHandler?: () => void; }; @@ -85,13 +85,34 @@ const EntityPageInfo = ({ const [entityFollowers, setEntityFollowers] = useState>(followersList); const [isViewMore, setIsViewMore] = useState(false); - const handleTagSelection = (selectedTags?: Array) => { - tagsHandler?.(selectedTags?.map((tag) => tag.tagFQN)); - setIsEditable(false); - }; const [tagList, setTagList] = useState>([]); const [isTagLoading, setIsTagLoading] = useState(false); + const handleTagSelection = (selectedTags?: Array) => { + if (selectedTags) { + const prevTags = + tags?.filter((tag) => + selectedTags + .map((selTag) => selTag.tagFQN) + .includes(tag?.tagFQN as string) + ) || []; + const newTags = selectedTags + .filter((tag) => { + return !prevTags + ?.map((prevTag) => prevTag.tagFQN) + .includes(tag.tagFQN); + }) + .map((tag) => ({ + labelType: LabelType.Manual, + state: State.Confirmed, + source: tagList.includes(tag.tagFQN) ? 'Tag' : 'Glossary', + tagFQN: tag.tagFQN, + })); + tagsHandler?.([...prevTags, ...newTags]); + } + setIsEditable(false); + }; + const getSelectedTags = () => { return tier?.tagFQN ? [ diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolderES.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolderES.tsx index 86573891e8c..b3d859079a1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolderES.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolderES.tsx @@ -15,7 +15,7 @@ import { uniqueId } from 'lodash'; import { observer } from 'mobx-react'; import React from 'react'; import AppState from '../../../AppState'; -import { useAuth } from '../../../hooks/authHooks'; +import { useAuthContext } from '../../../auth-provider/AuthProvider'; type Props = { type: 'error' | 'noData'; @@ -54,7 +54,7 @@ const stepsData = [ ]; const ErrorPlaceHolderES = ({ type, errorMessage, query = '' }: Props) => { - const { isAuthDisabled } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const getUserDisplayName = () => { return isAuthDisabled ? AppState.users?.length > 0 diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx index 8d9afdcbcf1..6f3627f4cbc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.test.tsx @@ -27,6 +27,18 @@ jest.mock('../../../hooks/authHooks', () => ({ useAuth: jest.fn(() => mockAuth), })); +jest.mock('../../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../popover/PopOver', () => { return jest .fn() diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.tsx index 421e884f3e9..1a447274221 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/non-admin-action/NonAdminAction.tsx @@ -13,6 +13,7 @@ import { UserPermissions } from 'Models'; import React from 'react'; +import { useAuthContext } from '../../../auth-provider/AuthProvider'; import { Operation } from '../../../generated/entity/policies/accessControl/rule'; import { useAuth } from '../../../hooks/authHooks'; import PopOver from '../popover/PopOver'; @@ -38,7 +39,8 @@ const NonAdminAction = ({ trigger = 'mouseenter', permission, }: Props) => { - const { isAuthDisabled, isAdminUser, userPermissions } = useAuth(); + const { isAdminUser, userPermissions } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const handleCapturedEvent = ( e: React.KeyboardEvent | React.MouseEvent diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/webhook-data-card/WebhookDataCardBody.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/webhook-data-card/WebhookDataCardBody.tsx index ed0aac61bb8..5770fa4fc0b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/webhook-data-card/WebhookDataCardBody.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/webhook-data-card/WebhookDataCardBody.tsx @@ -40,6 +40,7 @@ const WebhookDataCardBody: FunctionComponent = ({ {startCase(status)} | + Url:  {endpoint}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/AnchorDropDownList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/AnchorDropDownList.tsx index 1c99b701383..6981090b0c8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/AnchorDropDownList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/AnchorDropDownList.tsx @@ -14,12 +14,14 @@ import classNames from 'classnames'; import React, { Fragment } from 'react'; import { Link } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { useAuth } from '../../hooks/authHooks'; import SVGIcons from '../../utils/SvgUtils'; import { DropDownListItem, DropDownListProp } from './types'; const AnchorDropDownList = ({ dropDownList, setIsOpen }: DropDownListProp) => { - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); return ( <> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/CheckBoxDropDownList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/CheckBoxDropDownList.tsx index da708980da3..4c80cbfb3fa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/CheckBoxDropDownList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/CheckBoxDropDownList.tsx @@ -12,6 +12,7 @@ */ import React, { Fragment } from 'react'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { useAuth } from '../../hooks/authHooks'; import { DropDownListItem, DropDownListProp } from './types'; @@ -22,7 +23,8 @@ const CheckBoxDropDownList = ({ selectedItems, disabledItems, }: DropDownListProp) => { - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); return ( <> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDown.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDown.test.tsx index dbdde82c470..196b81d0cdf 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDown.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDown.test.tsx @@ -21,6 +21,18 @@ import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import DropDown from './DropDown'; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + const mockDropDown = [ { name: 'Test1', to: '/test1', disabled: false }, { name: 'Test2', to: '/test2', disabled: false }, diff --git a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDownList.tsx b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDownList.tsx index ddfe6c5263b..a84c01b8402 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDownList.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/dropdown/DropDownList.tsx @@ -83,7 +83,7 @@ const DropDownList: FunctionComponent = ({ key={index} role="menuitem" onClick={(e) => !item.disabled && onSelect?.(e, item.value)}> -

+

{item.name}

diff --git a/openmetadata-ui/src/main/resources/ui/src/components/my-data-details/SchemaTable.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/my-data-details/SchemaTable.test.tsx index edd1afbc050..b361b4621a1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/my-data-details/SchemaTable.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/my-data-details/SchemaTable.test.tsx @@ -24,6 +24,18 @@ import { } from '../../generated/entity/data/table'; import SchemaTable from './SchemaTable'; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../common/rich-text-editor/RichTextEditorPreviewer', () => { return jest.fn().mockReturnValue(

RichTextEditorPreviewer

); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx b/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx index 26fc967a9b4..daa4ee9427d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/tags-container/tags-container.tsx @@ -135,7 +135,7 @@ const TagsContainer: FunctionComponent = ({ }) .map((glossary) => { return { - name: glossary.name, + name: glossary.fqdn, value: glossary.fqdn, }; }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossary/AddGlossaryPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossary/AddGlossaryPage.component.tsx index 551cc73b34c..4ff6e7ef959 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossary/AddGlossaryPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossary/AddGlossaryPage.component.tsx @@ -2,6 +2,7 @@ import { AxiosError } from 'axios'; import { LoadingState } from 'Models'; import React, { FunctionComponent, useState } from 'react'; import { useHistory } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { addGlossaries } from '../../axiosAPIs/glossaryAPI'; import AddGlossary from '../../components/AddGlossary/AddGlossary.component'; import PageContainerV1 from '../../components/containers/PageContainerV1'; @@ -12,7 +13,8 @@ import useToastContext from '../../hooks/useToastContext'; import { getTagCategories, getTaglist } from '../../utils/TagsUtils'; const AddGlossaryPage: FunctionComponent = () => { - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const history = useHistory(); const showToast = useToastContext(); const [tagList, setTagList] = useState>([]); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.component.tsx index 003ce0afe5f..8b0727a46a8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.component.tsx @@ -15,6 +15,7 @@ import { AxiosError } from 'axios'; import { LoadingState } from 'Models'; import React, { FunctionComponent, useState } from 'react'; import { useHistory } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { addWebhook } from '../../axiosAPIs/webhookAPI'; import AddWebhook from '../../components/AddWebhook/AddWebhook'; import PageContainerV1 from '../../components/containers/PageContainerV1'; @@ -25,7 +26,8 @@ import { useAuth } from '../../hooks/authHooks'; import useToastContext from '../../hooks/useToastContext'; const AddWebhookPage: FunctionComponent = () => { - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const history = useHistory(); const showToast = useToastContext(); const [status, setStatus] = useState('initial'); @@ -51,7 +53,7 @@ const AddWebhookPage: FunctionComponent = () => { .catch((err: AxiosError) => { showToast({ variant: 'error', - body: err.message || 'Something went wrong!', + body: err.response?.data?.message || 'Something went wrong!', }); setStatus('initial'); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.test.tsx index 57330798ba5..c0d0f746371 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/AddWebhookPage/AddWebhookPage.test.tsx @@ -11,6 +11,18 @@ jest.mock('../../components/containers/PageContainerV1', () => { )); }); +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../../components/AddWebhook/AddWebhook', () => { return jest.fn().mockImplementation(() =>
AddWebhookComponent
); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DashboardDetailsPage/DashboardDetailsPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DashboardDetailsPage/DashboardDetailsPage.component.tsx index 7fbcf46b002..793a1c34073 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/DashboardDetailsPage/DashboardDetailsPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/DashboardDetailsPage/DashboardDetailsPage.component.tsx @@ -159,7 +159,7 @@ const DashboardDetailsPage = () => { const saveUpdatedDashboardData = ( updatedData: Dashboard ): Promise => { - const jsonPatch = compare(DashboardDetails, updatedData); + const jsonPatch = compare(dashboardDetails, updatedData); return patchDashboardDetails( dashboardId, diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/EditWebhookPage/EditWebhookPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/EditWebhookPage/EditWebhookPage.component.tsx index 19e3ff1ca48..e381c72f835 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/EditWebhookPage/EditWebhookPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/EditWebhookPage/EditWebhookPage.component.tsx @@ -15,6 +15,7 @@ import { AxiosError } from 'axios'; import { LoadingState } from 'Models'; import React, { FunctionComponent, useEffect, useState } from 'react'; import { useHistory, useParams } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { deleteWebhook, getWebhookByName, @@ -32,7 +33,8 @@ import useToastContext from '../../hooks/useToastContext'; const EditWebhookPage: FunctionComponent = () => { const { webhookName } = useParams<{ [key: string]: string }>(); - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const history = useHistory(); const showToast = useToastContext(); const [isLoading, setIsLoading] = useState(true); @@ -49,7 +51,7 @@ const EditWebhookPage: FunctionComponent = () => { .catch((err: AxiosError) => { showToast({ variant: 'error', - body: err.message || 'Something went wrong!', + body: err.response?.data?.message || 'Something went wrong!', }); }) .finally(() => setIsLoading(false)); @@ -77,7 +79,7 @@ const EditWebhookPage: FunctionComponent = () => { .catch((err: AxiosError) => { showToast({ variant: 'error', - body: err.message || 'Something went wrong!', + body: err.response?.data?.message || 'Something went wrong!', }); setStatus('initial'); }); @@ -93,7 +95,7 @@ const EditWebhookPage: FunctionComponent = () => { .catch((err: AxiosError) => { showToast({ variant: 'error', - body: err.message || 'Something went wrong!', + body: err.response?.data?.message || 'Something went wrong!', }); setDeleteStatus('initial'); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPageV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPageV1.component.tsx index 2b3d8d3bb49..59d08347407 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPageV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryPage/GlossaryPageV1.component.tsx @@ -23,6 +23,7 @@ import { } from 'Models'; import React, { useCallback, useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { deleteGlossary, deleteGlossaryTerm, @@ -37,7 +38,6 @@ import { getSuggestions, searchData } from '../../axiosAPIs/miscAPI'; import PageContainerV1 from '../../components/containers/PageContainerV1'; import GlossaryV1 from '../../components/Glossary/GlossaryV1.component'; import Loader from '../../components/Loader/Loader'; -import { WILD_CARD_CHAR } from '../../constants/char.constants'; import { getAddGlossaryTermsPath, PAGE_SIZE, @@ -63,7 +63,8 @@ const GlossaryPageV1 = () => { // const { glossaryName, glossaryTermsFQN } = // useParams<{ [key: string]: string }>(); - const { isAdminUser, isAuthDisabled } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const history = useHistory(); const showToast = useToastContext(); const [isLoading, setIsLoading] = useState(true); @@ -394,12 +395,13 @@ const GlossaryPageV1 = () => { }; const fetchGlossaryTermAssets = (data: GlossaryTerm, forceReset = false) => { - if (data?.fullyQualifiedName) { + if (data?.fullyQualifiedName || data?.name) { + const tagName = data?.fullyQualifiedName || data?.name; // Incase fqn is not fetched yet. searchData( - WILD_CARD_CHAR, + '', forceReset ? 1 : assetData.currPage, PAGE_SIZE, - `(tags:${data.fullyQualifiedName})`, + `(tags:${tagName})`, '', '', myDataSearchIndex diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.component.tsx index 8eabf544078..933754fe03c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.component.tsx @@ -17,6 +17,7 @@ import { isEmpty } from 'lodash'; import { Key } from 'rc-tree/lib/interface'; import React, { FunctionComponent, useEffect, useState } from 'react'; import { useLocation, useParams } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { getGlossariesByName, getGlossaryTermByFQN, @@ -36,7 +37,8 @@ import { getTagCategories, getTaglist } from '../../utils/TagsUtils'; const GlossaryTermPage: FunctionComponent = () => { const showToast = useToastContext(); - const { isAdminUser, isAuthDisabled } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const { glossaryName, glossaryTermsFQN } = useParams<{ [key: string]: string }>(); const [isLoading, setIsLoading] = useState(true); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.test.tsx index 76f4fc9417c..94815857b98 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/GlossaryTermPage/GlossaryTermPage.test.tsx @@ -6,6 +6,18 @@ jest.mock('../../components/GlossaryTerms/GlossaryTerms.component', () => { return jest.fn().mockReturnValue(
GlossaryTerms.component
); }); +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../../axiosAPIs/glossaryAPI', () => ({ getGlossariesByName: jest.fn().mockImplementation(() => Promise.resolve()), getGlossaryTermsById: jest.fn().mockImplementation(() => Promise.resolve()), diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.component.tsx index 33b58102c60..7060f2cb715 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.component.tsx @@ -19,6 +19,7 @@ import { observer } from 'mobx-react'; import { FormErrorData } from 'Models'; import React, { Fragment, useEffect, useState } from 'react'; import AppState from '../../AppState'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { createRole, getPolicy, @@ -66,7 +67,8 @@ const getActiveTabClass = (tab: number, currentTab: number) => { const RolesPage = () => { const showToast = useToastContext(); const [roles, setRoles] = useState>([]); - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [currentRole, setCurrentRole] = useState(); const [currentPolicy, setCurrentPolicy] = useState(); const [error, setError] = useState(''); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.test.tsx index 83059799094..0782779f455 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/RolesPage/RolesPage.test.tsx @@ -32,6 +32,18 @@ jest.mock('../../axiosAPIs/rolesAPI', () => ({ updateRole: jest.fn(), })); +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock( '../../components/containers/PageLayout', () => diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/WebhooksPage/WebhooksPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/WebhooksPage/WebhooksPage.component.tsx index 2fd406cae45..9e1f47537bf 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/WebhooksPage/WebhooksPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/WebhooksPage/WebhooksPage.component.tsx @@ -24,7 +24,7 @@ import { pagingObject, ROUTES, } from '../../constants/constants'; -import { Webhook } from '../../generated/entity/events/webhook'; +import { Status, Webhook } from '../../generated/entity/events/webhook'; import useToastContext from '../../hooks/useToastContext'; const WebhooksPage: FunctionComponent = () => { @@ -33,6 +33,7 @@ const WebhooksPage: FunctionComponent = () => { const [isLoading, setIsLoading] = useState(true); const [paging, setPaging] = useState(pagingObject); const [data, setData] = useState>([]); + const [selectedStatus, setSelectedStatus] = useState([]); const fetchData = (paging?: string) => { setIsLoading(true); @@ -64,6 +65,10 @@ const WebhooksPage: FunctionComponent = () => { fetchData(pagingString); }; + const handleStatusFilter = (status: Status[]) => { + setSelectedStatus(status); + }; + const handleAddWebhook = () => { history.push(ROUTES.ADD_WEBHOOK); }; @@ -82,9 +87,11 @@ const WebhooksPage: FunctionComponent = () => { ) : ( diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/database-details/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/database-details/index.test.tsx index 7bd6568b501..80e97e31568 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/database-details/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/database-details/index.test.tsx @@ -79,6 +79,18 @@ const mockTableData = { paging: { after: 'ZMbpLOqQQsREk_7DmEOr', total: 12 }, }; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock( '../../components/common/rich-text-editor/RichTextEditorPreviewer', () => { diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.test.tsx index 7cc0951fe0a..5eb9d3b7a30 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.test.tsx @@ -23,6 +23,18 @@ import { MemoryRouter } from 'react-router-dom'; import { act } from 'react-test-renderer'; import ServicePage from './index'; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + const mockData = { description: '', href: 'link', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx index 9ab265f7f68..963f6168890 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx @@ -25,6 +25,7 @@ import { import React, { Fragment, FunctionComponent, useEffect, useState } from 'react'; import { Link, useHistory, useParams } from 'react-router-dom'; import AppState from '../../AppState'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { addAirflowPipeline, deleteAirflowPipelineById, @@ -113,7 +114,8 @@ const ServicePage: FunctionComponent = () => { const { serviceFQN, serviceType, serviceCategory, tab } = useParams() as Record; const history = useHistory(); - const { isAdminUser, isAuthDisabled } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [serviceName, setServiceName] = useState( serviceCategory || getServiceCategoryFromType(serviceType) ); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx index 8fee000a542..c1410a61c55 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.test.tsx @@ -136,6 +136,18 @@ const mockPipelineService = { }, }; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../../axiosAPIs/serviceAPI', () => ({ deleteService: jest.fn(), getServiceDetails: jest diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx index 12112f8b364..912c232eaf3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/services/index.tsx @@ -17,6 +17,7 @@ import { isNil } from 'lodash'; import { Paging, ServiceCollection, ServiceData, ServiceTypes } from 'Models'; import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { addAirflowPipeline } from '../../axiosAPIs/airflowPipelineAPI'; import { deleteService, @@ -94,7 +95,8 @@ export type ApiData = { const ServicesPage = () => { const showToast = useToastContext(); - const { isAdminUser, isAuthDisabled } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [isModalOpen, setIsModalOpen] = useState(false); const [isConfirmationModalOpen, setIsConfirmationModalOpen] = useState(false); const [deleteSelection, setDeleteSelection] = useState({ diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.test.tsx index 04e9c095477..500159c2866 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.test.tsx @@ -21,6 +21,18 @@ import { import React, { ReactNode } from 'react'; import TagsPage from '.'; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + const mockTagsCategory = [ { categoryType: 'Classification', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.tsx index 21545a386ce..70362941683 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/tags/index.tsx @@ -17,6 +17,7 @@ import { isUndefined, toLower } from 'lodash'; import { EntityTags, FormErrorData } from 'Models'; import React, { useCallback, useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { createTag, createTagCategory, @@ -56,7 +57,8 @@ import { getTagCategories, getTaglist } from '../../utils/TagsUtils'; import Form from './Form'; // import { Tag, TagsCategory } from './tagsTypes'; const TagsPage = () => { - const { isAuthDisabled, isAdminUser } = useAuth(); + const { isAdminUser } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [categories, setCategoreis] = useState>([]); const [currentCategory, setCurrentCategory] = useState(); const [isEditCategory, setIsEditCategory] = useState(false); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.test.tsx index 171008a255f..25289b310ac 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.test.tsx @@ -24,6 +24,18 @@ const mockItem = { const mockRemove = jest.fn(); +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + jest.mock('../../components/common/avatar/Avatar', () => { return jest.fn().mockReturnValue(

Avatar

); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.tsx index 8ce4eb36c9d..d038f5c8d3e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/teams/UserCard.tsx @@ -15,6 +15,7 @@ import classNames from 'classnames'; import { capitalize } from 'lodash'; import React from 'react'; import { Link } from 'react-router-dom'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import Avatar from '../../components/common/avatar/Avatar'; import NonAdminAction from '../../components/common/non-admin-action/NonAdminAction'; import { SearchIndex } from '../../enums/search.enum'; @@ -49,7 +50,8 @@ const UserCard = ({ onSelect, onRemove, }: Props) => { - const { isAuthDisabled, isAdminUser, userPermissions } = useAuth(); + const { isAdminUser, userPermissions } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const getArrForPartialName = ( type: string ): Array<'service' | 'database' | 'table' | 'column'> => { diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.test.tsx index 48b51958691..82e6ff268c8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.test.tsx @@ -20,6 +20,18 @@ import { import React, { ReactNode } from 'react'; import TeamsPage from './index'; +jest.mock('../../auth-provider/AuthProvider', () => { + return { + useAuthContext: jest.fn(() => ({ + isAuthDisabled: false, + isAuthenticated: true, + isProtectedRoute: jest.fn().mockReturnValue(true), + isTourRoute: jest.fn().mockReturnValue(false), + onLogoutHandler: jest.fn(), + })), + }; +}); + const mockTeamsData = [ { description: '', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.tsx index b613f87de57..4082d6941c8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/teams/index.tsx @@ -20,6 +20,7 @@ import { FormErrorData } from 'Models'; import React, { useEffect, useState } from 'react'; import { Link, useHistory, useParams } from 'react-router-dom'; import AppState from '../../AppState'; +import { useAuthContext } from '../../auth-provider/AuthProvider'; import { createTeam, getTeamByName, @@ -57,7 +58,8 @@ import UserCard from './UserCard'; const TeamsPage = () => { const { team } = useParams() as Record; const history = useHistory(); - const { isAuthDisabled, isAdminUser, userPermissions } = useAuth(); + const { isAdminUser, userPermissions } = useAuth(); + const { isAuthDisabled } = useAuthContext(); const [teams, setTeams] = useState>([]); const [currentTeam, setCurrentTeam] = useState(); const [error, setError] = useState(''); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/CommonUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/CommonUtils.tsx index 4c28ca27822..92380c36f15 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/CommonUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/CommonUtils.tsx @@ -389,12 +389,16 @@ export const getSvgArrow = (isActive: boolean) => { }; export const isValidUrl = (href: string) => { - const regex = new RegExp( - // eslint-disable-next-line no-useless-escape - /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g - ); + if (!href) { + return false; + } + try { + const url = new URL(href); - return href.match(regex); + return Boolean(url.href); + } catch { + return false; + } }; export const getFields = (defaultFields: string, tabSpecificField: string) => { diff --git a/openmetadata-ui/src/main/resources/ui/tailwind.config.js b/openmetadata-ui/src/main/resources/ui/tailwind.config.js index eeb9a87c365..8fec37a2106 100644 --- a/openmetadata-ui/src/main/resources/ui/tailwind.config.js +++ b/openmetadata-ui/src/main/resources/ui/tailwind.config.js @@ -118,13 +118,13 @@ module.exports = { 'status-queued': statusQueued, // Ingestion statuses end // Webhook statuses begin - notStarted: ideal, - started: success, + disabled: ideal, + active: success, failed: error, awaitingRetry: success, retryLimitReached: warning, - 'notStarted-lite': idealBG, - 'started-lite': successBG, + 'disabled-lite': idealBG, + 'active-lite': successBG, 'failed-lite': errorBG, 'awaitingRetry-lite': successBG, 'retryLimitReached-lite': warningBG,