/** * 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 { observer } from 'mobx-react-lite'; import { clsx, HammerIcon, SyncIcon, FireIcon, CodeBranchIcon, TerminalIcon, HackerIcon, TrashIcon, CloudUploadIcon, AssistantIcon, ErrorIcon, WarningIcon, ShieldIcon, } from '@finos/legend-art'; import { LEGEND_STUDIO_TEST_ID } from '../../__lib__/LegendStudioTesting.js'; import { ACTIVITY_MODE, PANEL_MODE, GRAPH_EDITOR_MODE, } from '../../stores/editor/EditorConfig.js'; import { generateSetupRoute, type WorkspaceEditorPathParams, } from '../../__lib__/LegendStudioNavigation.js'; import { flowResult } from 'mobx'; import { useEditorStore } from './EditorStoreProvider.js'; import { WorkspaceType } from '@finos/legend-server-sdlc'; import { useLegendStudioApplicationStore, useLegendStudioBaseStore, } from '../LegendStudioFrameworkProvider.js'; import { useParams } from '@finos/legend-application/browser'; import { guaranteeNonNullable } from '@finos/legend-shared'; export const StatusBar = observer((props: { actionsDisabled: boolean }) => { const { actionsDisabled } = props; const params = useParams(); const editorStore = useEditorStore(); const applicationStore = useLegendStudioApplicationStore(); const baseStore = useLegendStudioBaseStore(); const isInConflictResolutionMode = editorStore.isInConflictResolutionMode; // SDLC const projectId = params.projectId; const workspaceType = params.groupWorkspaceId ? WorkspaceType.GROUP : WorkspaceType.USER; const patchReleaseVersionId = params.patchReleaseVersionId ? `patch / ${params.patchReleaseVersionId} / ` : ''; const workspaceId = guaranteeNonNullable( params.groupWorkspaceId ?? params.workspaceId, `Workspace/group workspace ID is not provided`, ); const currentProject = editorStore.sdlcState.currentProject; const goToWorkspaceUpdater = (): void => editorStore.setActiveActivity( isInConflictResolutionMode ? ACTIVITY_MODE.CONFLICT_RESOLUTION : ACTIVITY_MODE.WORKSPACE_UPDATER, ); const goToLocalChanges = (): void => editorStore.setActiveActivity(ACTIVITY_MODE.LOCAL_CHANGES); // Change Detection const changes = editorStore.changeDetectionState.workspaceLocalLatestRevisionState.changes .length; const configurationState = editorStore.projectConfigurationEditorState; const pushLocalChanges = applicationStore.guardUnhandledError(() => flowResult(editorStore.localChangesState.pushLocalChanges()), ); // TODO: we probably should refactor this, these messages are not that helpful and // meant for different purposes const pushStatusText = editorStore.graphManagerState.graphBuildState.hasFailed || editorStore.changeDetectionState.initState.hasFailed ? 'change detection halted' : !editorStore.changeDetectionState.initState.hasSucceeded ? editorStore.changeDetectionState.workspaceLocalLatestRevisionState .isBuildingEntityHashesIndex ? 'building indexes...' : 'starting change detection...' : editorStore.localChangesState.pushChangesState.isInProgress ? 'pushing local changes...' : configurationState.updatingConfigurationState.isInProgress ? 'updating configuration...' : changes ? `${changes} unpushed changes` : 'no changes detected'; const workspaceOutOfSync = !actionsDisabled && editorStore.sdlcState.isWorkspaceOutOfSync; // Problems const error = editorStore.graphState.error; const warnings = editorStore.graphState.warnings; // Conflict resolution const conflicts = editorStore.conflictResolutionState.conflicts.length; const acceptConflictResolution = applicationStore.guardUnhandledError(() => flowResult(editorStore.conflictResolutionState.acceptConflictResolution()), ); // TODO: we probably should refactor this, these messages are not that helpful and // meant for different purposes const conflictResolutionStatusText = editorStore.graphManagerState.graphBuildState.hasFailed || editorStore.changeDetectionState.initState.hasFailed ? 'change detection halted' : !editorStore.changeDetectionState.initState.hasSucceeded ? editorStore.changeDetectionState.workspaceLocalLatestRevisionState .isBuildingEntityHashesIndex ? 'building indexes...' : 'starting change detection...' : editorStore.conflictResolutionState.isAcceptingConflictResolution ? 'submitting conflict resolution...' : conflicts ? `has unresolved merge conflicts` : editorStore.conflictResolutionState.hasResolvedAllConflicts ? 'conflict resolution not accepted' : 'all conflicts resolved'; // Other actions const togglePanel = (): void => editorStore.panelGroupDisplayState.toggle(); const showCompilationWarnings = (): void => { editorStore.panelGroupDisplayState.open(); editorStore.setActivePanelMode(PANEL_MODE.PROBLEMS); }; const handleTextModeClick = applicationStore.guardUnhandledError(() => flowResult(editorStore.toggleTextMode()), ); const compile = applicationStore.guardUnhandledError(() => flowResult(editorStore.graphEditorMode.globalCompile()), ); const generate = applicationStore.guardUnhandledError(() => flowResult(editorStore.graphState.graphGenerationState.globalGenerate()), ); const emptyGenerationEntities = applicationStore.guardUnhandledError(() => flowResult(editorStore.graphState.graphGenerationState.clearGenerations()), ); const toggleAssistant = (): void => applicationStore.assistantService.toggleAssistant(); return (
/ {workspaceOutOfSync && ( )} {editorStore.sdlcState.isWorkspaceOutdated && !workspaceOutOfSync && ( )}
{isInConflictResolutionMode && (
{conflictResolutionStatusText}
)} {!isInConflictResolutionMode && (
{pushStatusText}
)} {baseStore.isSDLCPopupReAuthEnabled && ( )}
); });