diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js index 31a136e54f5..01a7b41bb85 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.js @@ -68,6 +68,7 @@ export const SEARCH_ENTITY_TABLE = { displayName: 'raw_product_catalog', entity: MYDATA_SUMMARY_OPTIONS.tables, serviceName: 'sample_data', + schemaName: 'shopify', }, table_4: { term: 'dim_address', diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RestoreEntity.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RestoreEntity.spec.js new file mode 100644 index 00000000000..e47c5b65469 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RestoreEntity.spec.js @@ -0,0 +1,181 @@ +/* + * Copyright 2023 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + interceptURL, + toastNotification, + verifyResponseStatusCode, + visitEntityDetailsPage, +} from '../../common/common'; +import { DELETE_TERM, SEARCH_ENTITY_TABLE } from '../../constants/constants'; + +const ENTITY_TABLE = SEARCH_ENTITY_TABLE.table_3; + +describe('Restore entity functionality should work properly', () => { + beforeEach(() => { + cy.login(); + }); + + it('Soft Delete entity table', () => { + visitEntityDetailsPage( + ENTITY_TABLE.term, + ENTITY_TABLE.serviceName, + ENTITY_TABLE.entity + ); + + cy.get('[data-testid="manage-button"]').should('exist').click(); + + cy.get('[data-testid="delete-button-title"]').should('exist').click(); + + cy.get('.ant-modal-header') + .should('be.visible') + .contains(`Delete ${ENTITY_TABLE.displayName}`); + + cy.get('[data-testid="soft-delete-option"]').should('exist').click(); + + cy.get('[data-testid="confirm-button"]').should('be.disabled'); + cy.get('[data-testid="confirmation-text-input"]') + .should('exist') + .type(DELETE_TERM); + + interceptURL( + 'DELETE', + 'api/v1/tables/*?hardDelete=false&recursive=false', + 'softDeleteTable' + ); + cy.get('[data-testid="confirm-button"]') + .should('be.visible') + .should('not.be.disabled') + .click(); + verifyResponseStatusCode('@softDeleteTable', 200); + + toastNotification('Table deleted successfully!'); + }); + + it('Check Soft Deleted entity table', () => { + cy.get('[data-testid="appbar-item-explore"]').should('exist').click(); + interceptURL( + 'GET', + 'api/v1/search/query?q=&index=table_search_index&from=0&size=10&deleted=true&query_filter=%7B%22query%22%3A%7B%22bool%22%3A%7B%7D%7D%7D&sort_field=_score&sort_order=desc', + 'showDeletedTables' + ); + cy.get('[data-testid="show-deleted"]').should('exist').click(); + verifyResponseStatusCode('@showDeletedTables', 200); + + cy.get('[data-testid="sample_data-raw_product_catalog"]') + .should('exist') + .click(); + + cy.get('[data-testid="inactive-link"]') + .should('be.visible') + .contains(ENTITY_TABLE.displayName); + + cy.get('[data-testid="deleted-badge"]').should('exist'); + }); + + it("Check Soft Deleted table in it's Schema", () => { + cy.get('[data-testid="appbar-item-explore"]').should('exist').click(); + interceptURL( + 'GET', + 'api/v1/search/query?q=&index=table_search_index&from=0&size=10&deleted=true&query_filter=%7B%22query%22%3A%7B%22bool%22%3A%7B%7D%7D%7D&sort_field=_score&sort_order=desc', + 'showDeletedTables' + ); + cy.get('[data-testid="show-deleted"]').should('exist').click(); + verifyResponseStatusCode('@showDeletedTables', 200); + + cy.get('[data-testid="sample_data-raw_product_catalog"]') + .should('exist') + .click(); + + cy.get('[data-testid="inactive-link"]') + .should('be.visible') + .contains(ENTITY_TABLE.displayName); + + cy.get('[data-testid="breadcrumb-link"]') + .should('be.visible') + .within(() => { + cy.contains(ENTITY_TABLE.displayName); + }); + + cy.get('[data-testid="deleted-badge"]').should('exist'); + + cy.get('[data-testid="breadcrumb-link"]') + .should('be.visible') + .within(() => { + cy.contains(ENTITY_TABLE.schemaName).click(); + }); + + cy.get('[data-testid="manage-button"]').should('exist').click(); + + cy.get('[data-testid="deleted-table-menu-item-label"]') + .should('exist') + .contains('Show Deleted Table'); + + cy.get('[data-testid="deleted-table-menu-item-switch') + .should('exist') + .click(); + + cy.get('[data-testid="Tables"] [data-testid="filter-count"]') + .should('exist') + .contains('1'); + + cy.get('.ant-table-row > :nth-child(1)') + .should('exist') + .contains(ENTITY_TABLE.displayName); + }); + + it('Restore Soft Deleted table', () => { + cy.get('[data-testid="appbar-item-explore"]').should('exist').click(); + interceptURL( + 'GET', + 'api/v1/search/query?q=&index=table_search_index&from=0&size=10&deleted=true&query_filter=%7B%22query%22%3A%7B%22bool%22%3A%7B%7D%7D%7D&sort_field=_score&sort_order=desc', + 'showDeletedTables' + ); + cy.get('[data-testid="show-deleted"]').should('exist').click(); + verifyResponseStatusCode('@showDeletedTables', 200); + + cy.get('[data-testid="sample_data-raw_product_catalog"]') + .should('exist') + .click(); + + cy.get('[data-testid="inactive-link"]') + .should('be.visible') + .contains(ENTITY_TABLE.displayName); + + cy.get('[data-testid="breadcrumb-link"]') + .should('be.visible') + .within(() => { + cy.contains(ENTITY_TABLE.displayName); + }); + + cy.get('[data-testid="deleted-badge"]').should('exist'); + + cy.get('[data-testid="manage-button"]').should('exist').click(); + + cy.get('[data-testid="restore-button"]').should('be.visible').click(); + + cy.get('.ant-modal-header').should('be.visible').contains('Restore table'); + + cy.get('[data-testid="restore-modal-body"]') + .should('be.visible') + .contains( + `Are you sure you want to restore ${ENTITY_TABLE.displayName}?` + ); + + cy.get('.ant-btn-primary').should('be.visible').contains('Restore').click(); + + cy.wait(500); + + cy.get('[data-testid="deleted-badge"]').should('not.exist'); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js index bb607f792bc..21638a86bc6 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js @@ -68,7 +68,7 @@ describe('Check if tags addition and removal flow working properly from tables', ); cy.get( - '[data-testid="entity-tags"] [data-testid="tags-wrapper"] > [data-testid="tag-container"] [data-testid="tags"] > [data-testid="add-tag"] > span' + '[data-testid="entity-tags"] [data-testid="tags-wrapper"] [data-testid="tag-container"] [data-testid="tags"] [data-testid="add-tag"] span' ) .should('be.visible') .click(); @@ -87,13 +87,13 @@ describe('Check if tags addition and removal flow working properly from tables', if (entityDetails.entity === 'mlmodels') { cy.get( - `[data-testid="feature-card-${entityDetails.fieldName}"] [data-testid="tag-container"] [data-testid="tags"] > [data-testid="add-tag"] > span` + `[data-testid="feature-card-${entityDetails.fieldName}"] [data-testid="tag-container"] [data-testid="tags"] > [data-testid="add-tag"] span` ) .should('be.visible') .click(); } else { cy.get( - `.ant-table-tbody [data-testid="tag-container"] [data-testid="add-tag"]>span` + `.ant-table-tbody [data-testid="tag-container"] [data-testid="add-tag"] span` ) .eq(0) .should('be.visible') diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/closed-lock.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/closed-lock.svg index 11296a696f2..e5ef99c536c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/assets/svg/closed-lock.svg +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/closed-lock.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/hide-password.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/hide-password.svg index 5e0da9930fd..1e863deec00 100644 --- a/openmetadata-ui/src/main/resources/ui/src/assets/svg/hide-password.svg +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/hide-password.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-restore.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-restore.svg index 6d05d23735a..2c42246c4ce 100644 --- a/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-restore.svg +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/ic-restore.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/open-lock.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/open-lock.svg index 0fa88109e03..8e3f16684c4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/assets/svg/open-lock.svg +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/open-lock.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/openmetadata-ui/src/main/resources/ui/src/assets/svg/show-password.svg b/openmetadata-ui/src/main/resources/ui/src/assets/svg/show-password.svg index 916a8a4038f..9ed544ff8ab 100644 --- a/openmetadata-ui/src/main/resources/ui/src/assets/svg/show-password.svg +++ b/openmetadata-ui/src/main/resources/ui/src/assets/svg/show-password.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file 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 445fc1545d6..177747756c1 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 @@ -28,6 +28,7 @@ import { ItemType } from 'antd/lib/menu/hooks/useItems'; import { ColumnsType } from 'antd/lib/table'; import { AxiosError } from 'axios'; import classNames from 'classnames'; +import { DROPDOWN_ICON_SIZE_PROPS } from 'constants/ManageButton.constants'; import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; import { compare } from 'fast-json-patch'; import { cloneDeep, isEmpty, isUndefined, orderBy, uniqueId } from 'lodash'; @@ -39,7 +40,11 @@ import { Link } from 'react-router-dom'; import { restoreTeam } from 'rest/teamsAPI'; import AppState from '../../AppState'; import { ReactComponent as IconEdit } from '../../assets/svg/ic-edit.svg'; +import { ReactComponent as IconRestore } from '../../assets/svg/ic-restore.svg'; import { ReactComponent as IconDropdown } from '../../assets/svg/menu.svg'; +import { ReactComponent as IconOpenLock } from '../../assets/svg/open-lock.svg'; +import { ReactComponent as IconRemove } from '../../assets/svg/Remove.svg'; +import { ReactComponent as IconShowPassword } from '../../assets/svg/show-password.svg'; import { getTeamAndUserDetailsPath, getUserPath, @@ -73,7 +78,6 @@ import { DEFAULT_ENTITY_PERMISSION, } from '../../utils/PermissionsUtils'; import { getTeamsWithFqnPath } from '../../utils/RouterUtils'; -import SVGIcons, { Icons } from '../../utils/SvgUtils'; import { filterChildTeams, getDeleteMessagePostFix, @@ -290,13 +294,7 @@ const TeamDetailsV1 = ({