UNPKG

@finos/legend-studio

Version:
80 lines 6.91 kB
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 { Switch, Route } from 'react-router'; import { WorkspaceSetup } from './workspace-setup/WorkspaceSetup.js'; import { Editor } from './editor/Editor.js'; import { WorkspaceReview } from './workspace-review/WorkspaceReview.js'; import { ProjectViewer } from './project-viewer/ProjectViewer.js'; import { observer } from 'mobx-react-lite'; import { clsx, GhostIcon, MarkdownTextViewer, PanelLoadingIndicator, } from '@finos/legend-art'; import { LEGEND_STUDIO_ROUTE_PATTERN } from '../stores/LegendStudioRouter.js'; import { flowResult } from 'mobx'; import { SDLCServerClientProvider } from '@finos/legend-server-sdlc'; import { DepotServerClientProvider } from '@finos/legend-server-depot'; import { LegendStudioBaseStoreProvider, useLegendStudioApplicationStore, useLegendStudioBaseStore, } from './LegendStudioBaseStoreProvider.js'; import { GraphManagerStateProvider } from '@finos/legend-graph'; import { generateExtensionUrlPattern, LegendApplicationComponentFrameworkProvider, useApplicationStore, VirtualAssistant, } from '@finos/legend-application'; import { LEGEND_STUDIO_DOCUMENTATION_KEY } from '../stores/LegendStudioDocumentation.js'; const LegendStudioNotFoundRouteScreen = observer(() => { const applicationStore = useApplicationStore(); const currentPath = applicationStore.navigator.getCurrentLocationPath(); const documentation = applicationStore.documentationService.getDocEntry(LEGEND_STUDIO_DOCUMENTATION_KEY.NOT_FOUND_HELP); return (_jsx("div", { className: "app__page", children: _jsxs("div", { className: clsx('not-found-screen', { 'not-found-screen--no-documentation': !documentation?.markdownText, }), 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.navigator.generateLocation(currentPath) }), "was not found in the application"] })] }), documentation?.markdownText && (_jsx("div", { className: "not-found-screen__documentation", children: _jsx(MarkdownTextViewer, { value: documentation.markdownText, className: "markdown-content--page" }) }))] }) })); }); export const LegendStudioApplicationRoot = observer(() => { const baseStore = useLegendStudioBaseStore(); const applicationStore = useLegendStudioApplicationStore(); const extraApplicationPageEntries = applicationStore.pluginManager .getApplicationPlugins() .flatMap((plugin) => plugin.getExtraApplicationPageEntries?.() ?? []); useEffect(() => { flowResult(baseStore.initialize()).catch(applicationStore.alertUnhandledError); }, [applicationStore, baseStore]); return (_jsxs("div", { className: "app", children: [!baseStore.isSDLCAuthorized && (_jsx("div", { className: "app__page", children: _jsx(PanelLoadingIndicator, { isLoading: true }) })), baseStore.isSDLCAuthorized && (_jsxs(_Fragment, { children: [_jsx(VirtualAssistant, {}), _jsxs(Switch, { children: [_jsx(Route, { exact: true, path: [ LEGEND_STUDIO_ROUTE_PATTERN.VIEW, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_GAV, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_GAV_ENTITY, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_ENTITY, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_REVISION, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_VERSION, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_REVISION_ENTITY, LEGEND_STUDIO_ROUTE_PATTERN.VIEW_BY_VERSION_ENTITY, ], component: ProjectViewer }), _jsx(Route, { exact: true, path: LEGEND_STUDIO_ROUTE_PATTERN.REVIEW, component: WorkspaceReview }), _jsx(Route, { exact: true, strict: true, path: [ LEGEND_STUDIO_ROUTE_PATTERN.EDIT_GROUP, LEGEND_STUDIO_ROUTE_PATTERN.EDIT, ], component: Editor }), _jsx(Route, { exact: true, path: [ // root path will lead to setup page (home page) '/', LEGEND_STUDIO_ROUTE_PATTERN.SETUP, LEGEND_STUDIO_ROUTE_PATTERN.SETUP_GROUP, ], component: WorkspaceSetup }), extraApplicationPageEntries.map((entry) => (_jsx(Route, { exact: true, path: entry.urlPatterns.map(generateExtensionUrlPattern), component: entry.renderer }, entry.key))), _jsx(Route, { children: _jsx(LegendStudioNotFoundRouteScreen, {}) })] })] }))] })); }); export const LegendStudioApplication = observer((props) => { const { config, pluginManager } = props; const applicationStore = useApplicationStore(); return (_jsx(SDLCServerClientProvider, { config: { env: config.env, serverUrl: config.sdlcServerUrl, baseHeaders: config.SDLCServerBaseHeaders, }, children: _jsx(DepotServerClientProvider, { config: { serverUrl: config.depotServerUrl, }, children: _jsx(GraphManagerStateProvider, { pluginManager: pluginManager, log: applicationStore.log, children: _jsx(LegendStudioBaseStoreProvider, { pluginManager: pluginManager, children: _jsx(LegendApplicationComponentFrameworkProvider, { children: _jsx(LegendStudioApplicationRoot, {}) }) }) }) }) })); }); //# sourceMappingURL=LegendStudioApplication.js.map