From 535f4b4f4fda8c34e2c97c34622db077e78fc537 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Tue, 6 Sep 2022 07:36:07 +0530 Subject: [PATCH] UI : Fix the Webhook add button issue in settings (#7222) * Fix the Webhook add button issue in settings * addressing comments * fixed failing cypress * miner cypress fix Co-authored-by: Shailesh Parmar --- .../integration/Pages/Glossary.spec.js | 4 +- .../BotListV1/BotListV1.component.tsx | 141 +++++++++++++----- .../BotListV1/BotListV1.interfaces.ts | 2 + .../Glossary/GlossaryV1.component.tsx | 16 +- .../SampleDataTable.component.tsx | 100 +++++++------ .../ui/src/components/Services/Services.tsx | 52 +++---- .../components/TeamDetails/TeamDetails.tsx | 3 + .../components/TeamDetails/TeamDetailsV1.tsx | 3 + .../ui/src/components/Webhooks/WebhooksV1.tsx | 17 ++- .../ErrorPlaceHolder.tsx | 34 +---- .../ui/src/constants/docs.constants.ts | 8 + .../pages/BotsPageV1/BotsPageV1.component.tsx | 47 +----- 12 files changed, 219 insertions(+), 208 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/integration/Pages/Glossary.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/integration/Pages/Glossary.spec.js index e344c92e3f7..d49d3d1a238 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/integration/Pages/Glossary.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/integration/Pages/Glossary.spec.js @@ -111,7 +111,7 @@ describe('Glossary page should work properly', () => { it('Create new glossary flow should work properly', () => { // check for no data placeholder - cy.contains('glossaries').should('be.visible'); + cy.contains('Add New Glossary').should('be.visible'); // Redirecting to add glossary page cy.get('[data-testid="add-webhook-button"]').should('be.visible').click(); @@ -456,6 +456,6 @@ describe('Glossary page should work properly', () => { .should('be.visible'); cy.get('.Toastify__close-button > svg > path').should('be.visible').click(); cy.wait(500); - cy.contains('glossaries').should('be.visible'); + cy.contains('Add New Glossary').should('be.visible'); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx index 39176f93421..174e94f232d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx @@ -11,9 +11,10 @@ * limitations under the License. */ -import { Button, Col, Row, Space, Table, Tooltip } from 'antd'; +import { Button, Col, Row, Space, Switch, Table, Tooltip } from 'antd'; import { ColumnsType } from 'antd/lib/table'; import { AxiosError } from 'axios'; +import { isEmpty } from 'lodash'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Link } from 'react-router-dom'; import { getBots } from '../../axiosAPIs/botsAPI'; @@ -22,6 +23,7 @@ import { INITIAL_PAGING_VALUE, PAGE_SIZE, } from '../../constants/constants'; +import { BOTS_DOCS } from '../../constants/docs.constants'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { EntityType } from '../../enums/entity.enum'; import { Bot } from '../../generated/entity/bot'; @@ -32,6 +34,7 @@ import { checkPermission } from '../../utils/PermissionsUtils'; import SVGIcons, { Icons } from '../../utils/SvgUtils'; import { showErrorToast } from '../../utils/ToastUtils'; import DeleteWidgetModal from '../common/DeleteWidget/DeleteWidgetModal'; +import ErrorPlaceHolder from '../common/error-with-placeholder/ErrorPlaceHolder'; import NextPrevious from '../common/next-previous/NextPrevious'; import RichTextEditorPreviewer from '../common/rich-text-editor/RichTextEditorPreviewer'; import Loader from '../Loader/Loader'; @@ -39,7 +42,11 @@ import { usePermissionProvider } from '../PermissionProvider/PermissionProvider' import { ResourceEntity } from '../PermissionProvider/PermissionProvider.interface'; import { BotListV1Props } from './BotListV1.interfaces'; -const BotListV1 = ({ showDeleted }: BotListV1Props) => { +const BotListV1 = ({ + showDeleted, + handleAddBotClick, + handleShowDeleted, +}: BotListV1Props) => { const { permissions } = usePermissionProvider(); const [botUsers, setBotUsers] = useState([]); const [paging, setPaging] = useState({} as Paging); @@ -47,6 +54,14 @@ const BotListV1 = ({ showDeleted }: BotListV1Props) => { const [loading, setLoading] = useState(true); const [currentPage, setCurrentPage] = useState(INITIAL_PAGING_VALUE); + const [handleErrorPlaceholder, setHandleErrorPlaceholder] = useState(false); + + const createPermission = checkPermission( + Operation.Create, + ResourceEntity.BOT, + permissions + ); + const deletePermission = useMemo( () => checkPermission(Operation.Delete, ResourceEntity.BOT, permissions), [permissions] @@ -66,6 +81,11 @@ const BotListV1 = ({ showDeleted }: BotListV1Props) => { }); setPaging(paging); setBotUsers(data); + if (!showDeleted && isEmpty(data)) { + setHandleErrorPlaceholder(true); + } else { + setHandleErrorPlaceholder(false); + } } catch (error) { showErrorToast((error as AxiosError).message); } finally { @@ -152,45 +172,88 @@ const BotListV1 = ({ showDeleted }: BotListV1Props) => { fetchBots(showDeleted); }, [showDeleted]); - return ( - <> - - - , - }} - pagination={false} - size="small" - /> - - - {paging.total > PAGE_SIZE && ( - + + + } + doc={BOTS_DOCS} + heading="Bot" + type="ADD_DATA" + /> + ) : ( + + + + + + - )} - - + + - { - setSelectedUser(undefined); - }} - /> - + + + + + + + + +
, + }} + pagination={false} + size="small" + /> + + + {paging.total > PAGE_SIZE && ( + + )} + + + + { + setSelectedUser(undefined); + }} + /> + + ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.interfaces.ts b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.interfaces.ts index 1844943888e..cddda5f36b4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.interfaces.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.interfaces.ts @@ -13,4 +13,6 @@ export interface BotListV1Props { showDeleted: boolean; + handleAddBotClick: () => void; + handleShowDeleted: (checked: boolean) => void; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx index a2ba70ad8aa..a9c685c5ccd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx @@ -562,11 +562,19 @@ const GlossaryV1 = ({ ) : ( + Add New Glossary + + } doc={GLOSSARIES_DOCS} - heading="glossaries" + heading="Glossary" type="ADD_DATA" /> diff --git a/openmetadata-ui/src/main/resources/ui/src/components/SampleDataTable/SampleDataTable.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/SampleDataTable/SampleDataTable.component.tsx index 762aa3a7591..d17f456d019 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/SampleDataTable/SampleDataTable.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/SampleDataTable/SampleDataTable.component.tsx @@ -103,59 +103,61 @@ const SampleDataTable: FunctionComponent = ({ sampleData }: Props) => { ) : null} -
+ <> {sampleData?.rows?.length && sampleData?.columns?.length ? ( -
- - - {sampleData.columns.map((column) => { +
+
+ + + {sampleData.columns.map((column) => { + return ( + + ); + })} + + + + {sampleData?.rows?.map((row, rowIndex) => { return ( - + + {row.map((data, index) => { + return ( + + ); + })} + ); })} - - - - {sampleData?.rows?.map((row, rowIndex) => { - return ( - - {row.map((data, index) => { - return ( - - ); - })} - - ); - })} - -
+ + {column.name} + + ({lowerCase(column.dataType)}) + + +
- - {column.name} - - ({lowerCase(column.dataType)}) - - -
+ +
- -
+ + + ) : ( -
+
No Service
@@ -180,7 +182,7 @@ const SampleDataTable: FunctionComponent = ({ sampleData }: Props) => {
)} - + ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Services/Services.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Services/Services.tsx index 18243e620aa..1c5ce7921dd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Services/Services.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Services/Services.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { Card, Col, Row, Tooltip, Typography } from 'antd'; +import { Button as ButtonAntd, Card, Col, Row, Tooltip } from 'antd'; import { isEmpty } from 'lodash'; import React, { Fragment, useMemo } from 'react'; import { Link, useHistory } from 'react-router-dom'; @@ -23,10 +23,7 @@ import { } from '../../constants/constants'; import { CONNECTORS_DOCS } from '../../constants/docs.constants'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; -import { - AddPlaceHolder, - servicesDisplayName, -} from '../../constants/services.const'; +import { servicesDisplayName } from '../../constants/services.const'; import { ServiceCategory } from '../../enums/service.enum'; import { Operation } from '../../generated/entity/policies/policy'; import { Paging } from '../../generated/type/paging'; @@ -43,6 +40,7 @@ import { getResourceEntityFromServiceCategory, } from '../../utils/ServiceUtils'; import { Button } from '../buttons/Button/Button'; +import ErrorPlaceHolder from '../common/error-with-placeholder/ErrorPlaceHolder'; import NextPrevious from '../common/next-previous/NextPrevious'; import NonAdminAction from '../common/non-admin-action/NonAdminAction'; import RichTextEditorPreviewer from '../common/rich-text-editor/RichTextEditorPreviewer'; @@ -64,8 +62,6 @@ const Services = ({ currentPage, onPageChange, }: ServicesProps) => { - const { Paragraph, Link: AntdLink } = Typography; - const { isAuthDisabled } = useAuthContext(); const history = useHistory(); const handleAddServiceClick = () => { @@ -187,41 +183,27 @@ const Services = ({ )} ) : ( -
-
- No Service -
-
- - {' '} - Adding a new {servicesDisplayName[serviceName]} is easy, just give - it a spin! - - - {' '} - Still need help? Refer to our{' '} - - docs - {' '} - for more information. - - -
+ + - - {' '} -
-
-
+ + + } + doc={CONNECTORS_DOCS} + heading={servicesDisplayName[serviceName]} + type="ADD_DATA" + /> + )}
); 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 d73840ecf94..ebb5277c88c 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 @@ -26,6 +26,7 @@ import { TITLE_FOR_NON_ADMIN_ACTION, TITLE_FOR_NON_OWNER_ACTION, } from '../../constants/constants'; +import { TEAMS_DOCS } from '../../constants/docs.constants'; import { ADMIN_ONLY_ACCESSIBLE_SECTION } from '../../enums/common.enum'; import { EntityType } from '../../enums/entity.enum'; import { OwnerType } from '../../enums/user.enum'; @@ -672,7 +673,9 @@ const TeamDetails = ({ } + doc={TEAMS_DOCS} heading="Teams" + type="ADD_DATA" /> )} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx index 4c39e69c68a..1b6b078ae74 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TeamDetails/TeamDetailsV1.tsx @@ -38,6 +38,7 @@ import { getTeamAndUserDetailsPath, PAGE_SIZE, } from '../../constants/constants'; +import { TEAMS_DOCS } from '../../constants/docs.constants'; import { NO_PERMISSION_FOR_ACTION, NO_PERMISSION_TO_VIEW, @@ -993,7 +994,9 @@ const TeamDetailsV1 = ({ } + doc={TEAMS_DOCS} heading="Teams" + type="ADD_DATA" /> )} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Webhooks/WebhooksV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Webhooks/WebhooksV1.tsx index 0a7f17e880e..cf30dc6ad72 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Webhooks/WebhooksV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Webhooks/WebhooksV1.tsx @@ -11,13 +11,14 @@ * limitations under the License. */ -import { Col, Row, Select, Space, Tooltip } from 'antd'; +import { Button as ButtonAntd, Col, Row, Select, Space, Tooltip } from 'antd'; import { AxiosError } from 'axios'; import classNames from 'classnames'; import { isEmpty, isNil } from 'lodash'; import React, { FC, useEffect, useMemo, useState } from 'react'; import { deleteWebhook } from '../../axiosAPIs/webhookAPI'; import { PAGE_SIZE } from '../../constants/constants'; +import { WEBHOOK_DOCS } from '../../constants/docs.constants'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { WebhookType } from '../../generated/api/events/createWebhook'; import { Webhook } from '../../generated/entity/events/webhook'; @@ -85,20 +86,22 @@ const WebhooksV1: FC = ({ ? 'Add Webhook' : NO_PERMISSION_FOR_ACTION }> - +

} + doc={WEBHOOK_DOCS} heading={message} + type="ADD_DATA" /> ); }, @@ -125,9 +128,7 @@ const WebhooksV1: FC = ({ }, [data, selectedStatus]); if (data.length === 0) { - return fetchErrorPlaceHolder( - `No ${WEBHOOKS_INTEGRATION[webhookType]} found` - ); + return fetchErrorPlaceHolder(WEBHOOKS_INTEGRATION[webhookType]); } return ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolder.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolder.tsx index 37727ee4059..78d8f971161 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolder.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/error-with-placeholder/ErrorPlaceHolder.tsx @@ -13,11 +13,8 @@ import { Typography } from 'antd'; import React from 'react'; -import { - default as AddPlaceHolder, - default as NoDataFoundPlaceHolder, -} from '../../../assets/img/no-data-placeholder.svg'; -import { Button } from '../../buttons/Button/Button'; +import AddPlaceHolder from '../../../assets/img/add-placeholder.svg'; +import NoDataFoundPlaceHolder from '../../../assets/img/no-data-placeholder.svg'; type Props = { children?: React.ReactNode; @@ -30,16 +27,7 @@ type Props = { buttonId?: string; }; -const ErrorPlaceHolder = ({ - doc, - type, - children, - heading, - buttonLabel, - buttonListener, - buttons, - buttonId, -}: Props) => { +const ErrorPlaceHolder = ({ doc, type, children, heading, buttons }: Props) => { const { Paragraph, Link } = Typography; return type === 'ADD_DATA' ? ( @@ -48,7 +36,7 @@ const ErrorPlaceHolder = ({ {' '} -
+
{' '} Adding a new {heading} is easy, just give it a spin! @@ -62,19 +50,7 @@ const ErrorPlaceHolder = ({ for more information. -
- {buttons ? ( - buttons - ) : ( - - )} -
+
{buttons}
) : ( diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/docs.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/docs.constants.ts index f849608ee54..563df7c2b1f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/docs.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/docs.constants.ts @@ -12,3 +12,11 @@ export const CONNECTORS_DOCS = export const WORKFLOWS_METADATA_DOCS = 'https://docs.open-metadata.org/openmetadata/ingestion/workflows/metadata'; + +export const BOTS_DOCS = + 'https://docs.open-metadata.org/main-concepts/metadata-standard/schemas/entity/bot'; + +export const TEAMS_DOCS = 'https://docs.open-metadata.org/openmetadata/users'; + +export const WEBHOOK_DOCS = + 'https://docs.open-metadata.org/developers/webhooks'; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/BotsPageV1/BotsPageV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/BotsPageV1/BotsPageV1.component.tsx index 999ea0d3f39..91628054471 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/BotsPageV1/BotsPageV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/BotsPageV1/BotsPageV1.component.tsx @@ -11,19 +11,12 @@ * limitations under the License. */ -import { Button, Col, Row, Space, Switch, Tooltip } from 'antd'; import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; import BotListV1 from '../../components/BotListV1/BotListV1.component'; -import { usePermissionProvider } from '../../components/PermissionProvider/PermissionProvider'; -import { ResourceEntity } from '../../components/PermissionProvider/PermissionProvider.interface'; import { getCreateUserPath } from '../../constants/constants'; -import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; -import { Operation } from '../../generated/entity/policies/accessControl/rule'; -import { checkPermission } from '../../utils/PermissionsUtils'; export const BotsPageV1 = () => { - const { permissions } = usePermissionProvider(); const history = useHistory(); const [showDeleted, setShowDeleted] = useState(false); @@ -35,42 +28,12 @@ export const BotsPageV1 = () => { setShowDeleted(checked); }; - const createPermission = checkPermission( - Operation.Create, - ResourceEntity.BOT, - permissions - ); - return ( - - - - - - - - - - - - - - - - - - + ); };