Changes to notebook publish pane (#419)

* Changes to publish pane

* fixed format errors

* fixed failing test

Co-authored-by: Tanuj Mittal <tamitta@microsoft.com>
This commit is contained in:
Srinath Narayanan
2021-02-03 10:46:51 -08:00
committed by GitHub
parent db7c45c9b8
commit 3b6fda4fa5
3 changed files with 25 additions and 17 deletions

View File

@@ -70,7 +70,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
onChangeDescription: (newValue: string) => (this.description = newValue),
onChangeTags: (newValue: string) => (this.tags = newValue),
onChangeImageSrc: (newValue: string) => (this.imageSrc = newValue),
onError: this.createFormErrorForLargeImageSelection,
onError: this.createFormError,
clearFormError: this.clearFormError,
};
@@ -146,11 +146,15 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
let startKey: number;
try {
if (!this.name || !this.description || !this.author) {
throw new Error("Name, description, and author are required");
}
if (!this.name || !this.description || !this.author || !this.imageSrc) {
const formError = `Failed to publish ${this.name} to gallery`;
const formErrorDetail = "Name, description, author and cover image are required";
this.createFormError(formError, formErrorDetail, "PublishNotebookPaneAdapter/submit");
this.isExecuting = false;
return;
}
try {
startKey = traceStart(Action.NotebooksGalleryPublish, {
databaseAccountName: this.container.databaseAccount()?.name,
defaultExperience: this.container.defaultExperience(),
@@ -217,7 +221,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
this.close();
}
private createFormErrorForLargeImageSelection = (formError: string, formErrorDetail: string, area: string): void => {
private createFormError = (formError: string, formErrorDetail: string, area: string): void => {
this.formError = formError;
this.formErrorDetail = formErrorDetail;
handleError(formErrorDetail, area, formError);