/* * Copyright 2023 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 { Col, Row, Space, Tabs, TabsProps } from 'antd'; import classNames from 'classnames'; import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; import DescriptionV1 from 'components/common/description/DescriptionV1'; import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; import TabsLabel from 'components/TabsLabel/TabsLabel.component'; import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; import { getVersionPathWithTab } from 'constants/constants'; import { EntityField } from 'constants/Feeds.constants'; import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; import { ChangeDescription, Column, Container, } from 'generated/entity/data/container'; import { TagSource } from 'generated/type/tagLabel'; import { cloneDeep, toString } from 'lodash'; import React, { useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useHistory, useParams } from 'react-router-dom'; import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; import { EntityTabs, EntityType, FqnPart } from '../../enums/entity.enum'; import { getPartialNameFromTableFQN } from '../../utils/CommonUtils'; import { getColumnsDataWithVersionChanges, getCommonExtraInfoForVersionDetails, getEntityVersionByField, getEntityVersionTags, } from '../../utils/EntityVersionUtils'; import EntityVersionTimeLine from '../EntityVersionTimeLine/EntityVersionTimeLine'; import Loader from '../Loader/Loader'; import VersionTable from '../VersionTable/VersionTable.component'; import { ContainerVersionProp } from './ContainerVersion.interface'; const ContainerVersion: React.FC = ({ version, currentVersionData, isVersionLoading, owner, tier, containerFQN, breadCrumbList, versionList, deleted = false, backHandler, versionHandler, entityPermissions, }: ContainerVersionProp) => { const { t } = useTranslation(); const history = useHistory(); const { tab } = useParams<{ tab: EntityTabs }>(); const [changeDescription, setChangeDescription] = useState( currentVersionData.changeDescription as ChangeDescription ); const { ownerDisplayName, ownerRef, tierDisplayName } = useMemo( () => getCommonExtraInfoForVersionDetails(changeDescription, owner, tier), [changeDescription, owner, tier] ); const columns = useMemo(() => { const colList = cloneDeep( (currentVersionData as Container).dataModel?.columns ); return getColumnsDataWithVersionChanges(changeDescription, colList); }, [currentVersionData, changeDescription]); const handleTabChange = (activeKey: string) => { history.push( getVersionPathWithTab( EntityType.CONTAINER, containerFQN, String(version), activeKey ) ); }; useEffect(() => { setChangeDescription( currentVersionData.changeDescription as ChangeDescription ); }, [currentVersionData]); const tags = useMemo(() => { return getEntityVersionTags(currentVersionData, changeDescription); }, [currentVersionData, changeDescription]); const description = useMemo(() => { return getEntityVersionByField( changeDescription, EntityField.DESCRIPTION, currentVersionData.description ); }, [currentVersionData, changeDescription]); const displayName = useMemo(() => { return getEntityVersionByField( changeDescription, EntityField.DISPLAYNAME, currentVersionData.displayName ); }, [currentVersionData, changeDescription]); const tabItems: TabsProps['items'] = useMemo( () => [ { key: EntityTabs.SCHEMA, label: , children: ( {Object.keys(TagSource).map((tagType) => ( ))} ), }, { key: EntityTabs.CUSTOM_PROPERTIES, label: ( ), children: !entityPermissions.ViewAll ? ( ) : ( ), }, ], [description, containerFQN, columns, currentVersionData, entityPermissions] ); if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { return ; } return ( <> {isVersionLoading ? ( ) : (
)} ); }; export default ContainerVersion;