Fix #4047 UI : Support owner entity reference from elastic search (#4059)

* Fix #4047 UI : Support owner entity reference from elastic search

* Change mention char constant
This commit is contained in:
Sachin Chaurasiya 2022-04-12 12:46:03 +05:30 committed by GitHub
parent 110c0f503e
commit 3f3e38043c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 78 additions and 25 deletions

View File

@ -30,6 +30,7 @@ class AppState {
client_id: '',
signingIn: false,
};
nonSecureUserDetails: User = {} as User;
userDetails: User = {} as User;
userTeams: Array<UserTeams> = [];
userRoles: Array<Role> = [];
@ -61,6 +62,7 @@ class AppState {
}
updateUsers(data: Array<User>) {
this.users = data;
this.nonSecureUserDetails = data[0];
}
updateUserTeam(data: Array<UserTeams>) {
this.userTeams = data;

View File

@ -7,7 +7,7 @@ import { EntityType } from '../../../enums/entity.enum';
import { SearchIndex } from '../../../enums/search.enum';
import { Paging } from '../../../generated/type/paging';
import { isEven } from '../../../utils/CommonUtils';
import { getEntityLink, getOwnerFromId } from '../../../utils/TableUtils';
import { getEntityLink } from '../../../utils/TableUtils';
import NextPrevious from '../../common/next-previous/NextPrevious';
import RichTextEditorPreviewer from '../../common/rich-text-editor/RichTextEditorPreviewer';
@ -75,7 +75,11 @@ const AssetsTabs = ({ assetData, onAssetPaginate, currentPage }: Props) => {
)}
</td>
<td className="tableBody-cell">
<p>{getOwnerFromId(dataObj.owner)?.name || '--'}</p>
<p>
{dataObj.owner?.displayName ||
dataObj.owner?.name ||
'--'}
</p>
</td>
</tr>
))

View File

@ -103,7 +103,8 @@ const MyData: React.FC<MyDataProps> = ({
const getLinkByFilter = (filter: Ownership) => {
return `${getExplorePathWithSearch()}?${filter}=${getOwnerIds(
filter,
AppState.userDetails
AppState.userDetails,
AppState.nonSecureUserDetails
).join()}`;
};

View File

@ -17,6 +17,7 @@ import {
getByText,
render,
} from '@testing-library/react';
import { FormatedTableData } from 'Models';
import React from 'react';
import { MemoryRouter } from 'react-router';
import SearchedData from './SearchedData';
@ -27,7 +28,16 @@ const mockData = [
name: 'name1',
description: 'description1',
fullyQualifiedName: 'fullyQualifiedName1',
owner: 'owner1',
owner: {
deleted: false,
displayName: 'Customer_Support',
name: 'Customer_Support',
description: 'This is Customer_Support description.',
id: '32a6706e-8862-48e5-b3f3-ff280045ae32',
href: 'http://localhost:8585/api/v1/teams/32a6706e-8862-48e5-b3f3-ff280045ae32',
type: 'team',
fullyQualifiedName: 'Customer_Support',
},
tags: ['tags1', 'tags2', 'tags3'],
tier: 'tier1',
index: 'index1',
@ -52,7 +62,7 @@ const mockData = [
tier: 'tier3',
index: 'index1',
},
];
] as FormatedTableData[];
const mockPaginate = jest.fn();

View File

@ -20,10 +20,7 @@ import { PAGE_SIZE } from '../../constants/constants';
import { TableType } from '../../generated/entity/data/table';
import { Paging } from '../../generated/type/paging';
import { pluralize } from '../../utils/CommonUtils';
import {
getOwnerFromId,
getTierFromSearchTableTags,
} from '../../utils/TableUtils';
import { getTierFromSearchTableTags } from '../../utils/TableUtils';
import ErrorPlaceHolderES from '../common/error-with-placeholder/ErrorPlaceHolderES';
import NextPrevious from '../common/next-previous/NextPrevious';
import TableDataCard from '../common/table-data-card/TableDataCard';
@ -126,7 +123,7 @@ const SearchedData: React.FC<SearchedDataProp> = ({
indexType={table.index}
matches={matches}
name={name}
owner={getOwnerFromId(table.owner)?.name}
owner={table.owner?.displayName || table.owner?.name}
service={table.service}
serviceType={table.serviceType || '--'}
tableType={table.tableType as TableType}

View File

@ -47,7 +47,7 @@ export const onErrorText = 'Error while deleting message';
export const onUpdatedConversastionError =
'Error while getting updated conversation';
export const MENTION_ALLOWED_CHARS = /^w*$/;
export const MENTION_ALLOWED_CHARS = /^[A-Za-z0-9_]*$/;
export const MENTION_DENOTATION_CHARS = ['@', '#'];
export const TOOLBAR_ITEMS = [

View File

@ -12,7 +12,7 @@
*/
export enum Ownership {
OWNER = 'owner',
OWNER = 'owner.id',
FOLLOWERS = 'followers',
}

View File

@ -13,6 +13,23 @@
declare module 'Models' {
import { TagLabel } from '../generated/type/tagLabel';
export interface EntityReference {
deleted?: boolean;
description?: string;
displayName?: string;
fullyQualifiedName?: string;
href?: string;
id: string;
name?: string;
type: string;
}
export type Match = {
params: {
@ -189,7 +206,7 @@ declare module 'Models' {
name: string;
description: string;
fullyQualifiedName: string;
owner: string;
owner: EntityReference;
tableType?: string;
tags: string[] | TagLabel[];
dailyStats?: number;

View File

@ -176,7 +176,11 @@ const MyDataPage = () => {
'',
1,
8,
getMyDataFilters(Ownership.OWNER, AppState.userDetails),
getMyDataFilters(
Ownership.OWNER,
AppState.userDetails,
AppState.nonSecureUserDetails
),
'',
'',
myDataSearchIndex
@ -186,7 +190,11 @@ const MyDataPage = () => {
'',
1,
8,
getMyDataFilters(Ownership.FOLLOWERS, AppState.userDetails),
getMyDataFilters(
Ownership.FOLLOWERS,
AppState.userDetails,
AppState.nonSecureUserDetails
),
'',
'',
myDataSearchIndex

View File

@ -316,16 +316,29 @@ export const getHtmlForNonAdminAction = (isClaimOwner: boolean) => {
export const getOwnerIds = (
filter: Ownership,
userDetails: User
userDetails: User,
nonSecureUserDetails: User
): Array<string> => {
if (filter === Ownership.OWNER && userDetails.teams) {
const userTeams = !isEmpty(userDetails)
? userDetails.teams.map((team) => team.id)
: [];
return [...userTeams, getCurrentUserId()];
if (filter === Ownership.OWNER) {
if (!isEmpty(userDetails)) {
return [
...(userDetails.teams?.map((team) => team.id) as Array<string>),
userDetails.id,
];
} else {
if (!isEmpty(nonSecureUserDetails)) {
return [
...(nonSecureUserDetails.teams?.map(
(team) => team.id
) as Array<string>),
nonSecureUserDetails.id,
];
} else {
return [];
}
}
} else {
return [getCurrentUserId()];
return [userDetails.id || nonSecureUserDetails.id];
}
};

View File

@ -17,9 +17,10 @@ import { getOwnerIds } from './CommonUtils';
export const getMyDataFilters = (
filter: Ownership,
userDetails: User
userDetails: User,
nonSecureUserDetails: User
): string => {
return `(${getOwnerIds(filter, userDetails)
return `(${getOwnerIds(filter, userDetails, nonSecureUserDetails)
.map((id) => `${filter}:${id}`)
.join(' OR ')})`;
};