Skip to content

Commit

Permalink
feat(editor): hide warning area & disable validator
Browse files Browse the repository at this point in the history
  • Loading branch information
tanbowensg committed Aug 28, 2023
1 parent 59d5e6a commit b7e9e16
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 43 deletions.
4 changes: 2 additions & 2 deletions packages/editor/src/components/WarningArea/ErrorLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DebugTable } from './Table';
import { Box } from '@chakra-ui/react';

export const ErrorLogs: React.FC<Props> = ({ services }) => {
const { validateResult, setSelectedComponentId } = services.editorStore;
const { setSelectedComponentId } = services.editorStore;
const errorColumns = [
{
title: 'Component Id',
Expand Down Expand Up @@ -37,7 +37,7 @@ export const ErrorLogs: React.FC<Props> = ({ services }) => {

return (
<DebugTable
data={validateResult}
data={[]}
pagination={{ hideOnSinglePage: true }}
columns={errorColumns}
emptyMessage="No Errors"
Expand Down
9 changes: 0 additions & 9 deletions packages/editor/src/components/WarningArea/WarningArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
HStack,
IconButton,
Tabs,
Text,
TabPanel,
TabPanels,
TabList,
Expand Down Expand Up @@ -150,14 +149,6 @@ export const WarningArea: React.FC<Props> = observer(({ services }) => {
>
<Tabs h="full" w="full" variant="soft-rounded" colorScheme="gray">
<TabList>
<Tab alignItems="baseline">
<Text fontSize="md" fontWeight="bold">
Errors
</Text>
<Badge ml="1" fontSize="0.8em" colorScheme="red">
{editorStore.validateResult.length}
</Badge>
</Tab>
<Tab>Logs</Tab>
<HStack w="full" justify="end">
{editorStore.isSaved ? savedBadge : unsaveBadge}
Expand Down
32 changes: 0 additions & 32 deletions packages/editor/src/services/EditorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand All @@ -45,7 +43,6 @@ export class EditorStore {
// when componentsChange event is triggered, currentComponentsVersion++
currentComponentsVersion = 0;
lastSavedComponentsVersion = 0;
schemaValidator?: SchemaValidator;

private isDataSourceTypeCache: Record<string, boolean> = {};

Expand All @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -287,10 +263,6 @@ export class EditorStore {
this.lastSavedComponentsVersion = val;
};

setValidateResult = (validateResult: ValidateErrorResult[]) => {
this.validateResult = validateResult;
};

setExplorerMenuTab = (val: ExplorerMenuTabs) => {
this.explorerMenuTab = val;
};
Expand All @@ -307,10 +279,6 @@ export class EditorStore {
this.isDraggingNewComponent = val;
};

setSchemaValidator = (val: SchemaValidator) => {
this.schemaValidator = val;
};

setModuleDependencies = (exampleProperties?: Record<string, unknown>) => {
const evaledDependencies = this.stateManager.deepEval(exampleProperties || {}, {
fallbackWhenError: () => undefined,
Expand Down

0 comments on commit b7e9e16

Please sign in to comment.