@finos/legend-application-marketplace
Version:
Legend Marketplace application core
44 lines • 3.86 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* 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 { useState } from 'react';
import { Chip, IconButton } from '@mui/material';
import { clsx, MarkdownTextViewer, StarIcon, EmptyStarIcon, } from '@finos/legend-art';
import { ServiceOwnershipType } from '@finos/legend-graph';
import { LegendMarketplaceListItem } from '../MarketplaceCard/LegendMarketplaceListItem.js';
const MAX_DESCRIPTION_LENGTH = 250;
export const LegendServiceListRow = observer((props) => {
const { serviceCardState, onClick, isFavorite, onToggleFavorite } = props;
const [expanded, setExpanded] = useState(false);
const description = serviceCardState.description;
const isTruncatable = description.length > MAX_DESCRIPTION_LENGTH;
const displayDescription = !expanded && isTruncatable
? `${description.substring(0, MAX_DESCRIPTION_LENGTH)}...`
: description;
return (_jsx(LegendMarketplaceListItem, { className: "marketplace-legend-service-list-row", onClick: onClick, cardMedia: serviceCardState.displayImage, content: _jsxs("div", { className: "marketplace-legend-service-list-row__body", children: [_jsxs("div", { className: "marketplace-legend-service-list-row__header", children: [_jsx(IconButton, { className: clsx('marketplace-legend-service-list-row__favorite-btn', isFavorite &&
'marketplace-legend-service-list-row__favorite-btn--active'), onClick: (e) => {
e.stopPropagation();
onToggleFavorite();
}, size: "small", title: isFavorite ? 'Remove from favorites' : 'Add to favorites', children: isFavorite ? _jsx(StarIcon, {}) : _jsx(EmptyStarIcon, {}) }), _jsxs("div", { className: "marketplace-legend-service-list-row__title-block", children: [_jsx("div", { className: "marketplace-legend-service-list-row__name", children: serviceCardState.title }), _jsx("div", { className: "marketplace-legend-service-list-row__pattern", children: serviceCardState.service.pattern })] }), _jsx("div", { className: "marketplace-legend-service-list-row__tags", children: serviceCardState.owners.map((owner) => (_jsx(Chip, { size: "small", label: owner, className: `marketplace-legend-service-list-row__chip marketplace-legend-service-list-row__chip--${serviceCardState.ownershipType ===
ServiceOwnershipType.DEPLOYMENT_OWNERSHIP
? 'did'
: 'owner'}` }, owner))) })] }), description && (_jsxs("div", { className: "marketplace-legend-service-list-row__description", children: [_jsx(MarkdownTextViewer, { className: "marketplace-legend-service-list-row__description__markdown", value: { value: displayDescription }, components: { h1: 'h2', h2: 'h3', h3: 'h4' } }), isTruncatable && (_jsx("button", { className: "marketplace-legend-service-list-row__description__toggle", onClick: (e) => {
e.stopPropagation();
setExpanded(!expanded);
}, children: expanded ? 'Show less' : 'Show more' }))] }))] }) }));
});
//# sourceMappingURL=LegendServiceListRow.js.map