/** * 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 { observer } from 'mobx-react-lite'; import { Box, Chip, IconButton } from '@mui/material'; import { clsx, MarkdownTextViewer, StarIcon, EmptyStarIcon, } from '@finos/legend-art'; import { LegendMarketplaceCard } from '../MarketplaceCard/LegendMarketplaceCard.js'; import { type LegendServiceCardState } from '../../stores/dataAPIs/LegendMarketplaceDataAPIsStore.js'; import { ServiceOwnershipType } from '@finos/legend-graph'; const MAX_DESCRIPTION_LENGTH = 250; export const LegendServiceCard = observer( (props: { serviceCardState: LegendServiceCardState; onClick: () => void; isFavorite: boolean; onToggleFavorite: () => void; }): React.ReactNode => { const { serviceCardState, onClick, isFavorite, onToggleFavorite } = props; const truncatedDescription = serviceCardState.description && serviceCardState.description.length > MAX_DESCRIPTION_LENGTH ? `${serviceCardState.description.substring( 0, MAX_DESCRIPTION_LENGTH, )}...` : serviceCardState.description; const content = ( { e.stopPropagation(); onToggleFavorite(); }} size="small" title={isFavorite ? 'Remove from favorites' : 'Add to favorites'} > {isFavorite ? : } {serviceCardState.ownershipType && ( )} ); const moreInfoContent = ( <> {serviceCardState.title} {serviceCardState.service.pattern} {truncatedDescription && ( )} {serviceCardState.owners.length > 0 && ( {serviceCardState.owners.map((owner) => ( ))} )} ); return ( ); }, );