Skip to content

Commit

Permalink
supported class base tab in databaseSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish8689 committed Oct 20, 2024
1 parent df48ebd commit 4c75d5a
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,15 @@ import React, {
} from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory, useParams } from 'react-router-dom';
import ActivityFeedProvider, {
useActivityFeedProvider,
} from '../../components/ActivityFeed/ActivityFeedProvider/ActivityFeedProvider';
import { ActivityFeedTab } from '../../components/ActivityFeed/ActivityFeedTab/ActivityFeedTab.component';
import { useActivityFeedProvider } from '../../components/ActivityFeed/ActivityFeedProvider/ActivityFeedProvider';
import ActivityThreadPanel from '../../components/ActivityFeed/ActivityThreadPanel/ActivityThreadPanel';
import { withActivityFeed } from '../../components/AppRouter/withActivityFeed';
import { CustomPropertyTable } from '../../components/common/CustomPropertyTable/CustomPropertyTable';
import ErrorPlaceHolder from '../../components/common/ErrorWithPlaceholder/ErrorPlaceHolder';
import Loader from '../../components/common/Loader/Loader';
import { PagingHandlerParams } from '../../components/common/NextPrevious/NextPrevious.interface';
import ResizablePanels from '../../components/common/ResizablePanels/ResizablePanels';
import TabsLabel from '../../components/common/TabsLabel/TabsLabel.component';
import { DataAssetsHeader } from '../../components/DataAssets/DataAssetsHeader/DataAssetsHeader.component';
import ProfilerSettings from '../../components/Database/Profiler/ProfilerSettings/ProfilerSettings';
import { QueryVote } from '../../components/Database/TableQueries/TableQueries.interface';
import EntityRightPanel from '../../components/Entity/EntityRightPanel/EntityRightPanel';
import { EntityName } from '../../components/Modals/EntityNameModal/EntityNameModal.interface';
import PageLayoutV1 from '../../components/PageLayoutV1/PageLayoutV1';
import {
Expand All @@ -50,7 +43,6 @@ import {
ROUTES,
} from '../../constants/constants';
import { FEED_COUNT_INITIAL_DATA } from '../../constants/entity.constants';
import { COMMON_RESIZABLE_PANEL_CONFIG } from '../../constants/ResizablePanel.constants';
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
import {
OperationPermission,
Expand All @@ -72,7 +64,6 @@ import { Include } from '../../generated/type/include';
import { TagLabel } from '../../generated/type/tagLabel';
import { useFqn } from '../../hooks/useFqn';
import { FeedCounts } from '../../interface/feed.interface';
import StoredProcedureTab from '../../pages/StoredProcedure/StoredProcedureTab';
import {
getDatabaseSchemaDetailsByFQN,
patchDatabaseSchemaDetails,
Expand All @@ -87,13 +78,13 @@ import {
getFeedCounts,
sortTagsCaseInsensitive,
} from '../../utils/CommonUtils';
import databaseSchemaClassBase from '../../utils/DatabaseSchemaClassBase';
import entityUtilClassBase from '../../utils/EntityUtilClassBase';
import { getEntityName } from '../../utils/EntityUtils';
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
import { getTagsWithoutTier, getTierTags } from '../../utils/TableUtils';
import { createTagObject, updateTierTag } from '../../utils/TagsUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import SchemaTablesTab from './SchemaTablesTab';

const DatabaseSchemaPage: FunctionComponent = () => {
const { postFeed, deleteFeed, updateFeed } = useActivityFeedProvider();
Expand Down Expand Up @@ -572,135 +563,68 @@ const DatabaseSchemaPage: FunctionComponent = () => {
});
};

const tabs: TabsProps['items'] = [
{
label: (
<TabsLabel
count={tableData.paging.total}
id={EntityTabs.TABLE}
isActive={activeTab === EntityTabs.TABLE}
name={t('label.table-plural')}
/>
),
key: EntityTabs.TABLE,
children: (
<Row gutter={[0, 16]} wrap={false}>
<Col className="tab-content-height-with-resizable-panel" span={24}>
<ResizablePanels
firstPanel={{
className: 'entity-resizable-panel-container',
children: (
<div className="p-t-sm m-x-lg">
<SchemaTablesTab
currentTablesPage={currentTablesPage}
databaseSchemaDetails={databaseSchema}
description={description}
editDescriptionPermission={editDescriptionPermission}
isEdit={isEdit}
showDeletedTables={showDeletedTables}
tableData={tableData}
tableDataLoading={tableDataLoading}
tablePaginationHandler={tablePaginationHandler}
onCancel={onEditCancel}
onDescriptionEdit={onDescriptionEdit}
onDescriptionUpdate={onDescriptionUpdate}
onShowDeletedTablesChange={handleShowDeletedTables}
onThreadLinkSelect={onThreadLinkSelect}
/>
</div>
),
...COMMON_RESIZABLE_PANEL_CONFIG.LEFT_PANEL,
}}
secondPanel={{
children: (
<div data-testid="entity-right-panel">
<EntityRightPanel<EntityType.DATABASE_SCHEMA>
customProperties={databaseSchema}
dataProducts={databaseSchema?.dataProducts ?? []}
domain={databaseSchema?.domain}
editCustomAttributePermission={
editCustomAttributePermission
}
editTagPermission={editTagsPermission}
entityFQN={decodedDatabaseSchemaFQN}
entityId={databaseSchema?.id ?? ''}
entityType={EntityType.DATABASE_SCHEMA}
selectedTags={tags}
viewAllPermission={viewAllPermission}
onExtensionUpdate={handleExtensionUpdate}
onTagSelectionChange={handleTagSelection}
onThreadLinkSelect={onThreadLinkSelect}
/>
</div>
),
...COMMON_RESIZABLE_PANEL_CONFIG.RIGHT_PANEL,
className:
'entity-resizable-right-panel-container entity-resizable-panel-container',
}}
/>
</Col>
</Row>
),
},
{
label: (
<TabsLabel
count={storedProcedureCount}
id={EntityTabs.STORED_PROCEDURE}
isActive={activeTab === EntityTabs.STORED_PROCEDURE}
name={t('label.stored-procedure-plural')}
/>
),
key: EntityTabs.STORED_PROCEDURE,
children: <StoredProcedureTab />,
},
{
label: (
<TabsLabel
count={feedCount.totalCount}
id={EntityTabs.ACTIVITY_FEED}
isActive={activeTab === EntityTabs.ACTIVITY_FEED}
name={t('label.activity-feed-plural')}
/>
),
key: EntityTabs.ACTIVITY_FEED,
children: (
<ActivityFeedProvider>
<ActivityFeedTab
refetchFeed
entityFeedTotalCount={feedCount.totalCount}
entityType={EntityType.DATABASE_SCHEMA}
fqn={databaseSchema.fullyQualifiedName ?? ''}
onFeedUpdate={getEntityFeedCount}
onUpdateEntityDetails={fetchDatabaseSchemaDetails}
onUpdateFeedCount={handleFeedCount}
/>
</ActivityFeedProvider>
),
},
{
label: (
<TabsLabel
id={EntityTabs.CUSTOM_PROPERTIES}
name={t('label.custom-property-plural')}
/>
),
key: EntityTabs.CUSTOM_PROPERTIES,
children: databaseSchema && (
<div className="m-sm">
<CustomPropertyTable<EntityType.DATABASE_SCHEMA>
className=""
entityDetails={databaseSchema}
entityType={EntityType.DATABASE_SCHEMA}
handleExtensionUpdate={handleExtensionUpdate}
hasEditAccess={editCustomAttributePermission}
hasPermission={viewAllPermission}
isVersionView={false}
/>
</div>
),
},
];
const tabs: TabsProps['items'] = useMemo(
() =>
databaseSchemaClassBase.getDatabaseSchemaPageTabs({
feedCount,
tableData,
activeTab,
currentTablesPage,
databaseSchema,
description,
editDescriptionPermission,
isEdit,
showDeletedTables,
tableDataLoading,
editCustomAttributePermission,
editTagsPermission,
decodedDatabaseSchemaFQN,
tags,
viewAllPermission,
storedProcedureCount,
onEditCancel,
handleExtensionUpdate,
handleTagSelection,
onThreadLinkSelect,
tablePaginationHandler,
onDescriptionEdit,
onDescriptionUpdate,
handleShowDeletedTables,
getEntityFeedCount,
fetchDatabaseSchemaDetails,
handleFeedCount,
}),
[
feedCount,
tableData,
activeTab,
currentTablesPage,
databaseSchema,
description,
editDescriptionPermission,
isEdit,
showDeletedTables,
tableDataLoading,
databaseSchema,
editCustomAttributePermission,
editTagsPermission,
decodedDatabaseSchemaFQN,
tags,
viewAllPermission,
storedProcedureCount,
handleExtensionUpdate,
handleTagSelection,
onThreadLinkSelect,
tablePaginationHandler,
onEditCancel,
onDescriptionEdit,
onDescriptionUpdate,
handleShowDeletedTables,
getEntityFeedCount,
fetchDatabaseSchemaDetails,
handleFeedCount,
]
);

const updateVote = async (data: QueryVote, id: string) => {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TabsProps } from 'antd';
import { EntityTags, PagingResponse } from 'Models';
import { PagingHandlerParams } from '../components/common/NextPrevious/NextPrevious.interface';
import { EntityTabs } from '../enums/entity.enum';
import { DatabaseSchema } from '../generated/entity/data/databaseSchema';
import { Table } from '../generated/entity/data/table';
import { ThreadType } from '../generated/entity/feed/thread';
import { FeedCounts } from '../interface/feed.interface';
import { getDataBaseSchemaPageBaseTabs } from './DatabaseSchemaDetailsUtils';

export interface DatabaseSchemaPageTabProps {
feedCount: FeedCounts;
tableData: PagingResponse<Table[]>;
activeTab: EntityTabs;
currentTablesPage: number;
databaseSchema: DatabaseSchema;
description: string;
editDescriptionPermission: boolean;
isEdit: boolean;
showDeletedTables: boolean;
tableDataLoading: boolean;
editCustomAttributePermission: boolean;
editTagsPermission: boolean;
decodedDatabaseSchemaFQN: string;
tags: any[];
viewAllPermission: boolean;
storedProcedureCount: number;
handleExtensionUpdate: (schema: DatabaseSchema) => Promise<void>;
handleTagSelection: (selectedTags: EntityTags[]) => Promise<void>;
onThreadLinkSelect: (link: string, threadType?: ThreadType) => void;
tablePaginationHandler: ({
cursorType,
currentPage,
}: PagingHandlerParams) => void;
onEditCancel: () => void;
onDescriptionEdit: () => void;
onDescriptionUpdate: (updatedHTML: string) => Promise<void>;
handleShowDeletedTables: (value: boolean) => void;
getEntityFeedCount: () => void;
fetchDatabaseSchemaDetails: () => Promise<void>;
handleFeedCount: (data: FeedCounts) => void;
}

class DatabaseSchemaClassBase {
public getDatabaseSchemaPageTabs(
databaseSchemaTabData: DatabaseSchemaPageTabProps
): TabsProps['items'] {
return getDataBaseSchemaPageBaseTabs(databaseSchemaTabData);
}
}

const databaseSchemaClassBase = new DatabaseSchemaClassBase();

export default databaseSchemaClassBase;
export { DatabaseSchemaClassBase };

This file was deleted.

Loading

0 comments on commit 4c75d5a

Please sign in to comment.