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

View File

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

View File

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