@finos/legend-application-marketplace
Version:
Legend Marketplace application core
78 lines • 4.79 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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 { clsx, ControlledDropdownMenu, MenuContent, MenuContentItem, MenuIcon, } from '@finos/legend-art';
import { AppBar, Box, Button, Container, Toolbar } from '@mui/material';
import { observer } from 'mobx-react-lite';
import { useState } from 'react';
import { LEGEND_MARKETPLACE_TEST_ID } from '../../__lib__/LegendMarketplaceTesting.js';
import { LegendMarketplaceAppInfo } from './LegendMarketplaceAppInfo.js';
import { useApplicationStore } from '@finos/legend-application';
import { LEGEND_MARKETPLACE_ROUTE_PATTERN } from '../../__lib__/LegendMarketplaceNavigation.js';
import { LegendMarketplaceIconToolbar } from './LegendMarketplaceIconToolbar.js';
import { matchPath } from '@finos/legend-application/browser';
const LegendMarketplaceHeaderMenu = observer(() => {
// about modal
const [openAppInfo, setOpenAppInfo] = useState(false);
const showAppInfo = () => setOpenAppInfo(true);
const hideAppInfo = () => setOpenAppInfo(false);
return (_jsxs(_Fragment, { children: [_jsx(ControlledDropdownMenu, { className: "legend-marketplace-header__menu", menuProps: {
anchorOrigin: { vertical: 'top', horizontal: 'right' },
transformOrigin: { vertical: 'top', horizontal: 'left' },
elevation: 7,
}, content: _jsx(MenuContent, { children: _jsx(MenuContentItem, { onClick: showAppInfo, children: "About" }) }), children: _jsx(MenuIcon, {}) }), _jsx(LegendMarketplaceAppInfo, { open: openAppInfo, closeModal: hideAppInfo })] }));
});
const LegendMarketPlaceHeaderTabs = observer((props) => {
const { pages } = props;
const applicationStore = useApplicationStore();
const navigateToPage = (route) => {
applicationStore.navigationService.navigator.goToLocation(route);
};
return (_jsx(Box, { className: "legend-marketplace-header__tabs", children: pages.map((page) => {
const isSelectedTab = matchPath(page.urlRoute, applicationStore.navigationService.navigator.getCurrentLocation()) !== null;
return (_jsx(Button, { className: clsx('legend-marketplace-header__tab', {
'legend-marketplace-header__tab--selected': isSelectedTab,
}), onClick: () => navigateToPage(page.urlRoute), children: page.title }, page.title));
}) }));
});
const LegendMarketplaceBaseHeader = observer((props) => {
const { headerName, homeUrl, pages, showIcons } = props;
const applicationStore = useApplicationStore();
const navigateToHome = () => {
applicationStore.navigationService.navigator.goToLocation(homeUrl);
};
return (_jsx(AppBar, { position: "sticky", className: "legend-marketplace-header", "data-testid": LEGEND_MARKETPLACE_TEST_ID.HEADER, children: _jsx(Container, { maxWidth: "xxl", children: _jsxs(Toolbar, { disableGutters: true, children: [_jsx(LegendMarketplaceHeaderMenu, {}), _jsx("div", { className: "legend-marketplace-header__name", onClick: () => navigateToHome(), children: headerName }), _jsx(LegendMarketPlaceHeaderTabs, { pages: pages }), showIcons && _jsx(LegendMarketplaceIconToolbar, {})] }) }) }));
});
export const LegendMarketplaceHeader = observer((props) => {
const { enableMarketplacePages } = props;
return (_jsx(LegendMarketplaceBaseHeader, { headerName: "Legend Marketplace", homeUrl: LEGEND_MARKETPLACE_ROUTE_PATTERN.DEFAULT, pages: enableMarketplacePages
? [
{
title: 'Vendor Data',
urlRoute: LEGEND_MARKETPLACE_ROUTE_PATTERN.VENDOR_DATA,
},
]
: [], showIcons: enableMarketplacePages }));
});
export const MarketplaceLakehouseHeader = observer(() => {
return (_jsx(LegendMarketplaceBaseHeader, { headerName: "Legend Marketplace", homeUrl: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE, pages: [
{
title: 'Entitlements',
urlRoute: LEGEND_MARKETPLACE_ROUTE_PATTERN.LAKEHOUSE_ENTITLEMENTS,
},
], showIcons: false }));
});
//# sourceMappingURL=LegendMarketplaceHeader.js.map