mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-10 15:59:57 +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,
|
ICON_DIMENSION,
|
||||||
NO_DATA_PLACEHOLDER,
|
NO_DATA_PLACEHOLDER,
|
||||||
} from '../../../../constants/constants';
|
} from '../../../../constants/constants';
|
||||||
|
import { EntityType } from '../../../../enums/entity.enum';
|
||||||
import {
|
import {
|
||||||
ChangePasswordRequest,
|
ChangePasswordRequest,
|
||||||
RequestType,
|
RequestType,
|
||||||
@ -36,6 +37,7 @@ import { getEntityName } from '../../../../utils/EntityUtils';
|
|||||||
import { showErrorToast, showSuccessToast } from '../../../../utils/ToastUtils';
|
import { showErrorToast, showSuccessToast } from '../../../../utils/ToastUtils';
|
||||||
import { useAuthContext } from '../../../Auth/AuthProviders/AuthProvider';
|
import { useAuthContext } from '../../../Auth/AuthProviders/AuthProvider';
|
||||||
import Chip from '../../../common/Chip/Chip.component';
|
import Chip from '../../../common/Chip/Chip.component';
|
||||||
|
import { DomainLabel } from '../../../common/DomainLabel/DomainLabel.component';
|
||||||
import { PersonaSelectableList } from '../../../Persona/PersonaSelectableList/PersonaSelectableList.component';
|
import { PersonaSelectableList } from '../../../Persona/PersonaSelectableList/PersonaSelectableList.component';
|
||||||
import UserProfileImage from '../UserProfileImage/UserProfileImage.component';
|
import UserProfileImage from '../UserProfileImage/UserProfileImage.component';
|
||||||
import { UserProfileDetailsProps } from './UserProfileDetails.interface';
|
import { UserProfileDetailsProps } from './UserProfileDetails.interface';
|
||||||
@ -216,6 +218,28 @@ const UserProfileDetails = ({
|
|||||||
[userData.email]
|
[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(
|
const handleDefaultPersonaUpdate = useCallback(
|
||||||
async (defaultPersona?: EntityReference) => {
|
async (defaultPersona?: EntityReference) => {
|
||||||
await updateUserDetails({ ...userData, defaultPersona });
|
await updateUserDetails({ ...userData, defaultPersona });
|
||||||
@ -271,6 +295,9 @@ const UserProfileDetails = ({
|
|||||||
<Divider type="vertical" />
|
<Divider type="vertical" />
|
||||||
|
|
||||||
{defaultPersonaRender}
|
{defaultPersonaRender}
|
||||||
|
<Divider type="vertical" />
|
||||||
|
|
||||||
|
{userDomainRender}
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
{changePasswordRenderComponent}
|
{changePasswordRenderComponent}
|
||||||
|
|||||||
@ -123,6 +123,16 @@ describe('Test User Profile Details Component', () => {
|
|||||||
expect(screen.getByTestId('default-persona-label')).toBeInTheDocument();
|
expect(screen.getByTestId('default-persona-label')).toBeInTheDocument();
|
||||||
expect(screen.getByText('PersonaSelectableList')).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();
|
expect(screen.getByTestId('change-password-button')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { EntityType } from '../enums/entity.enum';
|
||||||
import { User } from '../generated/entity/teams/user';
|
import { User } from '../generated/entity/teams/user';
|
||||||
|
|
||||||
export const USER_DATA: User = {
|
export const USER_DATA: User = {
|
||||||
@ -66,6 +67,15 @@ export const USER_DATA: User = {
|
|||||||
previousVersion: 3.2,
|
previousVersion: 3.2,
|
||||||
},
|
},
|
||||||
deleted: false,
|
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: [
|
roles: [
|
||||||
{
|
{
|
||||||
id: 'ed94fd7c-0974-4b87-9295-02b36c4c6bcd',
|
id: 'ed94fd7c-0974-4b87-9295-02b36c4c6bcd',
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const UserPage = () => {
|
|||||||
try {
|
try {
|
||||||
const res = await getUserByName(
|
const res = await getUserByName(
|
||||||
username,
|
username,
|
||||||
'profile,roles,teams,personas,defaultPersona'
|
'profile,roles,teams,personas,defaultPersona,domain'
|
||||||
);
|
);
|
||||||
setUserData(res);
|
setUserData(res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
import { findByTestId, findByText, render } from '@testing-library/react';
|
import { findByTestId, findByText, render } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import { EntityType } from '../../enums/entity.enum';
|
||||||
import { getUserByName } from '../../rest/userAPI';
|
import { getUserByName } from '../../rest/userAPI';
|
||||||
import UserPage from './UserPage.component';
|
import UserPage from './UserPage.component';
|
||||||
|
|
||||||
@ -27,6 +28,15 @@ const mockUserData = {
|
|||||||
email: 'xyz@gmail.com',
|
email: 'xyz@gmail.com',
|
||||||
href: 'http://localhost:8585/api/v1/users/d6764107-e8b4-4748-b256-c86fecc66064',
|
href: 'http://localhost:8585/api/v1/users/d6764107-e8b4-4748-b256-c86fecc66064',
|
||||||
isAdmin: false,
|
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: {
|
profile: {
|
||||||
images: {
|
images: {
|
||||||
image:
|
image:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user