@finos/legend-application-marketplace
Version:
Legend Marketplace application core
138 lines • 13.3 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
* Copyright (c) 2020-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 React, { Suspense, useEffect } from 'react';
import { observer } from 'mobx-react-lite';
import { CubesLoadingIndicator, CubesLoadingIndicatorIcon, GhostIcon, } from '@finos/legend-art';
import { useApplicationStore, LegendTokenSync, } from '@finos/legend-application';
import { BrowserEnvironmentProvider, Outlet, Route, Routes, Navigate, } from '@finos/legend-application/browser';
import { LegendMarketplaceFrameworkProvider, useLegendMarketplaceApplicationStore, useLegendMarketplaceBaseStore, } from './providers/LegendMarketplaceFrameworkProvider.js';
import { LEGEND_MARKETPLACE_ROUTE_PATTERN } from '../__lib__/LegendMarketplaceNavigation.js';
import { AuthProvider, withAuthenticationRequired, } from 'react-oidc-context';
import { MarketplaceLakehouseHeader } from '../components/Header/LegendMarketplaceHeader.js';
import { LegendMarketplacePage } from '../pages/LegendMarketplacePage.js';
import { CartToast } from '../components/Toast/CartToast.js';
import { FeedbackWidget } from '../components/Feedback/FeedbackWidget.js';
import { flowResult } from 'mobx';
// Lazy load page components for code splitting
const MarketplaceLakehouseHome = React.lazy(() => import('../pages/Lakehouse/MarketplaceLakehouseHome.js').then((module) => ({
default: module.MarketplaceLakehouseHome,
})));
const LakehouseDataProduct = React.lazy(() => import('../pages/Lakehouse/dataProduct/LakehouseDataProduct.js').then((module) => ({
default: module.LakehouseDataProduct,
})));
const TerminalProduct = React.lazy(() => import('../pages/Lakehouse/dataProduct/TerminalProduct.js').then((module) => ({
default: module.TerminalProduct,
})));
const LegendMarketplaceDataAPIs = React.lazy(() => import('../pages/DataAPIs/LegendMarketplaceDataAPIs.js').then((module) => ({
default: module.LegendMarketplaceDataAPIs,
})));
const LakehouseEntitlements = React.lazy(() => import('../pages/Lakehouse/entitlements/LakehouseEntitlements.js').then((module) => ({
default: module.LakehouseEntitlements,
})));
const LakehouseDataContractTask = React.lazy(() => import('../pages/Lakehouse/entitlements/LakehouseDataContract.js').then((module) => ({
default: module.LakehouseDataContractTask,
})));
const WorkflowDataAccessRequestTask = React.lazy(() => import('../pages/Lakehouse/entitlements/WorkflowDataAccessRequest.js').then((module) => ({
default: module.WorkflowDataAccessRequestTask,
})));
const PermitDataAccessRequestTask = React.lazy(() => import('../pages/Lakehouse/entitlements/PermitDataAccessRequest.js').then((module) => ({
default: module.PermitDataAccessRequestTask,
})));
const LakehouseAdmin = React.lazy(() => import('../pages/Lakehouse/admin/LakehouseAdmin.js').then((module) => ({
default: module.LakehouseAdmin,
})));
const MarketplaceLakehouseOAuthCallback = React.lazy(() => import('../pages/Lakehouse/MarketplaceLakehouseOAuthCallback.js').then((module) => ({
default: module.MarketplaceLakehouseOAuthCallback,
})));
const LakehouseSDLCDataProduct = React.lazy(() => import('../pages/Lakehouse/dataProduct/LakehouseSDLCDataProduct.js').then((module) => ({
default: module.LakehouseSDLCDataProduct,
})));
const LegendMarketplaceSearchResults = React.lazy(() => import('../pages/Lakehouse/searchResults/LegendMarketplaceSearchResults.js').then((module) => ({
default: module.LegendMarketplaceSearchResults,
})));
const LegendMarketplaceFieldSearchResults = React.lazy(() => import('../pages/Lakehouse/searchResults/LegendMarketplaceFieldSearchResults.js').then((module) => ({
default: module.LegendMarketplaceFieldSearchResults,
})));
const LegacyDataProduct = React.lazy(() => import('../pages/Lakehouse/dataProduct/LegacyDataProduct.js').then((module) => ({
default: module.LegacyDataProduct,
})));
const LegendMarketplaceAgents = React.lazy(() => import('../pages/Agents/LegendMarketplaceAgents.js').then((module) => ({
default: module.LegendMarketplaceAgents,
})));
const LegendMarketplaceInventory = React.lazy(() => import('../pages/Inventory/LegendMarketplaceInventory.js').then((module) => ({
default: module.LegendMarketplaceInventory,
})));
const LegendMarketplaceVendorData = React.lazy(() => import('../pages/TerminalsAddons/LegendMarketplaceTerminalsAddons.js').then((module) => ({
default: module.LegendMarketplaceVendorData,
})));
const LegendMarketplaceSubscriptions = React.lazy(() => import('../pages/Profile/LegendMarketplaceSubscriptions.js').then((module) => ({
default: module.LegendMarketplaceSubscriptions,
})));
const LegendMarketplaceYourOrders = React.lazy(() => import('../pages/Profile/LegendMarketplaceYourOrders.js').then((module) => ({
default: module.LegendMarketplaceYourOrders,
})));
const NotFoundPage = observer(() => {
const applicationStore = useApplicationStore();
const currentPath = applicationStore.navigationService.navigator.getCurrentLocation();
return (_jsx(LegendMarketplacePage, { className: "legend-marketplace__not-found", children: _jsxs("div", { className: "not-found-screen not-found-screen--no-documentation", children: [_jsxs("div", { className: "not-found-screen__icon", children: [_jsx("div", { className: "not-found-screen__icon__ghost", children: _jsx(GhostIcon, {}) }), _jsx("div", { className: "not-found-screen__icon__shadow", children: _jsx("svg", { viewBox: "0 0 600 400", children: _jsx("g", { transform: "translate(300 200)", children: _jsx("ellipse", { className: "not-found-screen__icon__shadow__inner", rx: "320", ry: "80" }) }) }) })] }), _jsxs("div", { className: "not-found-screen__text-content", children: [_jsx("div", { className: "not-found-screen__text-content__title", children: "404. Not Found" }), _jsxs("div", { className: "not-found-screen__text-content__detail", children: ["The requested URL", _jsx("span", { className: "not-found-screen__text-content__detail__url", children: applicationStore.navigationService.navigator.generateAddress(currentPath) }), "was not found in the application"] })] })] }) }));
});
const useProtectedPage = (PageComponent) => withAuthenticationRequired(PageComponent, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}${window.location.hash}`,
},
});
export const LegendMarketplaceWebApplicationRouter = observer(() => {
const marketplaceBaseStore = useLegendMarketplaceBaseStore();
const applicationStore = useLegendMarketplaceApplicationStore();
useEffect(() => {
if (marketplaceBaseStore.initState.isInInitialState) {
flowResult(marketplaceBaseStore.initialize()).catch(applicationStore.alertUnhandledError);
}
}, [applicationStore.alertUnhandledError, marketplaceBaseStore]);
const ProtectedYourOrders = withAuthenticationRequired(LegendMarketplaceYourOrders, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
// Loading fallback for lazy-loaded components
const LazyLoadingFallback = (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) }));
return (_jsx("div", { className: "app", children: marketplaceBaseStore.initState.hasCompleted && (_jsx(Routes, { children: _jsxs(Route, { element: _jsxs(_Fragment, { children: [_jsx(MarketplaceLakehouseHeader, {}), _jsx(CartToast, {}), _jsx(FeedbackWidget, {}), _jsx(Suspense, { fallback: LazyLoadingFallback, children: _jsx(Outlet, {}) })] }), children: [_jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.OAUTH_CALLBACK, element: _jsx(MarketplaceLakehouseOAuthCallback, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DATA_PRODUCT_SEARCH_RESULTS, element: React.createElement(useProtectedPage(LegendMarketplaceSearchResults)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.FIELD_SEARCH_RESULTS, element: React.createElement(useProtectedPage(LegendMarketplaceFieldSearchResults)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DATA_APIS, element: _jsx(LegendMarketplaceDataAPIs, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.AGENTS, element: _jsx(LegendMarketplaceAgents, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.INVENTORY, element: _jsx(LegendMarketplaceInventory, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.TERMINAL_ADD_ONS, element: _jsx(LegendMarketplaceVendorData, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DATA_PRODUCT, element: React.createElement(useProtectedPage(LakehouseDataProduct)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.TERMINAL_PRODUCT, element: React.createElement(useProtectedPage(TerminalProduct)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.SDLC_DATA_PRODUCT, element: _jsx(LakehouseSDLCDataProduct, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LEGACY_DATA_PRODUCT, element: _jsx(LegacyDataProduct, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS_WORKFLOW_DATA_ACCESS_REQUEST, element: React.createElement(useProtectedPage(WorkflowDataAccessRequestTask)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS_PERMIT_DATA_ACCESS_REQUEST, element: React.createElement(useProtectedPage(PermitDataAccessRequestTask)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS_CONTRACT_TASK, element: React.createElement(useProtectedPage(LakehouseDataContractTask)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS, element: React.createElement(useProtectedPage(LakehouseEntitlements)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.HOME_PAGE, element: React.createElement(useProtectedPage(MarketplaceLakehouseHome)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ADMIN, element: React.createElement(useProtectedPage(LakehouseAdmin)) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEPRECATED_LAKEHOUSE, element: _jsx(Navigate, { to: LEGEND_MARKETPLACE_ROUTE_PATTERN.HOME_PAGE, replace: true }) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEPRECATED_LAKEHOUSE_SEARCH_RESULTS, element: _jsx(Navigate, { to: LEGEND_MARKETPLACE_ROUTE_PATTERN.DATA_PRODUCT_SEARCH_RESULTS, replace: true }) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEPRECATED_LAKEHOUSE_PRODUCT, element: _jsx(Navigate, { to: LEGEND_MARKETPLACE_ROUTE_PATTERN.DATA_PRODUCT, replace: true }) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEPRECATED_LAKEHOUSE_SDLC_PRODUCT, element: _jsx(Navigate, { to: LEGEND_MARKETPLACE_ROUTE_PATTERN.SDLC_DATA_PRODUCT, replace: true }) }), applicationStore.pluginManager
.getApplicationPlugins()
.flatMap((plugin) => plugin.getAdditionalMarketplacePageConfigs?.() ?? [])
.filter((pageConfig) => !(pageConfig.path in LEGEND_MARKETPLACE_ROUTE_PATTERN))
.map((pageConfig) => (_jsx(Route, { path: pageConfig.path, element: React.createElement(pageConfig.protected
? useProtectedPage(pageConfig.component)
: pageConfig.component) }, pageConfig.path))), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.ORDERS, element: _jsx(ProtectedYourOrders, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.SUBSCRIPTIONS, element: _jsx(LegendMarketplaceSubscriptions, {}) }), _jsx(Route, { path: "*", element: _jsx(NotFoundPage, {}) })] }) })) }));
});
export const LegendMarketplaceWebApplication = observer((props) => {
const { baseUrl, oidcConfig } = props;
const onSigninCallback = (_user) => {
window.location.href = _user?.state ?? '/';
};
const mergedOIDCConfig = oidcConfig
? {
...oidcConfig.authProviderProps,
redirect_uri: `${window.location.origin}${oidcConfig.redirectPath}`,
silent_redirect_uri: `${window.location.origin}${oidcConfig.silentRedirectPath}`,
onSigninCallback,
}
: undefined;
return (_jsx(AuthProvider, { ...mergedOIDCConfig, children: _jsx(LegendTokenSync, { children: _jsx(BrowserEnvironmentProvider, { baseUrl: baseUrl, children: _jsx(LegendMarketplaceFrameworkProvider, { children: _jsx(LegendMarketplaceWebApplicationRouter, {}) }) }) }) }));
});
//# sourceMappingURL=LegendMarketplaceWebApplication.js.map