@finos/legend-studio
Version:
84 lines • 7.49 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 { useWorkspaceReviewStore, withWorkspaceReviewStore, } from './WorkspaceReviewStoreProvider.js';
import { useParams } from 'react-router';
import { WorkspaceReviewSideBar } from './WorkspaceReviewSideBar.js';
import { WorkspaceReviewPanel } from './WorkspaceReviewPanel.js';
import { ACTIVITY_MODE } from '../../stores/EditorConfig.js';
import { Link } from 'react-router-dom';
import { getControlledResizablePanelProps, clsx, PanelLoadingIndicator, ResizablePanel, ResizablePanelGroup, ResizablePanelSplitter, CheckListIcon, CodeBranchIcon, CogIcon, UserIcon, AssistantIcon, } from '@finos/legend-art';
import { generateViewProjectRoute, generateEditorRoute, } from '../../stores/LegendStudioRouter.js';
import { flowResult } from 'mobx';
import { useEditorStore, withEditorStore, } from '../editor/EditorStoreProvider.js';
import { useApplicationStore } from '@finos/legend-application';
const WorkspaceReviewStatusBar = observer(() => {
const reviewStore = useWorkspaceReviewStore();
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.isApprovingReview
? 'approving review...'
: reviewStore.isCommittingReview
? 'committing review...'
: reviewStore.isClosingReview
? 'closing review...'
: reviewStore.isReopeningReview
? 'reopening review...'
: reviewStore.isFetchingComparison
? '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("div", { className: "workspace-review__status-bar__workspace__project", children: _jsx(Link, { to: generateViewProjectRoute(reviewStore.projectId), children: currentProject }) }), "/", _jsx("div", { className: "workspace-review__status-bar__workspace__workspace", children: _jsx(Link, { to: generateEditorRoute(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 WorkspaceReviewExplorer = observer(() => {
const reviewStore = useWorkspaceReviewStore();
const editorStore = useEditorStore();
const applicationStore = useApplicationStore();
const resizeSideBar = (handleProps) => editorStore.sideBarDisplayState.setSize(handleProps.domElement.getBoundingClientRect().width);
useEffect(() => {
flowResult(reviewStore.fetchReviewComparison()).catch(applicationStore.alertUnhandledError);
}, [applicationStore, reviewStore]);
return (_jsxs(ResizablePanelGroup, { orientation: "vertical", children: [_jsx(ResizablePanel, { ...getControlledResizablePanelProps(editorStore.sideBarDisplayState.size === 0, {
onStopResize: resizeSideBar,
size: editorStore.sideBarDisplayState.size,
}), direction: 1, children: _jsx(WorkspaceReviewSideBar, {}) }), _jsx(ResizablePanelSplitter, {}), _jsx(ResizablePanel, { minSize: 300, children: _jsx(WorkspaceReviewPanel, {}) })] }));
});
export const WorkspaceReview = withEditorStore(withWorkspaceReviewStore(observer(() => {
const params = useParams();
const projectId = params.projectId;
const reviewId = params.reviewId;
const reviewStore = useWorkspaceReviewStore();
const editorStore = useEditorStore();
const applicationStore = useApplicationStore();
const changeActivity = (activity) => () => editorStore.setActiveActivity(activity);
useEffect(() => {
reviewStore.setProjectIdAndReviewId(projectId, reviewId);
flowResult(reviewStore.initialize()).catch(applicationStore.alertUnhandledError);
flowResult(reviewStore.getReview()).catch(applicationStore.alertUnhandledError);
flowResult(reviewStore.fetchProject()).catch(applicationStore.alertUnhandledError);
}, [applicationStore, reviewStore, projectId, reviewId]);
return (_jsx("div", { className: "app__page", children: _jsxs("div", { className: "workspace-review", children: [_jsx(PanelLoadingIndicator, { isLoading: reviewStore.isFetchingCurrentReview }), reviewStore.currentReview && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "workspace-review__body", children: [_jsxs("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: "activity-bar__setting", children: _jsx("button", { className: "activity-bar__item", tabIndex: -1, title: 'Settings...', children: _jsx(CogIcon, {}) }) })] }), _jsx("div", { className: "workspace-review__content-container", children: _jsx("div", { className: "workspace-review__content", children: _jsx(WorkspaceReviewExplorer, {}) }) })] }), _jsx(WorkspaceReviewStatusBar, {})] }))] }) }));
})));
//# sourceMappingURL=WorkspaceReview.js.map