UNPKG

@finos/legend-application-marketplace

Version:
140 lines 15.2 kB
import { createElement as _createElement } from "react"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; /** * Copyright (c) 2025-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 { useEffect, useCallback } from 'react'; import { LegendMarketplaceSearchBar } from '../../components/SearchBar/LegendMarketplaceSearchBar.js'; import { Button, Tooltip, Typography, List, ListItem, CircularProgress, } from '@mui/material'; import { LegendMarketplaceTerminalCard } from '../../components/ProviderCard/LegendMarketplaceTerminalCard.js'; import { LegendMarketplaceOrderProfileCard } from '../../components/ProviderCard/LegendMarketplaceOrderProfileCard.js'; import { VendorDataProviderType, } from '../../stores/LegendMarketPlaceVendorDataStore.js'; import { LegendMarketplacePage } from '../LegendMarketplacePage.js'; import { useLegendMarketPlaceVendorDataStore, withLegendMarketplaceVendorDataStore, } from '../../application/providers/LegendMarketplaceVendorDataProvider.js'; import { useParams } from '@finos/legend-application/browser'; import { InfoCircleIcon, UserSearchInput } from '@finos/legend-art'; import { flowResult } from 'mobx'; import { useLegendMarketplaceBaseStore } from '../../application/providers/LegendMarketplaceFrameworkProvider.js'; import { PaginationControls } from '../../components/Pagination/PaginationControls.js'; import { UserRenderer } from '@finos/legend-extension-dsl-data-product'; import { LegendMarketplaceOptionSelector } from '../../components/OptionSelector/LegendMarketplaceOptionSelector.js'; export const RefinedVendorRadioSelector = observer((props) => { const { vendorDataState } = props; const radioOptions = [ VendorDataProviderType.ALL, VendorDataProviderType.TERMINAL_LICENSE, VendorDataProviderType.ADD_ONS, VendorDataProviderType.ORDER_PROFILE, ]; const onRadioChange = useCallback((value) => { vendorDataState.setProviderDisplayState(value); flowResult(vendorDataState.populateProviders()).catch(vendorDataState.applicationStore.alertUnhandledError); }, [vendorDataState]); return (_jsx(LegendMarketplaceOptionSelector, { options: radioOptions, selectedOption: vendorDataState.providerDisplayState, onChange: onRadioChange, ariaLabel: "Vendor data provider type" })); }); /** * Shared section wrapper that renders the header (title, count badge, tooltip, * "See All" button) plus any card content passed via the `renderCards` prop. * Use this as the base for both terminal/add-on and order-profile sections so * the header logic lives in exactly one place. */ const SearchResultsSection = observer((props) => { const { vendorDataState, sectionTitle, itemCount, totalCount, tooltip, seeAll, renderCards, } = props; const showCount = vendorDataState.searchTerm.trim().length > 0; return (_jsxs("div", { children: [_jsxs("div", { className: "legend-marketplace-vendordata-main-search-results__category", children: [_jsxs("div", { className: "legend-marketplace-vendordata-main-sidebar__title", children: [sectionTitle, showCount && (_jsxs("span", { className: "legend-marketplace-vendordata-main-sidebar__title__count", children: ["(", totalCount ?? itemCount, ")"] }))] }), tooltip && (_jsx(Tooltip, { title: tooltip, placement: 'right', arrow: true, children: _jsx(InfoCircleIcon, {}) })), seeAll && (_jsx("button", { className: "see-all", onClick: () => { vendorDataState.setProviderDisplayState(sectionTitle); flowResult(vendorDataState.populateProviders()).catch(vendorDataState.applicationStore.alertUnhandledError); }, children: _jsx("strong", { children: "See All>" }) }))] }), renderCards()] })); }); const SearchResultsRenderer = observer((props) => { const { vendorDataState, terminalResults, sectionTitle, totalCount, seeAll, tooltip, } = props; return (_jsx(SearchResultsSection, { vendorDataState: vendorDataState, sectionTitle: sectionTitle, itemCount: terminalResults.length, totalCount: totalCount, seeAll: seeAll, tooltip: tooltip, renderCards: () => (_jsx("div", { className: "legend-marketplace-vendordata-main-search-results__card-group", children: terminalResults.map((terminal) => (_jsx(LegendMarketplaceTerminalCard, { terminalResult: terminal }, terminal.id))) })) })); }); const OrderProfileSearchResultsRenderer = observer((props) => { const { vendorDataState, traderProfiles, totalCount, tooltip, seeAll } = props; return (_jsx(SearchResultsSection, { vendorDataState: vendorDataState, sectionTitle: VendorDataProviderType.ORDER_PROFILE, itemCount: traderProfiles.length, totalCount: totalCount, seeAll: seeAll, tooltip: tooltip, renderCards: () => traderProfiles.length === 0 ? (_jsx("div", { className: "legend-marketplace-vendordata-main__empty", children: "No Order Profiles available" })) : (_jsx("div", { className: "legend-marketplace-vendordata-main-search-results__card-group", children: traderProfiles.map((profile) => (_jsx(LegendMarketplaceOrderProfileCard, { traderProfile: profile }, profile.id))) })) })); }); export const VendorDataMainContent = observer((props) => { const { marketPlaceVendorDataState } = props; const addOnsInfoMessage = 'Add-ons cannot be ordered standalone. You must order terminal license with them.'; const handlePageChange = useCallback((page) => { marketPlaceVendorDataState.setPage(page); flowResult(marketPlaceVendorDataState.populateProviders()).catch(marketPlaceVendorDataState.applicationStore.alertUnhandledError); }, [marketPlaceVendorDataState]); const handleItemsPerPageChange = useCallback((itemsPerPage) => { marketPlaceVendorDataState.setItemsPerPage(itemsPerPage); flowResult(marketPlaceVendorDataState.populateProviders()).catch(marketPlaceVendorDataState.applicationStore.alertUnhandledError); }, [marketPlaceVendorDataState]); return (_jsx("div", { className: "legend-marketplace-vendordata-main", children: marketPlaceVendorDataState.fetchingProvidersState.isInProgress ? (_jsx("div", { className: "legend-marketplace-vendordata-main__loading", children: _jsx(CircularProgress, {}) })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "legend-marketplace-vendordata-main-search-results", children: [marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.ALL && (_jsxs(_Fragment, { children: [_jsx(SearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, terminalResults: marketPlaceVendorDataState.terminalProviders, sectionTitle: VendorDataProviderType.TERMINAL_LICENSE, totalCount: marketPlaceVendorDataState.totalTerminalItems, seeAll: true }), _jsx("hr", {}), _jsx(SearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, terminalResults: marketPlaceVendorDataState.addOnProviders, sectionTitle: VendorDataProviderType.ADD_ONS, totalCount: marketPlaceVendorDataState.totalAddOnItems, seeAll: true, tooltip: addOnsInfoMessage }), _jsx("hr", {}), _jsx(OrderProfileSearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, traderProfiles: marketPlaceVendorDataState.traderProfileProviders, totalCount: marketPlaceVendorDataState.totalTraderProfileItems, seeAll: true })] })), marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.TERMINAL_LICENSE && (_jsx(SearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, terminalResults: marketPlaceVendorDataState.providers, sectionTitle: VendorDataProviderType.TERMINAL_LICENSE, totalCount: marketPlaceVendorDataState.totalItems, seeAll: false })), marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.ADD_ONS && (_jsx(SearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, terminalResults: marketPlaceVendorDataState.providers, sectionTitle: VendorDataProviderType.ADD_ONS, totalCount: marketPlaceVendorDataState.totalItems, seeAll: false, tooltip: addOnsInfoMessage })), marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.ORDER_PROFILE && (_jsx(OrderProfileSearchResultsRenderer, { vendorDataState: marketPlaceVendorDataState, traderProfiles: marketPlaceVendorDataState.traderProfileAllProviders, totalCount: marketPlaceVendorDataState.totalItems }))] }), (marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.TERMINAL_LICENSE || marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.ADD_ONS || marketPlaceVendorDataState.providerDisplayState === VendorDataProviderType.ORDER_PROFILE) && (_jsx(PaginationControls, { totalItems: marketPlaceVendorDataState.totalItems, itemsPerPage: marketPlaceVendorDataState.itemsPerPage, page: marketPlaceVendorDataState.page, onPageChange: handlePageChange, onItemsPerPageChange: handleItemsPerPageChange }))] })) })); }); export const LegendMarketplaceVendorData = withLegendMarketplaceVendorDataStore(observer(() => { const marketPlaceVendorDataStore = useLegendMarketPlaceVendorDataStore(); const marketplaceStore = useLegendMarketplaceBaseStore(); const cartStore = marketplaceStore.cartStore; const handleSearch = useCallback((query) => { marketPlaceVendorDataStore.setSearchTerm(query ?? ''); flowResult(marketPlaceVendorDataStore.populateProviders()).catch(marketPlaceVendorDataStore.applicationStore.alertUnhandledError); }, [marketPlaceVendorDataStore]); const handleSearchChange = useCallback((query) => { if (query === '') { marketPlaceVendorDataStore.setSearchTerm(''); flowResult(marketPlaceVendorDataStore.populateProviders()).catch(marketPlaceVendorDataStore.applicationStore.alertUnhandledError); } }, [marketPlaceVendorDataStore]); useEffect(() => { marketPlaceVendorDataStore.init(); }, [marketPlaceVendorDataStore]); return (_jsxs(LegendMarketplacePage, { className: "legend-marketplace-vendor-data", children: [_jsx("div", { className: "legend-marketplace-banner", children: _jsx("div", { className: "legend-marketplace-banner__search-bar", children: _jsx(LegendMarketplaceSearchBar, { onSearch: handleSearch, onChange: handleSearchChange, enableAutosuggest: false }) }) }), _jsxs("div", { className: "legend-marketplace-body__content", children: [_jsxs("div", { className: "legend-marketplace-body__filter-bar", children: [_jsxs("div", { className: "legend-marketplace-user-search-container", children: [_jsx("span", { className: "legend-marketplace-user-search-container__label", children: "Target User:" }), _jsx(UserSearchInput, { className: "legend-marketplace__user-input", userValue: marketPlaceVendorDataStore.selectedUser, setUserValue: (_user) => { if (!_user.id) { marketPlaceVendorDataStore.resetSelectedUser(); flowResult(cartStore.setTargetUser(undefined)).catch(marketplaceStore.applicationStore.alertUnhandledError); } else { marketPlaceVendorDataStore.setSelectedUser(_user); flowResult(cartStore.setTargetUser(_user.id)).catch(marketplaceStore.applicationStore.alertUnhandledError); } }, userSearchService: marketplaceStore.userSearchService, label: "Search user or kerberos", required: true, variant: "outlined", renderOption: (optionProps, option) => (_createElement("li", { ...optionProps, key: option.id }, _jsx(UserRenderer, { userId: option.id, applicationStore: marketplaceStore.applicationStore, userSearchService: marketplaceStore.userSearchService, disableOnClick: true }))) })] }), _jsx("div", { className: "legend-marketplace-body__tab", children: _jsx(RefinedVendorRadioSelector, { vendorDataState: marketPlaceVendorDataStore }) }), _jsxs("div", { className: "legend-marketplace-body__action-buttons", children: [marketplaceStore.applicationStore.config.options .generalInquiriesUrl && (_jsx(Button, { variant: "outlined", className: "legend-marketplace-body__action-button", onClick: () => { const url = marketplaceStore.applicationStore.config.options .generalInquiriesUrl; if (url) { marketplaceStore.applicationStore.navigationService.navigator.visitAddress(url); } }, children: "General Inquiries" })), marketplaceStore.applicationStore.config.options .requestInternalAppUrl && (_jsx(Button, { variant: "outlined", className: "legend-marketplace-body__action-button", onClick: () => { const url = marketplaceStore.applicationStore.config.options .requestInternalAppUrl; if (url) { marketplaceStore.applicationStore.navigationService.navigator.visitAddress(url); } }, children: "Request Internal Application" }))] })] }), _jsx(VendorDataMainContent, { marketPlaceVendorDataState: marketPlaceVendorDataStore })] })] })); })); export const LegendMarketplaceVendorDetails = withLegendMarketplaceVendorDataStore(observer(() => { const { vendorName } = useParams(); const vendorDatasets = ['Dataset 1', 'Dataset 2', 'Dataset 3']; return (_jsx(LegendMarketplacePage, { className: "legend-marketplace-vendor-data", children: _jsxs("div", { className: "legend-marketplace-vendor-data__content", children: [_jsx(Typography, { variant: "h3", fontWeight: "bold", children: vendorName }), _jsx(List, { sx: { listStyleType: 'disc', paddingLeft: '16px' }, children: vendorDatasets.map((dataset) => (_jsx(ListItem, { sx: { display: 'list-item', padding: 'unset' }, children: dataset }, dataset))) })] }) })); })); //# sourceMappingURL=LegendMarketplaceTerminalsAddons.js.map