@finos/legend-application-studio
Version:
Legend Studio application core
77 lines • 7.32 kB
JavaScript
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 { 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 { getCollapsiblePanelGroupProps, clsx, PanelLoadingIndicator, ResizablePanel, ResizablePanelGroup, ResizablePanelSplitter, CheckListIcon, CodeBranchIcon, UserIcon, AssistantIcon, } from '@finos/legend-art';
import { generateSetupRoute, } from '../../__lib__/LegendStudioNavigation.js';
import { useEditorStore, withEditorStore, } from '../editor/EditorStoreProvider.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 = () => applicationStore.assistantService.toggleAssistant();
return (_jsxs("div", { className: "workspace-review__status-bar workspace-review__status-bar", children: [_jsx("div", { className: "workspace-review__status-bar__left", children: _jsxs("div", { className: "workspace-review__status-bar__workspace", children: [_jsx("div", { className: "workspace-review__status-bar__workspace__icon", children: _jsx(CodeBranchIcon, {}) }), _jsx("button", { className: "workspace-review__status-bar__workspace__project", title: "Go back to workspace setup using the specified project", tabIndex: -1, onClick: () => applicationStore.navigationService.navigator.visitAddress(applicationStore.navigationService.navigator.generateAddress(generateSetupRoute(reviewStore.projectId, undefined))), children: currentProject }), "/", _jsx("button", { className: "workspace-review__status-bar__workspace__workspace", title: "Go back to workspace setup using the specified workspace", tabIndex: -1, onClick: () => applicationStore.navigationService.navigator.visitAddress(applicationStore.navigationService.navigator.generateAddress(generateSetupRoute(reviewStore.projectId, review.workspaceId, review.workspaceType))), children: review.workspaceId }), _jsx("div", { className: "workspace-review__status-bar__review", children: _jsx("a", { target: "_blank", rel: "noopener noreferrer", href: review.webURL, children: review.title }) })] }) }), _jsxs("div", { className: "workspace-review__status-bar__right", children: [_jsx("div", { className: "workspace-review__status-bar__status", children: reviewStatus }), _jsxs("div", { className: "workspace-review__status-bar__user", children: [_jsx("div", { className: "workspace-review__status-bar__user__icon", children: _jsx(UserIcon, {}) }), _jsx("div", { className: "review__status-bar__user__name", children: currentUserId })] }), _jsx("button", { className: clsx('editor__status-bar__action editor__status-bar__action__toggler', {
'editor__status-bar__action__toggler--active': !applicationStore.assistantService.isHidden,
}), onClick: toggleAssistant, tabIndex: -1, title: "Toggle assistant", children: _jsx(AssistantIcon, {}) })] })] }));
});
const ProjectReviewerExplorer = observer(() => {
const editorStore = useEditorStore();
// layout
const resizeSideBar = (handleProps) => editorStore.sideBarDisplayState.setSize(handleProps.domElement.getBoundingClientRect().width);
const sideBarCollapsiblePanelGroupProps = getCollapsiblePanelGroupProps(editorStore.sideBarDisplayState.size === 0, {
onStopResize: resizeSideBar,
size: editorStore.sideBarDisplayState.size,
});
return (_jsxs(ResizablePanelGroup, { orientation: "vertical", children: [_jsx(ResizablePanel, { ...sideBarCollapsiblePanelGroupProps.collapsiblePanel, direction: 1, children: _jsx(ProjectReviewerSideBar, {}) }), _jsx(ResizablePanelSplitter, {}), _jsx(ResizablePanel, { ...sideBarCollapsiblePanelGroupProps.remainingPanel, minSize: 300, children: _jsx(ProjectReviewerPanel, {}) })] }));
});
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) => () => editorStore.setActiveActivity(activity);
useEffect(() => {
reviewStore.setProjectIdAndReviewId(projectId, reviewId);
reviewStore.initialize();
}, [reviewStore, projectId, reviewId]);
return (_jsx("div", { className: "app__page", children: _jsxs("div", { className: "workspace-review", children: [_jsx(PanelLoadingIndicator, { isLoading: reviewStore.fetchCurrentReviewState.isInProgress }), reviewStore.currentReview && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "workspace-review__body", children: [_jsx("div", { className: "activity-bar", children: _jsx("div", { className: "activity-bar__items", children: _jsx("button", { className: "activity-bar__item activity-bar__item--active workspace-review__activity-bar__review-icon", tabIndex: -1, title: "Review", onClick: changeActivity(ACTIVITY_MODE.REVIEW), children: _jsx(CheckListIcon, {}) }, ACTIVITY_MODE.REVIEW) }) }), _jsx("div", { className: "workspace-review__content-container", children: _jsx("div", { className: "workspace-review__content", children: _jsx(ProjectReviewerExplorer, {}) }) })] }), _jsx(ProjectReviewerStatusBar, {})] }))] }) }));
})));
//# sourceMappingURL=ProjectReviewer.js.map