/** * Copyright (c) 2026-present, Goldman Sachs * * 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 { clsx } from '@finos/legend-art'; import { V1_EntitlementsLakehouseEnvironmentType } from '@finos/legend-graph'; import { isSnapshotVersion } from '@finos/legend-server-depot'; import { LakehouseDataProductSearchResultDetails } from '@finos/legend-server-marketplace'; import { Chip } from '@mui/material'; import { observer } from 'mobx-react-lite'; import { useRef, useState } from 'react'; import type { ProductCardState } from '../../stores/lakehouse/dataProducts/ProductCardState.js'; import { DevelopmentLegendMarketplaceEnvState, ProdParallelLegendMarketplaceEnvState, } from '../../stores/LegendMarketplaceEnvState.js'; import { getDataProductLicenseDisplayLabel } from '../../stores/lakehouse/LegendMarketplaceSearchResultsStore.js'; import { getHumanReadableIngestEnvName, LakehouseDataProductOwnersTooltip, } from '@finos/legend-extension-dsl-data-product'; import { useAuth } from 'react-oidc-context'; import { flowResult } from 'mobx'; export const DATA_PRODUCT_MARKDOWN_COMPONENTS: Record< string, | string | (( linkProps: React.AnchorHTMLAttributes, ) => React.ReactNode) > = { h1: 'h2', h2: 'h3', h3: 'h4', a: (linkProps: React.AnchorHTMLAttributes) => ( e.stopPropagation()} /> ), }; export const LakehouseProductTags = observer( (props: { productCardState: ProductCardState }): React.ReactNode => { const { productCardState } = props; const auth = useAuth(); const tokenRef = useRef(auth.user?.access_token); tokenRef.current = auth.user?.access_token; const [isOwnersTooltipOpen, setIsOwnersTooltipOpen] = useState(false); const versionId = productCardState.versionId; const isSnapshot = versionId ? isSnapshotVersion(versionId) : undefined; const isLakehouse = productCardState.searchResult.dataProductDetails instanceof LakehouseDataProductSearchResultDetails; return ( <> {isLakehouse && ( { await flowResult(productCardState.fetchOwners(tokenRef.current)); }} applicationStore={ productCardState.marketplaceBaseStore.applicationStore } userSearchService={ productCardState.marketplaceBaseStore.userSearchService } >
{ event.stopPropagation(); setIsOwnersTooltipOpen((val) => !val); }} title="Click to view owners" className="marketplace-lakehouse-data-product-card__lakehouse-env-chip" />
)} {isSnapshot && ( )} {(productCardState.marketplaceBaseStore.envState instanceof ProdParallelLegendMarketplaceEnvState || productCardState.marketplaceBaseStore.envState instanceof DevelopmentLegendMarketplaceEnvState) && productCardState.searchResult.dataProductDetails instanceof LakehouseDataProductSearchResultDetails && ( )} {productCardState.searchResult.dataProductSource === 'External' && ( )} {productCardState.searchResult.licenseTo && ( )} ); }, );