Fixed multiple table issue in freq joined section

This commit is contained in:
darth-coder00 2021-08-12 23:53:11 +05:30
parent ffd0e3f949
commit ff887b2b79
5 changed files with 32 additions and 11 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import React, { FunctionComponent } from 'react'; import React, { FunctionComponent, useEffect, useState } from 'react';
import { Link, useHistory } from 'react-router-dom'; import { Link, useHistory } from 'react-router-dom';
import { getDatasetDetailsPath } from '../../constants/constants'; import { getDatasetDetailsPath } from '../../constants/constants';
import PopOver from '../common/popover/PopOver'; import PopOver from '../common/popover/PopOver';
@ -27,20 +27,41 @@ type Props = {
const viewCap = 3; const viewCap = 3;
const getUniqueTablesWithCount = (tableFQNs: Props['tableList']) => {
return tableFQNs.reduce((resList, curr) => {
let duplicates = false;
for (const table of resList) {
if (table.fqn === curr.fqn) {
table.joinCount += curr.joinCount;
duplicates = true;
break;
}
}
return duplicates ? resList : [...resList, curr];
}, [] as Props['tableList']);
};
const FrequentlyJoinedTables: FunctionComponent<Props> = ({ const FrequentlyJoinedTables: FunctionComponent<Props> = ({
header, header,
tableList, tableList,
}: Props) => { }: Props) => {
const history = useHistory(); const history = useHistory();
const [joinedTables, setJoinedTables] = useState<Props['tableList']>([]);
const handleTableClick = (fqn: string) => { const handleTableClick = (fqn: string) => {
history.push(getDatasetDetailsPath(fqn)); history.push(getDatasetDetailsPath(fqn));
}; };
useEffect(() => {
setJoinedTables(getUniqueTablesWithCount(tableList));
}, [tableList]);
const additionalOptions = () => { const additionalOptions = () => {
return ( return (
<div> <div>
{tableList?.slice(viewCap).map((table, index) => ( {joinedTables?.slice(viewCap).map((table, index) => (
<div <div
className="tw-py-1 tw-cursor-pointer" className="tw-py-1 tw-cursor-pointer"
data-testid="related-tables-data" data-testid="related-tables-data"
@ -69,9 +90,9 @@ const FrequentlyJoinedTables: FunctionComponent<Props> = ({
</span> </span>
</div> </div>
<div className="tw-flex tw-flex-col tw-px-3 tw-py-2"> <div className="tw-flex tw-flex-col tw-px-3 tw-py-2">
{(tableList.length <= viewCap {(joinedTables.length <= viewCap
? tableList ? joinedTables
: tableList.slice(0, viewCap) : joinedTables.slice(0, viewCap)
).map((table, index) => { ).map((table, index) => {
return ( return (
<div <div
@ -86,7 +107,7 @@ const FrequentlyJoinedTables: FunctionComponent<Props> = ({
); );
})} })}
{tableList.length > viewCap && ( {joinedTables.length > viewCap && (
<div data-testid="related-tables-data"> <div data-testid="related-tables-data">
<PopOver <PopOver
html={additionalOptions()} html={additionalOptions()}
@ -94,7 +115,7 @@ const FrequentlyJoinedTables: FunctionComponent<Props> = ({
theme="light" theme="light"
trigger="click"> trigger="click">
<span className="show-more"> <span className="show-more">
{`+ ${tableList.length - viewCap} more`} {`+ ${joinedTables.length - viewCap} more`}
</span> </span>
</PopOver> </PopOver>
</div> </div>

View File

@ -442,7 +442,7 @@ const MyDataDetailsPage = () => {
{activeTab === 1 && ( {activeTab === 1 && (
<div className="tw-grid tw-grid-cols-4 tw-gap-4 w-full"> <div className="tw-grid tw-grid-cols-4 tw-gap-4 w-full">
<div className="tw-col-span-3"> <div className="tw-col-span-3">
<div className="schema-description tw-flex tw-flex-col tw-h-full tw-max-h-32 tw-relative tw-border tw-border-main tw-rounded-md"> <div className="schema-description tw-flex tw-flex-col tw-h-full tw-min-h-168 tw-relative tw-border tw-border-main tw-rounded-md">
<div className="tw-flex tw-items-center tw-px-3 tw-py-1 tw-border-b tw-border-main"> <div className="tw-flex tw-items-center tw-px-3 tw-py-1 tw-border-b tw-border-main">
<span className="tw-flex-1 tw-leading-8 tw-m-0 tw-text-sm tw-font-normal"> <span className="tw-flex-1 tw-leading-8 tw-m-0 tw-text-sm tw-font-normal">
Description Description

View File

@ -157,7 +157,7 @@
} }
.tw-tag { .tw-tag {
@apply tw-py-1 tw-px-3 tw-text-xs tw-font-normal tw-rounded-2xl tw-bg-gray-200; @apply tw-py-1 tw-px-3 tw-text-xs tw-font-normal tw-rounded-2xl tw-bg-tag;
} }
.tw-signin-button { .tw-signin-button {

View File

@ -647,8 +647,7 @@
color: #5e5c58; color: #5e5c58;
} }
/* My data details page realted CSS */ /* My data details page realted CSS */
.sl-box.description, .sl-box.description {
.schema-description {
min-height: 138px; min-height: 138px;
} }

View File

@ -101,6 +101,7 @@ module.exports = {
}, },
minHeight: { minHeight: {
32: '8rem', 32: '8rem',
168: '10.5rem',
}, },
padding: { padding: {
'5px': '5px', '5px': '5px',