Fix validation errors (#14009)

* Fix validation errors

* fix compile

* update return type
This commit is contained in:
Charles Gagnon
2021-01-21 10:40:46 -08:00
committed by GitHub
parent 5f61becd36
commit f986b8cf78
2 changed files with 4 additions and 5 deletions

View File

@@ -77,7 +77,7 @@ export interface IModelStore {
/** /**
* Run all validations for the given component and return the new validation value * Run all validations for the given component and return the new validation value
*/ */
validate(component: IComponent): Thenable<boolean>; validate(component: IComponent): Promise<boolean>;
} }
/** /**

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Deferred } from 'sql/base/common/promise'; import { Deferred } from 'sql/base/common/promise';
import { entries } from 'sql/base/common/collections';
import { IComponentDescriptor, IModelStore, IComponent } from 'sql/platform/dashboard/browser/interfaces'; import { IComponentDescriptor, IModelStore, IComponent } from 'sql/platform/dashboard/browser/interfaces';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
@@ -76,9 +75,9 @@ export class ModelStore implements IModelStore {
this._validationCallbacks.push(callback); this._validationCallbacks.push(callback);
} }
validate(component: IComponent): Thenable<boolean> { async validate(component: IComponent): Promise<boolean> {
let componentId = entries(this._componentMappings).find(([id, mappedComponent]) => component === mappedComponent)[0]; const validations = await Promise.all(this._validationCallbacks.map(callback => callback(component.descriptor.id)));
return Promise.all(this._validationCallbacks.map(callback => callback(componentId))).then(validations => validations.every(validation => validation === true)); return validations.every(validation => validation === true);
} }
/** /**