/** * 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 { useProjectReviewerStore, withProjectReviewerStore, } from './ProjectReviewStoreProvider.js'; import { ProjectReviewerSideBar } from './ProjectReviewSideBar.js'; import { ProjectReviewerPanel } from './ProjectReviewerPanel.js'; import { ACTIVITY_MODE } from '../../stores/editor/EditorConfig.js'; import { type ResizablePanelHandlerProps, getCollapsiblePanelGroupProps, clsx, PanelLoadingIndicator, ResizablePanel, ResizablePanelGroup, ResizablePanelSplitter, CheckListIcon, CodeBranchIcon, UserIcon, AssistantIcon, } from '@finos/legend-art'; import { type ProjectReviewerPathParams, generateSetupRoute, } from '../../__lib__/LegendStudioNavigation.js'; import { useEditorStore, withEditorStore, } from '../editor/EditorStoreProvider.js'; import { ColorThemeToggle } from '../editor/ActivityBar.js'; import { useApplicationStore } from '@finos/legend-application'; import { useParams } from '@finos/legend-application/browser'; import { guaranteeNonNullable } from '@finos/legend-shared'; const ProjectReviewerStatusBar = observer(() => { const reviewStore = useProjectReviewerStore(); const editorStore = useEditorStore(); const applicationStore = useApplicationStore(); const currentUserId = editorStore.sdlcServerClient.currentUser?.userId ?? '(unknown)'; const currentProject = reviewStore.currentProject ? reviewStore.currentProject.name : reviewStore.projectId; const review = reviewStore.review; const reviewStatus = reviewStore.approveState.isInProgress ? 'approving review...' : reviewStore.commitState.isInProgress ? 'committing review...' : reviewStore.closeState.isInProgress ? 'closing review...' : reviewStore.reOpenState.isInProgress ? 'reopening review...' : reviewStore.buildReviewReportState.isInProgress ? 'loading changes...' : undefined; const toggleAssistant = (): void => applicationStore.assistantService.toggleAssistant(); return (
/
{review.title}
{reviewStatus}
{currentUserId}
); }); const ProjectReviewerExplorer = observer(() => { const editorStore = useEditorStore(); // layout const resizeSideBar = (handleProps: ResizablePanelHandlerProps): void => editorStore.sideBarDisplayState.setSize( (handleProps.domElement as HTMLDivElement).getBoundingClientRect().width, ); const sideBarCollapsiblePanelGroupProps = getCollapsiblePanelGroupProps( editorStore.sideBarDisplayState.size === 0, { onStopResize: resizeSideBar, size: editorStore.sideBarDisplayState.size, }, ); return ( ); }); export const ProjectReviewer = withEditorStore( withProjectReviewerStore( observer(() => { const params = useParams(); const projectId = guaranteeNonNullable(params.projectId); const reviewId = guaranteeNonNullable(params.reviewId); const reviewStore = useProjectReviewerStore(); const editorStore = useEditorStore(); const changeActivity = (activity: ACTIVITY_MODE): (() => void) => (): void => editorStore.setActiveActivity(activity); useEffect(() => { reviewStore.setProjectIdAndReviewId(projectId, reviewId); reviewStore.initialize(); }, [reviewStore, projectId, reviewId]); return (
{reviewStore.currentReview && ( <>
)}
); }), ), );