Skip to content

Commit

Permalink
deployed activators alert added (#3612)
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-thai authored Oct 17, 2024
1 parent 12ae1f7 commit 5f661e5
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .changeset/metal-books-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@finos/legend-application-studio': patch
'@finos/legend-graph': patch
---

Successfully deployed activators will now receive a pop-up alert that includes the link to the deployed activator.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ import type { EditorStore } from '../../../EditorStore.js';
import { ElementEditorState } from '../ElementEditorState.js';
import { activator_setOwnership } from '../../../../graph-modifier/DSL_FunctionActivator_GraphModifierHelper.js';
import { User } from '@finos/legend-server-sdlc';
import {
ActionAlertActionType,
ActionAlertType,
} from '@finos/legend-application';

//Ownership
export enum HostedServiceOwnershipType {
Expand Down Expand Up @@ -178,13 +182,40 @@ export class HostedServiceFunctionActivatorEditorState extends ElementEditorStat
*deployToSandbox(): GeneratorFn<void> {
this.deployState.inProgress();
try {
yield this.editorStore.graphManagerState.graphManager.publishFunctionActivatorToSandbox(
this.activator,
new InMemoryGraphData(this.editorStore.graphManagerState.graph),
);
this.editorStore.applicationStore.notificationService.notifySuccess(
'Hosted Service Function Activator has been deployed successfully',
);
yield this.editorStore.graphManagerState.graphManager
.publishFunctionActivatorToSandbox(
this.activator,
new InMemoryGraphData(this.editorStore.graphManagerState.graph),
)
.then((response) =>
this.editorStore.applicationStore.alertService.setActionAlertInfo({
message: `Hosted Service Function Activator has been deployed successfully`,
prompt: response.deploymentLocation
? 'You can now launch and monitor the operation of your function activator'
: undefined,
type: ActionAlertType.STANDARD,
actions: [
...(response.deploymentLocation !== undefined
? [
{
label: 'Launch Service',
type: ActionAlertActionType.PROCEED,
handler: (): void => {
this.editorStore.applicationStore.navigationService.navigator.visitAddress(
response.deploymentLocation ?? '',
);
},
default: true,
},
]
: []),
{
label: 'Close',
type: ActionAlertActionType.PROCEED_WITH_CAUTION,
},
],
}),
);
} catch (error) {
assertErrorThrown(error);
this.editorStore.applicationStore.notificationService.notifyError(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import type { EngineError } from './action/EngineError.js';
import type { TestDebug } from '../graph/metamodel/pure/test/result/DebugTestsResult.js';
import type { RelationTypeMetadata } from './action/relation/RelationTypeMetadata.js';
import type { CodeCompletionResult } from './action/compilation/Completion.js';
import type { DeploymentResult } from './action/DeploymentResult.js';

export interface TEMPORARY__EngineSetupConfig {
env: string;
Expand Down Expand Up @@ -685,7 +686,7 @@ export abstract class AbstractPureGraphManager {
abstract publishFunctionActivatorToSandbox(
functionActivator: FunctionActivator,
graphData: GraphData,
): Promise<void>;
): Promise<DeploymentResult>;

// --------------------------------------------- Relational ---------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

import { primitive, createModelSchema, list } from 'serializr';
import { primitive, createModelSchema, list, optional } from 'serializr';
import { SerializationFactory } from '@finos/legend-shared';

export class V1_DeploymentResult {
export class DeploymentResult {
activatorIdentifier!: string;
successful!: boolean;
errors: string[] = [];
deploymentLocation!: string;
deploymentLocation: string | undefined;

static readonly serialization = new SerializationFactory(
createModelSchema(V1_DeploymentResult, {
createModelSchema(DeploymentResult, {
activatorIdentifier: primitive(),
successful: primitive(),
errors: list(primitive()),
deploymentLocation: primitive(),
deploymentLocation: optional(primitive()),
}),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ import type { V1_GraphManagerEngine } from './engine/V1_GraphManagerEngine.js';
import type { RelationTypeMetadata } from '../../../action/relation/RelationTypeMetadata.js';
import type { CodeCompletionResult } from '../../../action/compilation/Completion.js';
import { V1_CompleteCodeInput } from './engine/compilation/V1_CompleteCodeInput.js';
import type { DeploymentResult } from '../../../action/DeploymentResult.js';

class V1_PureModelContextDataIndex {
elements: V1_PackageableElement[] = [];
Expand Down Expand Up @@ -3497,12 +3498,13 @@ export class V1_PureGraphManager extends AbstractPureGraphManager {
async publishFunctionActivatorToSandbox(
functionActivator: FunctionActivator,
graphData: GraphData,
): Promise<void> {
): Promise<DeploymentResult> {
const input = new V1_FunctionActivatorInput();
input.clientVersion = V1_PureGraphManager.PROD_PROTOCOL_VERSION;
input.functionActivator = functionActivator.path;
input.model = this.prepareExecutionContextGraphData(graphData);
await this.engine.publishFunctionActivatorToSandbox(input);
const result = await this.engine.publishFunctionActivatorToSandbox(input);
return result;
}

// --------------------------------------------- Relational ---------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ import type { V1_TestDataGenerationInput } from './service/V1_TestDataGeneration
import type { V1_TestDataGenerationResult } from './service/V1_TestDataGenerationResult.js';
import type { V1_RelationalConnectionBuilder } from './relational/V1_RelationalConnectionBuilder.js';
import type { V1_LambdaPrefix } from './lambda/V1_LambdaPrefix.js';
import type { V1_DeploymentResult } from './functionActivator/V1_DeploymentResult.js';
import type { V1_DebugTestsResult } from './test/V1_DebugTestsResult.js';
import type { V1_RelationType } from '../model/relation/V1_RelationType.js';
import type { CodeCompletionResult } from '../../../../action/compilation/Completion.js';
import type { V1_CompleteCodeInput } from './compilation/V1_CompleteCodeInput.js';
import type { DeploymentResult } from '../../../../action/DeploymentResult.js';

enum CORE_ENGINE_ACTIVITY_TRACE {
GRAMMAR_TO_JSON = 'transform Pure code to protocol',
Expand Down Expand Up @@ -949,7 +949,7 @@ export class V1_EngineServerClient extends AbstractServerClient {

publishFunctionActivatorToSandbox(
input: PlainObject<V1_FunctionActivatorInput>,
): Promise<PlainObject<V1_DeploymentResult>> {
): Promise<PlainObject<DeploymentResult>> {
return this.postWithTracing(
this.getTraceData(
CORE_ENGINE_ACTIVITY_TRACE.PUBLISH_FUNCTION_ACTIVATOR_TO_SANDBOX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import type { TEMPORARY__AbstractEngineConfig } from '../../../../action/TEMPORA
import type { RelationTypeMetadata } from '../../../../action/relation/RelationTypeMetadata.js';
import type { V1_CompleteCodeInput } from './compilation/V1_CompleteCodeInput.js';
import type { CodeCompletionResult } from '../../../../action/compilation/Completion.js';
import type { DeploymentResult } from '../../../../action/DeploymentResult.js';

export interface V1_GraphManagerEngine {
config: TEMPORARY__AbstractEngineConfig;
Expand Down Expand Up @@ -369,7 +370,7 @@ export interface V1_GraphManagerEngine {

publishFunctionActivatorToSandbox: (
input: V1_FunctionActivatorInput,
) => Promise<void>;
) => Promise<DeploymentResult>;

// ------------------------------------------- Relational -------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ import {
V1_testDataGenerationResultModelSchema,
} from './service/V1_TestDataGenerationResult.js';
import { V1_RelationalConnectionBuilder } from './relational/V1_RelationalConnectionBuilder.js';
import { V1_DeploymentResult } from './functionActivator/V1_DeploymentResult.js';
import type { PostValidationAssertionResult } from '../../../../../DSL_Service_Exports.js';
import { V1_DebugTestsResult } from './test/V1_DebugTestsResult.js';
import type { V1_GraphManagerEngine } from './V1_GraphManagerEngine.js';
Expand All @@ -162,6 +161,7 @@ import {
} from '../../../../action/relation/RelationTypeMetadata.js';
import { V1_CompleteCodeInput } from './compilation/V1_CompleteCodeInput.js';
import { CodeCompletionResult } from '../../../../action/compilation/Completion.js';
import { DeploymentResult } from '../../../../action/DeploymentResult.js';

class V1_RemoteEngineConfig extends TEMPORARY__AbstractEngineConfig {
private engine: V1_RemoteEngine;
Expand Down Expand Up @@ -1251,17 +1251,18 @@ export class V1_RemoteEngine implements V1_GraphManagerEngine {

async publishFunctionActivatorToSandbox(
input: V1_FunctionActivatorInput,
): Promise<void> {
const error = V1_DeploymentResult.serialization.fromJson(
): Promise<DeploymentResult> {
const deploymentResult = DeploymentResult.serialization.fromJson(
await this.engineServerClient.publishFunctionActivatorToSandbox(
V1_FunctionActivatorInput.serialization.toJson(input),
),
);
if (!error.successful) {
if (!deploymentResult.successful) {
throw new Error(
`Function activator validation failed: ${error.errors.join('\n')}`,
`Function activator validation failed: ${deploymentResult.errors.join('\n')}`,
);
}
return deploymentResult;
}

// ------------------------------------------- Relational -------------------------------------------
Expand Down

0 comments on commit 5f661e5

Please sign in to comment.