/** * 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 { ArrowCircleRightIcon, clsx, ExclamationCircleIcon, getSelectorInputOptionEmbeddedButtonProps, } from '@finos/legend-art'; import type { Project } from '@finos/legend-server-sdlc'; import type { LegendStudioApplicationStore } from '../../stores/LegendStudioBaseStore.js'; import { generateViewProjectRoute } from '../../__lib__/LegendStudioNavigation.js'; import type { ProjectConfigurationStatus } from '../../stores/workspace-setup/ProjectConfigurationStatus.js'; export interface ProjectOption { label: string; value: Project; } export const buildProjectOption = (project: Project): ProjectOption => ({ label: project.name, value: project, }); export const getProjectOptionLabelFormatter = ( applicationStore: LegendStudioApplicationStore, projectConfigurationStatus?: ProjectConfigurationStatus | undefined, ): ((option: ProjectOption) => React.ReactNode) => function ProjectOptionLabel(option: ProjectOption): React.ReactNode { const viewProject = (): void => applicationStore.navigationService.navigator.visitAddress( applicationStore.navigationService.navigator.generateAddress( generateViewProjectRoute(option.value.projectId), ), ); const configure = (): void => { if (projectConfigurationStatus?.reviewUrl) { applicationStore.navigationService.navigator.visitAddress( projectConfigurationStatus.reviewUrl, ); } else { applicationStore.notificationService.notifyWarning( `Can't find project configuration review: opening the project web page...`, ); applicationStore.navigationService.navigator.visitAddress( option.value.webUrl, ); } }; return (
{option.label}
{projectConfigurationStatus && option.value.projectId === projectConfigurationStatus.projectId && ( <> {projectConfigurationStatus.isConfigured && ( )} {!projectConfigurationStatus.isConfigured && ( )} )}
); };