@finos/legend-application-marketplace
Version:
Legend Marketplace application core
100 lines • 9.49 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 { useEffect } from 'react';
import { observer } from 'mobx-react-lite';
import { CubesLoadingIndicator, CubesLoadingIndicatorIcon, GhostIcon, } from '@finos/legend-art';
import { flowResult } from 'mobx';
import { useApplicationStore } from '@finos/legend-application';
import { BrowserEnvironmentProvider, Outlet, Route, Routes, } from '@finos/legend-application/browser';
import { LegendMarketplaceFrameworkProvider, useLegendMarketplaceApplicationStore, useLegendMarketplaceBaseStore, } from './LegendMarketplaceFrameworkProvider.js';
import { isLakehouseRoute, LEGEND_MARKETPLACE_ROUTE_PATTERN, } from '../__lib__/LegendMarketplaceNavigation.js';
import { MarketplaceLakehouseHome } from '../pages/Lakehouse/MarketplaceLakehouseHome.js';
import { LegendMarketplaceHome } from '../pages/Home/LegendMarketplaceHome.js';
import { LegendMarketplaceSearchResults } from '../pages/SearchResults/LegendMarketplaceSearchResults.js';
import { AuthProvider, withAuthenticationRequired, } from 'react-oidc-context';
import { LakehouseDataProduct } from '../pages/Lakehouse/dataProduct/LakehouseDataProduct.js';
import { LegendMarketplaceVendorData } from '../pages/VendorData/LegendMarketplaceVendorData.js';
import { LakehouseEntitlements } from '../pages/Lakehouse/entitlements/LakehouseEntitlements.js';
import { LakehouseAdmin } from '../pages/Lakehouse/admin/LakehouseAdmin.js';
import { LegendMarketplaceHeader, MarketplaceLakehouseHeader, } from '../components/Header/LegendMarketplaceHeader.js';
import { LegendMarketplacePage } from '../pages/LegendMarketplacePage.js';
import { LegendMarketplaceVendorDetails } from '../pages/VendorDetails/LegendMarketplaceVendorDetails.js';
import { LegendMarketplaceSubscriptions } from '../pages/Profile/LegendMarketplaceSubscriptions.js';
import { LegendMarketplaceOrders } from '../pages/Profile/LegendMarketplaceOrders.js';
import { LakehouseSandboxDataProduct } from '../pages/Lakehouse/dataProduct/LakehouseSandboxDataProduct.js';
import { LegendMarketplaceComingSoon } from '../pages/Home/LegendMarketplaceComingSoon.js';
import { MarketplaceLakehouseOAuthCallback } from '../pages/Lakehouse/MarketplaceLakehouseOAuthCallback.js';
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"] })] })] }) }));
});
export const LegendMarketplaceWebApplicationRouter = observer(() => {
const baseStore = useLegendMarketplaceBaseStore();
const applicationStore = useLegendMarketplaceApplicationStore();
const enableMarketplacePages = applicationStore.config.options.enableMarketplacePages;
useEffect(() => {
flowResult(baseStore.initialize()).catch(applicationStore.alertUnhandledError);
}, [applicationStore, baseStore]);
const ProtectedLakehouseMarketplace = withAuthenticationRequired(MarketplaceLakehouseHome, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
const ProtectedLakehouseDataProduct = withAuthenticationRequired(LakehouseDataProduct, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
const ProtectedLakehouseSandboxDataProduct = withAuthenticationRequired(LakehouseSandboxDataProduct, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
const ProtectedLakehouseEntitlements = withAuthenticationRequired(LakehouseEntitlements, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
const ProtectedLakehouseAdmin = withAuthenticationRequired(LakehouseAdmin, {
OnRedirecting: () => (_jsx(CubesLoadingIndicator, { isLoading: true, children: _jsx(CubesLoadingIndicatorIcon, {}) })),
signinRedirectArgs: {
state: `${window.location.pathname}${window.location.search}`,
},
});
return (_jsx("div", { className: "app", children: baseStore.initState.hasCompleted && (_jsx(Routes, { children: _jsxs(Route, { element: _jsxs(_Fragment, { children: [isLakehouseRoute(baseStore.applicationStore.navigationService.navigator.getCurrentLocation()) ? (_jsx(MarketplaceLakehouseHeader, {})) : (_jsx(LegendMarketplaceHeader, { enableMarketplacePages: enableMarketplacePages })), _jsx(Outlet, {})] }), children: [enableMarketplacePages ? (_jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEFAULT, element: _jsx(LegendMarketplaceHome, {}) })) : (_jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEFAULT, element: _jsx(LegendMarketplaceComingSoon, {}) })), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.OAUTH_CALLBACK, element: _jsx(MarketplaceLakehouseOAuthCallback, {}) }), enableMarketplacePages && (_jsxs(_Fragment, { children: [_jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.SEARCH_RESULTS, element: _jsx(LegendMarketplaceSearchResults, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.VENDOR_DATA, element: _jsx(LegendMarketplaceVendorData, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.VENDOR_DETAILS, element: _jsx(LegendMarketplaceVendorDetails, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.SUBSCRIPTIONS, element: _jsx(LegendMarketplaceSubscriptions, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.ORDERS, element: _jsx(LegendMarketplaceOrders, {}) })] })), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_PRODUCT, element: _jsx(ProtectedLakehouseDataProduct, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_SANDBOX_PRODUCT, element: _jsx(ProtectedLakehouseSandboxDataProduct, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS_CONTRACTS, element: _jsx(ProtectedLakehouseEntitlements, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS, element: _jsx(ProtectedLakehouseEntitlements, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE, element: _jsx(ProtectedLakehouseMarketplace, {}) }), _jsx(Route, { path: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ADMIN, element: _jsx(ProtectedLakehouseAdmin, {}) }), _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(BrowserEnvironmentProvider, { baseUrl: baseUrl, children: _jsx(LegendMarketplaceFrameworkProvider, { children: _jsx(LegendMarketplaceWebApplicationRouter, {}) }) }) }));
});
//# sourceMappingURL=LegendMarketplaceWebApplication.js.map