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 committed by Jev Björsell
parent b9ee504dd6
commit 11f1cf01ee
No known key found for this signature in database
GPG Key ID: 03F50CB91981EC9E
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 { EditorState } from './editor';
import { EvaluateFunctionState } from './evaluate-function'; import { EvaluateFunctionState } from './evaluate-function';
import { EvaluateValueState } from './evaluate-value'; import { EvaluateValueState } from './evaluate-value';
import { GenerateDeployScriptState } from './generate-deploy-script';
export interface ExampleState { export interface ExampleState {
id: string; id: string;
@ -14,4 +16,5 @@ export interface ExampleState {
deploy: DeployState; deploy: DeployState;
evaluateFunction: EvaluateFunctionState; evaluateFunction: EvaluateFunctionState;
evaluateValue: EvaluateValueState; evaluateValue: EvaluateValueState;
generateDeployScript: GenerateDeployScriptState;
} }

View File

@ -1,3 +1,4 @@
import { ActionType as ExamplesActionType, ChangeSelectedAction as ChangeSelectedExampleAction } from './examples';
import { Tool, ToolCommand } from './types'; import { Tool, ToolCommand } from './types';
export enum ActionType { export enum ActionType {
@ -40,7 +41,8 @@ type Action =
| ChangeToolAction | ChangeToolAction
| ChangeCommandAction | ChangeCommandAction
| ChangeEntrypointAction | ChangeEntrypointAction
| ChangeStorageAction; | ChangeStorageAction
| ChangeSelectedExampleAction;
const DEFAULT_STATE: GenerateDeployScriptState = { const DEFAULT_STATE: GenerateDeployScriptState = {
tool: Tool.TezosClient, tool: Tool.TezosClient,
@ -56,6 +58,11 @@ export default (
action: Action action: Action
): GenerateDeployScriptState => { ): GenerateDeployScriptState => {
switch (action.type) { switch (action.type) {
case ExamplesActionType.ChangeSelected:
return {
...state,
...(!action.payload ? DEFAULT_STATE : action.payload.generateDeployScript)
};
case ActionType.ChangeTool: case ActionType.ChangeTool:
return { return {
...state, ...state,

View File

@ -28,6 +28,7 @@ export async function loadDefaultState(appBundleDirectory: string) {
deploy: {}, deploy: {},
evaluateValue: {}, evaluateValue: {},
evaluateFunction: {}, evaluateFunction: {},
generateDeployScript: {},
editor: { editor: {
title: '' title: ''
}, },
@ -63,6 +64,10 @@ export async function loadDefaultState(appBundleDirectory: string) {
...defaultState.evaluateFunction, ...defaultState.evaluateFunction,
...defaultExample.evaluateFunction ...defaultExample.evaluateFunction
}; };
defaultState.generateDeployScript = {
...defaultState.generateDeployScript,
...defaultExample.generateDeployScript
};
defaultState.editor = { defaultState.editor = {
...defaultState.editor, ...defaultState.editor,
...defaultExample.editor, ...defaultExample.editor,