/** * 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 { WorkspaceSetup } from './workspace-setup/WorkspaceSetup.js'; import { Editor } from './editor/Editor.js'; import { ProjectReviewer } from './project-reviewer/ProjectReviewer.js'; import { ProjectViewer } from './project-view/ProjectViewer.js'; import { observer } from 'mobx-react-lite'; import { clsx, CubesLoadingIndicator, CubesLoadingIndicatorIcon, GhostIcon, MarkdownTextViewer, } from '@finos/legend-art'; import { LEGEND_STUDIO_ROUTE_PATTERN, LEGEND_STUDIO_SDLC_BYPASSED_ROUTE_PATTERN, } from '../__lib__/LegendStudioNavigation.js'; import { flowResult } from 'mobx'; import { LegendStudioFrameworkProvider, useLegendStudioApplicationStore, useLegendStudioBaseStore, } from './LegendStudioFrameworkProvider.js'; import { useApplicationStore, LegendTokenSync, ExtensionPageBoundary, LegendApplicationTelemetryHelper, } from '@finos/legend-application'; import { BrowserEnvironmentProvider, generateExtensionUrlPattern, Route, Routes, } from '@finos/legend-application/browser'; import { LEGEND_STUDIO_DOCUMENTATION_KEY } from '../__lib__/LegendStudioDocumentation.js'; import { LazyTextEditor } from './lazy-text-editor/LazyTextEditor.js'; import { PureCompatibilityTestManager } from './pct/PureCompatibilityTest.js'; import { ShowcaseViewer } from './showcase/ShowcaseViewer.js'; import { AuthProvider, withAuthenticationRequired, type AuthProviderProps, } from 'react-oidc-context'; import type { User } from 'oidc-client-ts'; const NotFoundPage = observer(() => { const applicationStore = useApplicationStore(); const currentPath = applicationStore.navigationService.navigator.getCurrentLocation(); useEffect(() => { LegendApplicationTelemetryHelper.logEvent_RouteNotFound( applicationStore.telemetryService, { path: currentPath }, ); }, [applicationStore, currentPath]); const documentation = applicationStore.documentationService.getDocEntry( LEGEND_STUDIO_DOCUMENTATION_KEY.NOT_FOUND_HELP, ); return (
404. Not Found
The requested URL {applicationStore.navigationService.navigator.generateAddress( currentPath, )} was not found in the application
{documentation?.markdownText && (
)}
); }); export const LegendStudioWebApplicationRouter = 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 (
{baseStore.initState.hasCompleted && ( <> {baseStore.isSDLCAuthorized === undefined && ( <> } /> } /> } /> } /> } /> )} {baseStore.isSDLCAuthorized && ( <> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {extraApplicationPageEntries.flatMap((entry) => entry.addressPatterns .map(generateExtensionUrlPattern) .map((path) => ( {entry.renderer()} } /> )), )} } /> )} )}
); }); const LegendStudioWebProvider: React.FC<{ baseUrl: string; }> = ({ baseUrl }) => { return ( ); }; const AuthenticatedLegendStudioWebProvider = withAuthenticationRequired( LegendStudioWebProvider, { OnRedirecting: () => ( ), signinRedirectArgs: { state: `${window.location.pathname}${window.location.search}`, }, }, ); export const LegendStudioWebApplication = observer( (props: { baseUrl: string }) => { const { baseUrl } = props; const applicationStore = useLegendStudioApplicationStore(); const oidcConfig = applicationStore.config.options.ingestDeploymentConfig?.deployment .oidcConfig; const enableOauthFlow = applicationStore.config.options.enableOauthFlow; if (oidcConfig) { const onSigninCallback = (_user: User | undefined) => { window.location.href = (_user?.state as string | undefined) ?? '/'; }; const mergedOIDCConfig: AuthProviderProps = { ...oidcConfig.authProviderProps, redirect_uri: `${window.location.origin}${oidcConfig.redirectPath}`, silent_redirect_uri: `${window.location.origin}${oidcConfig.silentRedirectPath}`, onSigninCallback, }; if (enableOauthFlow) { return ( ); } return ( ); } return ; }, );