Fix #3473: we need to show own assets in owned and following tab. (#3482)

This commit is contained in:
Shailesh Parmar 2022-03-18 00:23:42 +05:30 committed by GitHub
parent 98421f2d56
commit 55177b13cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 24 deletions

View File

@ -1,5 +1,5 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { EntityType } from '../../enums/entity.enum'; import { AssetsType } from '../../enums/entity.enum';
import { EntityReference, User } from '../../generated/entity/teams/user'; import { EntityReference, User } from '../../generated/entity/teams/user';
import UserCard from '../../pages/teams/UserCard'; import UserCard from '../../pages/teams/UserCard';
import SVGIcons, { Icons } from '../../utils/SvgUtils'; import SVGIcons, { Icons } from '../../utils/SvgUtils';
@ -43,10 +43,10 @@ const Users = ({ userData }: Props) => {
}, },
]; ];
const getEntityDetails = (data: EntityReference[]) => { const getAssets = (data: EntityReference[]) => {
const includedEntity = Object.values(EntityType); const includedEntity = Object.values(AssetsType);
return data.filter((d) => includedEntity.includes(d.type as EntityType)); return data.filter((d) => includedEntity.includes(d.type as AssetsType));
}; };
const fetchLeftPanel = () => { const fetchLeftPanel = () => {
@ -142,14 +142,14 @@ const Users = ({ userData }: Props) => {
<div> <div>
{activeTab === 1 && {activeTab === 1 &&
getEntityData( getEntityData(
getEntityDetails(userData?.owns || []), getAssets(userData?.owns || []),
`${ `${
userData?.displayName || userData?.name || 'User' userData?.displayName || userData?.name || 'User'
} does not own anything yet` } does not own anything yet`
)} )}
{activeTab === 2 && {activeTab === 2 &&
getEntityData( getEntityData(
getEntityDetails(userData?.follows || []), getAssets(userData?.follows || []),
`${ `${
userData?.displayName || userData?.name || 'User' userData?.displayName || userData?.name || 'User'
} does not follow anything yet` } does not follow anything yet`

View File

@ -27,6 +27,13 @@ export enum EntityType {
WEBHOOK = 'webhook', WEBHOOK = 'webhook',
} }
export enum AssetsType {
TABLE = 'table',
TOPIC = 'topic',
DASHBOARD = 'dashboard',
PIPELINE = 'pipeline',
}
export enum ChangeType { export enum ChangeType {
ADDED = 'Added', ADDED = 'Added',
UPDATED = 'Updated', UPDATED = 'Updated',

View File

@ -18,6 +18,7 @@ import { Link } from 'react-router-dom';
import { useAuthContext } from '../../auth-provider/AuthProvider'; import { useAuthContext } from '../../auth-provider/AuthProvider';
import Avatar from '../../components/common/avatar/Avatar'; import Avatar from '../../components/common/avatar/Avatar';
import NonAdminAction from '../../components/common/non-admin-action/NonAdminAction'; import NonAdminAction from '../../components/common/non-admin-action/NonAdminAction';
import { AssetsType } from '../../enums/entity.enum';
import { SearchIndex } from '../../enums/search.enum'; import { SearchIndex } from '../../enums/search.enum';
import { Operation } from '../../generated/entity/policies/accessControl/rule'; import { Operation } from '../../generated/entity/policies/accessControl/rule';
import { useAuth } from '../../hooks/authHooks'; import { useAuth } from '../../hooks/authHooks';
@ -35,13 +36,6 @@ type Props = {
onRemove?: (value: string) => void; onRemove?: (value: string) => void;
}; };
enum DatasetType {
TABLE = 'table',
TOPIC = 'topic',
DASHBOARD = 'dashboard',
PIPELINE = 'pipeline',
}
const UserCard = ({ const UserCard = ({
item, item,
isActionVisible = false, isActionVisible = false,
@ -57,10 +51,10 @@ const UserCard = ({
type: string type: string
): Array<'service' | 'database' | 'table' | 'column'> => { ): Array<'service' | 'database' | 'table' | 'column'> => {
switch (type) { switch (type) {
case DatasetType.TABLE: case AssetsType.TABLE:
return ['database', 'table']; return ['database', 'table'];
case DatasetType.TOPIC: case AssetsType.TOPIC:
case DatasetType.DASHBOARD: case AssetsType.DASHBOARD:
default: default:
return ['service', 'database', 'table']; return ['service', 'database', 'table'];
} }
@ -69,19 +63,19 @@ const UserCard = ({
const getDatasetIcon = (type: string) => { const getDatasetIcon = (type: string) => {
let icon = ''; let icon = '';
switch (type) { switch (type) {
case DatasetType.TOPIC: case AssetsType.TOPIC:
icon = Icons.TOPIC; icon = Icons.TOPIC;
break; break;
case DatasetType.DASHBOARD: case AssetsType.DASHBOARD:
icon = Icons.DASHBOARD; icon = Icons.DASHBOARD;
break; break;
case DatasetType.PIPELINE: case AssetsType.PIPELINE:
icon = Icons.PIPELINE; icon = Icons.PIPELINE;
break; break;
case DatasetType.TABLE: case AssetsType.TABLE:
default: default:
icon = Icons.TABLE; icon = Icons.TABLE;
@ -92,7 +86,7 @@ const UserCard = ({
<SVGIcons <SVGIcons
alt="icon" alt="icon"
className={classNames('tw-h-4 tw-w-4', { className={classNames('tw-h-4 tw-w-4', {
'tw-mt-0.5': type !== DatasetType.DASHBOARD, 'tw-mt-0.5': type !== AssetsType.DASHBOARD,
})} })}
icon={icon} icon={icon}
/> />
@ -102,15 +96,19 @@ const UserCard = ({
const getDatasetTitle = (type: string, fqn: string) => { const getDatasetTitle = (type: string, fqn: string) => {
let link = ''; let link = '';
switch (type) { switch (type) {
case DatasetType.TOPIC: case AssetsType.TOPIC:
link = getEntityLink(SearchIndex.TOPIC, fqn); link = getEntityLink(SearchIndex.TOPIC, fqn);
break; break;
case DatasetType.DASHBOARD: case AssetsType.PIPELINE:
link = getEntityLink(SearchIndex.PIPELINE, fqn);
break;
case AssetsType.DASHBOARD:
link = getEntityLink(SearchIndex.DASHBOARD, fqn); link = getEntityLink(SearchIndex.DASHBOARD, fqn);
break; break;
case DatasetType.TABLE: case AssetsType.TABLE:
default: default:
link = getEntityLink(SearchIndex.TABLE, fqn); link = getEntityLink(SearchIndex.TABLE, fqn);