UNPKG

@finos/legend-application-studio

Version:
70 lines 3.45 kB
/** * 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 { ActionState, assertErrorThrown, assertNonNullable, assertTrue, } from '@finos/legend-shared'; import { action, flow, makeObservable, observable } from 'mobx'; import { MetadataRequestOptions, } from '@finos/legend-graph'; import { LegendStudioTelemetryHelper } from '../../../../__lib__/LegendStudioTelemetryHelper.js'; export class DevMetadataState { editorStore; result; options = new MetadataRequestOptions(); pushState = ActionState.create(); constructor(editorStore) { this.editorStore = editorStore; makeObservable(this, { pushState: observable, push: flow, options: observable, setOptions: action, }); } setOptions(options) { this.options = options; } get projectGAV() { const currentProjectConfiguration = this.editorStore.projectConfigurationEditorState.projectConfiguration; if (currentProjectConfiguration) { return { groupId: currentProjectConfiguration.groupId, artifactId: currentProjectConfiguration.artifactId, }; } return undefined; } *push() { try { this.result = undefined; const dependenciesSize = this.editorStore.graphManagerState.graph.dependencyManager .projectDependencyModelsIndex.size; assertTrue(dependenciesSize === 0, 'Dependencies not supported in dev mode'); const currentProjectConfiguration = this.editorStore.projectConfigurationEditorState .currentProjectConfiguration; assertNonNullable(currentProjectConfiguration, 'Project Name required to push to dev mode'); this.pushState.inProgress(); const result = (yield this.editorStore.graphManagerState.graphManager.pushToDevMetadata(currentProjectConfiguration.groupId, currentProjectConfiguration.artifactId, undefined, this.options, this.editorStore.graphManagerState.graph)); this.result = result; LegendStudioTelemetryHelper.logEvent_DevMetadataPushLaunched(this.editorStore.applicationStore.telemetryService, this.editorStore.editorMode.getSourceInfo(), currentProjectConfiguration.groupId, currentProjectConfiguration.artifactId, undefined, result.finalStatus); this.pushState.complete(); } catch (error) { assertErrorThrown(error); this.editorStore.applicationStore.notificationService.notifyError(`Error pushing to dev metadata: ${error.message}`); LegendStudioTelemetryHelper.logEvent_DevMetadataPushFailure(this.editorStore.applicationStore.telemetryService, this.editorStore.editorMode.getSourceInfo(), error.message); this.pushState.fail(); } } } //# sourceMappingURL=DevMetadataState.js.map