remove edit button from team type group and fix color of button (#17478)

This commit is contained in:
Ashish Gupta 2024-08-18 22:05:08 +05:30 committed by GitHub
parent bbb3256c0d
commit bcc07173fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 86 additions and 57 deletions

View File

@ -25,19 +25,20 @@ export const navigateToCustomizeLandingPage = async (
await getPersonas; await getPersonas;
// Navigate to the customize landing page const getCustomPageDataResponse = page.waitForResponse(
await page.click(
`[data-testid="persona-details-card-${personaName}"] [data-testid="customize-page-button"]`
);
const getCustomPageDataResponse = await page.waitForResponse(
`/api/v1/docStore/name/persona.${encodeURIComponent( `/api/v1/docStore/name/persona.${encodeURIComponent(
personaName personaName
)}.Page.LandingPage` )}.Page.LandingPage`
); );
// await getCustomPageDataResponse; // Navigate to the customize landing page
expect(getCustomPageDataResponse.status()).toBe(customPageDataResponse); await page.click(
`[data-testid="persona-details-card-${personaName}"] [data-testid="customize-page-button"]`
);
expect((await getCustomPageDataResponse).status()).toBe(
customPageDataResponse
);
}; };
export const removeAndCheckWidget = async ( export const removeAndCheckWidget = async (

View File

@ -925,7 +925,7 @@ const TeamDetailsV1 = ({
<IconTeams className="text-primary" width={20} /> <IconTeams className="text-primary" width={20} />
</Avatar> </Avatar>
<Space direction="vertical" size={3}> <div className="d-flex flex-column gap-1">
{!isOrganization && ( {!isOrganization && (
<TitleBreadcrumb titleLinks={slashedTeamName} /> <TitleBreadcrumb titleLinks={slashedTeamName} />
)} )}
@ -935,7 +935,7 @@ const TeamDetailsV1 = ({
entityPermissions={entityPermissions} entityPermissions={entityPermissions}
updateTeamHandler={updateTeamHandler} updateTeamHandler={updateTeamHandler}
/> />
</Space> </div>
</Space> </Space>
<Space align="center"> <Space align="center">

View File

@ -10,16 +10,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Icon, { import {
CheckOutlined, CheckOutlined,
CloseOutlined, CloseOutlined,
ExclamationCircleFilled, ExclamationCircleFilled,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Button, Col, Input, Space, Tooltip, Typography } from 'antd'; import { Button, Input, Space, Tooltip, Typography } from 'antd';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ReactComponent as EditIcon } from '../../../../../assets/svg/edit-new.svg'; import { ReactComponent as EditIcon } from '../../../../../assets/svg/edit-new.svg';
import { DE_ACTIVE_COLOR } from '../../../../../constants/constants';
import { Team } from '../../../../../generated/entity/teams/team'; import { Team } from '../../../../../generated/entity/teams/team';
import { useAuth } from '../../../../../hooks/authHooks'; import { useAuth } from '../../../../../hooks/authHooks';
import { useApplicationStore } from '../../../../../hooks/useApplicationStore'; import { useApplicationStore } from '../../../../../hooks/useApplicationStore';
@ -121,8 +122,8 @@ const TeamsHeadingLabel = ({
</Space> </Space>
</Space> </Space>
) : ( ) : (
<Space align="center"> <>
<Space align="baseline"> <>
{heading ? ( {heading ? (
<Typography.Title <Typography.Title
className="m-b-0 w-max-200" className="m-b-0 w-max-200"
@ -150,12 +151,13 @@ const TeamsHeadingLabel = ({
}) })
: t('message.no-permission-for-action') : t('message.no-permission-for-action')
}> }>
<Icon <Button
className="align-middle" className="p-0 flex-center"
component={EditIcon}
data-testid="edit-team-name" data-testid="edit-team-name"
disabled={!hasEditDisplayNamePermission} disabled={!hasEditDisplayNamePermission}
style={{ fontSize: '16px' }} icon={<EditIcon color={DE_ACTIVE_COLOR} width="16px" />}
size="small"
type="text"
onClick={(e) => { onClick={(e) => {
// Used to stop click propagation event to parent TeamDetailV1 collapsible panel // Used to stop click propagation event to parent TeamDetailV1 collapsible panel
e.stopPropagation(); e.stopPropagation();
@ -164,16 +166,16 @@ const TeamsHeadingLabel = ({
/> />
</Tooltip> </Tooltip>
)} )}
</Space> </>
{currentTeam.deleted && ( {currentTeam.deleted && (
<Col className="text-xs"> <div
<div className="deleted-badge-button" data-testid="deleted-badge"> className="deleted-badge-button text-xs flex-center"
<ExclamationCircleFilled className="m-r-xss font-medium text-xs" /> data-testid="deleted-badge">
{t('label.deleted')} <ExclamationCircleFilled className="m-r-xss" />
</div> {t('label.deleted')}
</Col> </div>
)} )}
</Space> </>
), ),
[ [
heading, heading,

View File

@ -11,14 +11,16 @@
* limitations under the License. * limitations under the License.
*/ */
import { CheckOutlined, CloseOutlined } from '@ant-design/icons'; import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
import Icon from '@ant-design/icons/lib/components/Icon';
import { Button, Divider, Form, Input, Space, Tooltip, Typography } from 'antd'; import { Button, Divider, Form, Input, Space, Tooltip, Typography } from 'antd';
import classNames from 'classnames';
import { isEmpty, last } from 'lodash'; import { isEmpty, last } from 'lodash';
import React, { useCallback, useMemo, useState } from 'react'; import React, { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { ReactComponent as EditIcon } from '../../../../../assets/svg/edit-new.svg'; import { ReactComponent as EditIcon } from '../../../../../assets/svg/edit-new.svg';
import { NO_DATA_PLACEHOLDER } from '../../../../../constants/constants'; import {
DE_ACTIVE_COLOR,
ICON_DIMENSION,
NO_DATA_PLACEHOLDER,
} from '../../../../../constants/constants';
import { EMAIL_REG_EX } from '../../../../../constants/regex.constants'; import { EMAIL_REG_EX } from '../../../../../constants/regex.constants';
import { EntityType } from '../../../../../enums/entity.enum'; import { EntityType } from '../../../../../enums/entity.enum';
import { Team, TeamType } from '../../../../../generated/entity/teams/team'; import { Team, TeamType } from '../../../../../generated/entity/teams/team';
@ -196,17 +198,17 @@ const TeamsInfo = ({
</Typography.Text> </Typography.Text>
{hasEditPermission && ( {hasEditPermission && (
<Tooltip <Tooltip
title={ title={t('label.edit-entity', {
hasEditPermission entity: t('label.email'),
? t('label.edit-entity', { })}>
entity: t('label.email'), <Button
}) className="flex-center p-0"
: t('message.no-permission-for-action')
}>
<Icon
className="toolbar-button align-middle"
component={EditIcon}
data-testid="edit-email" data-testid="edit-email"
icon={
<EditIcon color={DE_ACTIVE_COLOR} {...ICON_DIMENSION} />
}
size="small"
type="text"
onClick={(e) => { onClick={(e) => {
// Used to stop click propagation event to parent TeamDetailV1 collapsible panel // Used to stop click propagation event to parent TeamDetailV1 collapsible panel
e.stopPropagation(); e.stopPropagation();
@ -249,30 +251,25 @@ const TeamsInfo = ({
{teamType} {teamType}
</Typography.Text> </Typography.Text>
{hasEditPermission && ( {hasEditPermission && !isGroupType && (
<Tooltip <Tooltip
title={ title={t('label.edit-entity', {
isGroupType entity: t('label.team-type'),
? t('message.group-team-type-change-message') })}>
: t('label.edit-entity', { <Button
entity: t('label.team-type'), className="flex-center p-0"
})
}>
<Icon
className={classNames('align-middle m-l-xss', {
'opacity-30': isGroupType,
})}
data-testid="edit-team-type-icon" data-testid="edit-team-type-icon"
icon={
<EditIcon color={DE_ACTIVE_COLOR} {...ICON_DIMENSION} />
}
size="small"
type="text"
onClick={(e) => { onClick={(e) => {
// Used to stop click propagation event to parent TeamDetailV1 collapsible panel // Used to stop click propagation event to parent TeamDetailV1 collapsible panel
e.stopPropagation(); e.stopPropagation();
if (isGroupType) {
return;
}
setShowTypeSelector(true); setShowTypeSelector(true);
}}> }}
<EditIcon /> />
</Icon>
</Tooltip> </Tooltip>
)} )}
</> </>

View File

@ -130,6 +130,35 @@ describe('TeamsInfo', () => {
expect(screen.queryByTestId('email-input')).not.toBeInTheDocument(); expect(screen.queryByTestId('email-input')).not.toBeInTheDocument();
}); });
it('should not render edit button if team type is organization', () => {
const { queryByTestId } = render(<TeamsInfo {...teamProps} />);
expect(queryByTestId('edit-team-type-icon')).not.toBeInTheDocument();
});
it('should not render edit button if team type is group & isGroupType is true', () => {
const { queryByTestId } = render(
<TeamsInfo
{...teamProps}
isGroupType
currentTeam={{ ...mockTeam, teamType: TeamType.Group }}
/>
);
expect(queryByTestId('edit-team-type-icon')).not.toBeInTheDocument();
});
it('should render edit button if team type is not group and organization', () => {
const { queryByTestId } = render(
<TeamsInfo
{...teamProps}
currentTeam={{ ...mockTeam, teamType: TeamType.BusinessUnit }}
/>
);
expect(queryByTestId('edit-team-type-icon')).toBeInTheDocument();
});
it('should not show edit button if user does not have permission', () => { it('should not show edit button if user does not have permission', () => {
(useAuth as jest.Mock).mockReturnValue({ isAdminUser: false }); (useAuth as jest.Mock).mockReturnValue({ isAdminUser: false });