From 9b78f12305345d0e04adc0e84d2a72b382f60607 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Wed, 17 May 2023 23:58:09 +0530 Subject: [PATCH] feat(#11608): show email in teams page (#11642) * feat(#11608): UI: Show Email in teams page * update method name --- .../ui/cypress/e2e/Pages/Teams.spec.js | 30 +++++++ .../components/TeamDetails/TeamDetailsV1.tsx | 78 ++++++++++++++++++- .../ui/src/styles/components/size.less | 3 + 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js index 6fb4c9f34d9..92a1e0ae877 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Teams.spec.js @@ -33,6 +33,7 @@ const TEAM_DETAILS = { userId: 'aaron_johnson0', assetname: 'dim_address', email: 'team1@gmail.com', + updatedEmail: 'updatedemail@gmail.com', }; const hardDeleteTeamName = `team-ct-test-${uuid()}`; const HARD_DELETE_TEAM_DETAILS = { @@ -82,6 +83,35 @@ describe('Teams flow should work properly', () => { updateOwner(); }); + it('Update email of created team', () => { + interceptURL('PATCH', '/api/v1/teams/*', 'updateEmail'); + interceptURL('GET', '/api/v1/teams/name/*', 'getTeam'); + + // Clicking on created team + cy.get(`[data-row-key="${TEAM_DETAILS.name}"]`) + .contains(TEAM_DETAILS.name) + .click(); + verifyResponseStatusCode('@getUserDetails', 200); + verifyResponseStatusCode('@getTeam', 200); + + cy.get('[data-testid="edit-email"]').should('be.visible').click(); + cy.get('[data-testid="email-input"]') + .should('be.visible') + .clear() + .type(TEAM_DETAILS.updatedEmail); + + cy.get('[data-testid="save-edit-email"]').should('be.visible').click(); + + verifyResponseStatusCode('@updateEmail', 200); + + cy.reload(); + + // check for updated email + cy.get('[data-testid="email-value"]') + .should('be.visible') + .contains(TEAM_DETAILS.updatedEmail); + }); + it('Add user to created team', () => { interceptURL('GET', '/api/v1/users?&isBot=false&limit=15', 'getUsers'); interceptURL('PATCH', '/api/v1/teams/*', 'updateTeam'); 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 45655835039..2bef0408be4 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 @@ -16,6 +16,7 @@ import { Button, Col, Dropdown, + Input, Modal, Row, Space, @@ -205,6 +206,8 @@ const TeamDetailsV1 = ({ useState(DEFAULT_ENTITY_PERMISSION); const [isModalLoading, setIsModalLoading] = useState(false); const [showActions, setShowActions] = useState(false); + const [email, setEmail] = useState(currentTeam.email || ''); + const [isEmailEdit, setIsEmailEdit] = useState(false); const addPolicy = t('label.add-entity', { entity: t('label.policy'), @@ -589,6 +592,18 @@ const TeamDetailsV1 = ({ } }; + const handleUpdateEmail = () => { + if (currentTeam) { + const updatedData: Team = { + ...currentTeam, + email, + }; + + updateTeamHandler(updatedData); + setIsEmailEdit(false); + } + }; + const fetchPermissions = async () => { setLoading(true); try { @@ -965,7 +980,7 @@ const TeamDetailsV1 = ({ const getTeamHeading = () => { return ( -
+
{isHeadingEditing ? (
+ {isEmailEdit ? ( + + setEmail(e.target.value)} + /> + + + + ) : ( + <> + + {currentTeam.email || + t('label.no-entity', { entity: t('label.email') })} + + +
+ {emailElement} {extraInfo.map((info, index) => ( diff --git a/openmetadata-ui/src/main/resources/ui/src/styles/components/size.less b/openmetadata-ui/src/main/resources/ui/src/styles/components/size.less index 9e7cfbd51e2..16e618c96e0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/styles/components/size.less +++ b/openmetadata-ui/src/main/resources/ui/src/styles/components/size.less @@ -128,6 +128,9 @@ .w-max-256 { max-width: 256px; } +.w-64 { + width: 264px; +} .w-max-13 { max-width: 13rem;