From 8b7594c2d13edc7a809a12b13ff455bf71bc665e Mon Sep 17 00:00:00 2001 From: Edmond Lee Date: Thu, 21 May 2020 16:54:17 -0700 Subject: [PATCH] update example.ts, generate-deploy-script.ts, and load-state.ts to support default generateDeployScript values for examples --- tools/webide/packages/client/src/redux/example.ts | 3 +++ .../packages/client/src/redux/generate-deploy-script.ts | 9 ++++++++- tools/webide/packages/server/src/load-state.ts | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/webide/packages/client/src/redux/example.ts b/tools/webide/packages/client/src/redux/example.ts index 12a799555..4a49d829b 100644 --- a/tools/webide/packages/client/src/redux/example.ts +++ b/tools/webide/packages/client/src/redux/example.ts @@ -4,6 +4,8 @@ import { DryRunState } from './dry-run'; import { EditorState } from './editor'; import { EvaluateFunctionState } from './evaluate-function'; import { EvaluateValueState } from './evaluate-value'; +import { GenerateDeployScriptState } from './generate-deploy-script'; + export interface ExampleState { id: string; @@ -14,4 +16,5 @@ export interface ExampleState { deploy: DeployState; evaluateFunction: EvaluateFunctionState; evaluateValue: EvaluateValueState; + generateDeployScript: GenerateDeployScriptState; } diff --git a/tools/webide/packages/client/src/redux/generate-deploy-script.ts b/tools/webide/packages/client/src/redux/generate-deploy-script.ts index 0bbf7168a..0d4adcb14 100644 --- a/tools/webide/packages/client/src/redux/generate-deploy-script.ts +++ b/tools/webide/packages/client/src/redux/generate-deploy-script.ts @@ -1,3 +1,4 @@ +import { ActionType as ExamplesActionType, ChangeSelectedAction as ChangeSelectedExampleAction } from './examples'; import { Tool, ToolCommand } from './types'; export enum ActionType { @@ -40,7 +41,8 @@ type Action = | ChangeToolAction | ChangeCommandAction | ChangeEntrypointAction - | ChangeStorageAction; + | ChangeStorageAction + | ChangeSelectedExampleAction; const DEFAULT_STATE: GenerateDeployScriptState = { tool: Tool.TezosClient, @@ -56,6 +58,11 @@ export default ( action: Action ): GenerateDeployScriptState => { switch (action.type) { + case ExamplesActionType.ChangeSelected: + return { + ...state, + ...(!action.payload ? DEFAULT_STATE : action.payload.generateDeployScript) + }; case ActionType.ChangeTool: return { ...state, diff --git a/tools/webide/packages/server/src/load-state.ts b/tools/webide/packages/server/src/load-state.ts index a1062e962..11da3a100 100644 --- a/tools/webide/packages/server/src/load-state.ts +++ b/tools/webide/packages/server/src/load-state.ts @@ -28,6 +28,7 @@ export async function loadDefaultState(appBundleDirectory: string) { deploy: {}, evaluateValue: {}, evaluateFunction: {}, + generateDeployScript: {}, editor: { title: '' }, @@ -63,6 +64,10 @@ export async function loadDefaultState(appBundleDirectory: string) { ...defaultState.evaluateFunction, ...defaultExample.evaluateFunction }; + defaultState.generateDeployScript = { + ...defaultState.generateDeployScript, + ...defaultExample.generateDeployScript + }; defaultState.editor = { ...defaultState.editor, ...defaultExample.editor,