Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for preferences schema provided by a plug-in in a manifest file #3159

Merged
merged 2 commits into from
Oct 12, 2018

Conversation

akurinnoy
Copy link
Contributor

props.push(property);
}
}
this.validateFunction = new Ajv().compile(this.combinedSchema);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refactor that it is called only once from the constructor, not for each contribution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!
My point here is to be able to validate a plugin schema too. Do we have another way to validate it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, you can call it from setSchema as well

just refactor it in a way that it is called once from the constructor and on each call of setSchema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already called once from the constructor since setSchema is called there. Or maybe I missed something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is called in forEach loop for each contribution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, got it! I'll refactor this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -96,6 +85,26 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
return this.preferences;
}

setSchema(schema: PreferenceSchema, updateValidation: boolean = true): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How abou, instead of adding internal options to public APIs extract 2 methods:

setSchema(schema: PreferenceSchema): void {
    this.doSetSchema(schema);
    this.updateValidate();
}
protected doSetSchema() ... // updates combined schema
protected updateValidate() ... // updates validate function

and call doSetSchema and updateValidate from the constructor instead of setSchema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this will be better, I'm updating the PR

akurinnoy and others added 2 commits October 12, 2018 14:18
and consolidate it with existing ones

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
…in init

Signed-off-by: Yevhen Vydolob <yvydolob@redhat.com>
@akurinnoy akurinnoy merged commit b33c49e into master Oct 12, 2018
@akurinnoy akurinnoy deleted the CHE-9990 branch October 12, 2018 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WIPTheia] Add support for preferences schema from contribution point of a manifest file
5 participants