update example.ts, generate-deploy-script.ts, and load-state.ts to support default generateDeployScript values for examples

This commit is contained in:
Edmond Lee 2020-05-21 16:54:17 -07:00
parent 0e48b5bb54
commit 8b7594c2d1
3 changed files with 16 additions and 1 deletions

View File

@ -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;
}

View File

@ -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,

View File

@ -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,