From b7e9e16406195a987ef5a7c17ba5b7b3c9303895 Mon Sep 17 00:00:00 2001 From: Bowen Tan Date: Mon, 28 Aug 2023 16:33:12 +0800 Subject: [PATCH] feat(editor): hide warning area & disable validator --- .../src/components/WarningArea/ErrorLogs.tsx | 4 +-- .../components/WarningArea/WarningArea.tsx | 9 ------ packages/editor/src/services/EditorStore.ts | 32 ------------------- 3 files changed, 2 insertions(+), 43 deletions(-) diff --git a/packages/editor/src/components/WarningArea/ErrorLogs.tsx b/packages/editor/src/components/WarningArea/ErrorLogs.tsx index ec084a2de..5f1afc51e 100644 --- a/packages/editor/src/components/WarningArea/ErrorLogs.tsx +++ b/packages/editor/src/components/WarningArea/ErrorLogs.tsx @@ -4,7 +4,7 @@ import { DebugTable } from './Table'; import { Box } from '@chakra-ui/react'; export const ErrorLogs: React.FC = ({ services }) => { - const { validateResult, setSelectedComponentId } = services.editorStore; + const { setSelectedComponentId } = services.editorStore; const errorColumns = [ { title: 'Component Id', @@ -37,7 +37,7 @@ export const ErrorLogs: React.FC = ({ services }) => { return ( = observer(({ services }) => { > - - - Errors - - - {editorStore.validateResult.length} - - Logs {editorStore.isSaved ? savedBadge : unsaveBadge} diff --git a/packages/editor/src/services/EditorStore.ts b/packages/editor/src/services/EditorStore.ts index 07edb296e..461126921 100644 --- a/packages/editor/src/services/EditorStore.ts +++ b/packages/editor/src/services/EditorStore.ts @@ -5,7 +5,6 @@ import { isEqual } from 'lodash'; import { EventBusType } from './eventBus'; import { AppStorage } from './AppStorage'; -import type { SchemaValidator, ValidateErrorResult } from '../validator'; import { ExplorerMenuTabs, ToolMenuTabs } from '../constants/enum'; import { AppModelManager } from '../operations/AppModelManager'; @@ -29,7 +28,6 @@ export class EditorStore { explorerMenuTab = ExplorerMenuTabs.UI_TREE; toolMenuTab = ToolMenuTabs.INSERT; viewStateComponentId = ''; - validateResult: ValidateErrorResult[] = []; // current editor editing target(app or module) currentEditingTarget: EditingTarget = { kind: 'app', @@ -45,7 +43,6 @@ export class EditorStore { // when componentsChange event is triggered, currentComponentsVersion++ currentComponentsVersion = 0; lastSavedComponentsVersion = 0; - schemaValidator?: SchemaValidator; private isDataSourceTypeCache: Record = {}; @@ -57,19 +54,9 @@ export class EditorStore { private appModelManager: AppModelManager ) { this.globalDependencies = this.stateManager.dependencies; - const dependencyNames = Object.keys(this.globalDependencies); - // dynamic load validator - import('../validator').then(({ SchemaValidator: SchemaValidatorClass }) => { - this.setSchemaValidator(new SchemaValidatorClass(this.registry, dependencyNames)); - // do first validation - this.setValidateResult( - this.schemaValidator!.validate(this.appModelManager.appModel) - ); - }); makeAutoObservable(this, { eleMap: false, components: observable.shallow, - schemaValidator: observable.ref, setComponents: action, setHoverComponentId: action, setDragOverComponentId: action, @@ -133,17 +120,6 @@ export class EditorStore { } ); - reaction( - () => this.components, - () => { - if (this.schemaValidator) { - this.setValidateResult( - this.schemaValidator.validate(this.appModelManager.appModel) - ); - } - } - ); - this.updateCurrentEditingTarget('app', this.app.version, this.app.metadata.name); } @@ -287,10 +263,6 @@ export class EditorStore { this.lastSavedComponentsVersion = val; }; - setValidateResult = (validateResult: ValidateErrorResult[]) => { - this.validateResult = validateResult; - }; - setExplorerMenuTab = (val: ExplorerMenuTabs) => { this.explorerMenuTab = val; }; @@ -307,10 +279,6 @@ export class EditorStore { this.isDraggingNewComponent = val; }; - setSchemaValidator = (val: SchemaValidator) => { - this.schemaValidator = val; - }; - setModuleDependencies = (exampleProperties?: Record) => { const evaledDependencies = this.stateManager.deepEval(exampleProperties || {}, { fallbackWhenError: () => undefined,