mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 19:48:17 +00:00
* show domain on users page * added test cases --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
parent
4c1c91e6ba
commit
71ca9e3855
@ -24,6 +24,7 @@ import {
|
||||
ICON_DIMENSION,
|
||||
NO_DATA_PLACEHOLDER,
|
||||
} from '../../../../constants/constants';
|
||||
import { EntityType } from '../../../../enums/entity.enum';
|
||||
import {
|
||||
ChangePasswordRequest,
|
||||
RequestType,
|
||||
@ -36,6 +37,7 @@ import { getEntityName } from '../../../../utils/EntityUtils';
|
||||
import { showErrorToast, showSuccessToast } from '../../../../utils/ToastUtils';
|
||||
import { useAuthContext } from '../../../Auth/AuthProviders/AuthProvider';
|
||||
import Chip from '../../../common/Chip/Chip.component';
|
||||
import { DomainLabel } from '../../../common/DomainLabel/DomainLabel.component';
|
||||
import { PersonaSelectableList } from '../../../Persona/PersonaSelectableList/PersonaSelectableList.component';
|
||||
import UserProfileImage from '../UserProfileImage/UserProfileImage.component';
|
||||
import { UserProfileDetailsProps } from './UserProfileDetails.interface';
|
||||
@ -216,6 +218,28 @@ const UserProfileDetails = ({
|
||||
[userData.email]
|
||||
);
|
||||
|
||||
const userDomainRender = useMemo(
|
||||
() => (
|
||||
<Space align="center">
|
||||
<Typography.Text
|
||||
className="text-grey-muted"
|
||||
data-testid="user-domain-label">{`${t(
|
||||
'label.domain'
|
||||
)} :`}</Typography.Text>
|
||||
<Space align="center">
|
||||
<DomainLabel
|
||||
domain={userData?.domain}
|
||||
entityFqn={userData.fullyQualifiedName ?? ''}
|
||||
entityId={userData.id ?? ''}
|
||||
entityType={EntityType.USER}
|
||||
hasPermission={false}
|
||||
/>
|
||||
</Space>
|
||||
</Space>
|
||||
),
|
||||
[userData.domain]
|
||||
);
|
||||
|
||||
const handleDefaultPersonaUpdate = useCallback(
|
||||
async (defaultPersona?: EntityReference) => {
|
||||
await updateUserDetails({ ...userData, defaultPersona });
|
||||
@ -271,6 +295,9 @@ const UserProfileDetails = ({
|
||||
<Divider type="vertical" />
|
||||
|
||||
{defaultPersonaRender}
|
||||
<Divider type="vertical" />
|
||||
|
||||
{userDomainRender}
|
||||
</Space>
|
||||
|
||||
{changePasswordRenderComponent}
|
||||
|
||||
@ -123,6 +123,16 @@ describe('Test User Profile Details Component', () => {
|
||||
expect(screen.getByTestId('default-persona-label')).toBeInTheDocument();
|
||||
expect(screen.getByText('PersonaSelectableList')).toBeInTheDocument();
|
||||
|
||||
// user domain
|
||||
expect(screen.getByTestId('user-domain-label')).toContainHTML(
|
||||
'label.domain'
|
||||
);
|
||||
expect(screen.getByTestId('domain-link')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('domain-link')).toHaveAttribute(
|
||||
'href',
|
||||
'/domain/Engineering'
|
||||
);
|
||||
|
||||
expect(screen.getByTestId('change-password-button')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EntityType } from '../enums/entity.enum';
|
||||
import { User } from '../generated/entity/teams/user';
|
||||
|
||||
export const USER_DATA: User = {
|
||||
@ -66,6 +67,15 @@ export const USER_DATA: User = {
|
||||
previousVersion: 3.2,
|
||||
},
|
||||
deleted: false,
|
||||
domain: {
|
||||
id: '303ca53b-5050-4caa-9c4e-d4fdada76a53',
|
||||
type: EntityType.DOMAIN,
|
||||
name: 'Engineering',
|
||||
fullyQualifiedName: 'Engineering',
|
||||
description: 'description',
|
||||
inherited: true,
|
||||
href: 'http://localhost:8585/api/v1/domains/303ca53b-5050-4caa-9c4e-d4fdada76a53',
|
||||
},
|
||||
roles: [
|
||||
{
|
||||
id: 'ed94fd7c-0974-4b87-9295-02b36c4c6bcd',
|
||||
|
||||
@ -47,7 +47,7 @@ const UserPage = () => {
|
||||
try {
|
||||
const res = await getUserByName(
|
||||
username,
|
||||
'profile,roles,teams,personas,defaultPersona'
|
||||
'profile,roles,teams,personas,defaultPersona,domain'
|
||||
);
|
||||
setUserData(res);
|
||||
} catch (error) {
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
import { findByTestId, findByText, render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { EntityType } from '../../enums/entity.enum';
|
||||
import { getUserByName } from '../../rest/userAPI';
|
||||
import UserPage from './UserPage.component';
|
||||
|
||||
@ -27,6 +28,15 @@ const mockUserData = {
|
||||
email: 'xyz@gmail.com',
|
||||
href: 'http://localhost:8585/api/v1/users/d6764107-e8b4-4748-b256-c86fecc66064',
|
||||
isAdmin: false,
|
||||
domain: {
|
||||
id: '303ca53b-5050-4caa-9c4e-d4fdada76a53',
|
||||
type: EntityType.DOMAIN,
|
||||
name: 'Engineering',
|
||||
fullyQualifiedName: 'Engineering',
|
||||
description: 'description',
|
||||
inherited: true,
|
||||
href: 'http://localhost:8585/api/v1/domains/303ca53b-5050-4caa-9c4e-d4fdada76a53',
|
||||
},
|
||||
profile: {
|
||||
images: {
|
||||
image:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user