mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-08 13:36:32 +00:00
* Fix #4047 UI : Support owner entity reference from elastic search * Change mention char constant
This commit is contained in:
parent
110c0f503e
commit
3f3e38043c
@ -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;
|
||||
|
||||
@ -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>
|
||||
))
|
||||
|
||||
@ -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()}`;
|
||||
};
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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 = [
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
export enum Ownership {
|
||||
OWNER = 'owner',
|
||||
OWNER = 'owner.id',
|
||||
FOLLOWERS = 'followers',
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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 ')})`;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user