mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
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:
parent
db7c45c9b8
commit
3b6fda4fa5
@ -70,7 +70,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
|
|||||||
onChangeDescription: (newValue: string) => (this.description = newValue),
|
onChangeDescription: (newValue: string) => (this.description = newValue),
|
||||||
onChangeTags: (newValue: string) => (this.tags = newValue),
|
onChangeTags: (newValue: string) => (this.tags = newValue),
|
||||||
onChangeImageSrc: (newValue: string) => (this.imageSrc = newValue),
|
onChangeImageSrc: (newValue: string) => (this.imageSrc = newValue),
|
||||||
onError: this.createFormErrorForLargeImageSelection,
|
onError: this.createFormError,
|
||||||
clearFormError: this.clearFormError,
|
clearFormError: this.clearFormError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -146,11 +146,15 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
|
|||||||
|
|
||||||
let startKey: number;
|
let startKey: number;
|
||||||
|
|
||||||
try {
|
if (!this.name || !this.description || !this.author || !this.imageSrc) {
|
||||||
if (!this.name || !this.description || !this.author) {
|
const formError = `Failed to publish ${this.name} to gallery`;
|
||||||
throw new Error("Name, description, and author are required");
|
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, {
|
startKey = traceStart(Action.NotebooksGalleryPublish, {
|
||||||
databaseAccountName: this.container.databaseAccount()?.name,
|
databaseAccountName: this.container.databaseAccount()?.name,
|
||||||
defaultExperience: this.container.defaultExperience(),
|
defaultExperience: this.container.defaultExperience(),
|
||||||
@ -217,7 +221,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter {
|
|||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private createFormErrorForLargeImageSelection = (formError: string, formErrorDetail: string, area: string): void => {
|
private createFormError = (formError: string, formErrorDetail: string, area: string): void => {
|
||||||
this.formError = formError;
|
this.formError = formError;
|
||||||
this.formErrorDetail = formErrorDetail;
|
this.formErrorDetail = formErrorDetail;
|
||||||
handleError(formErrorDetail, area, formError);
|
handleError(formErrorDetail, area, formError);
|
||||||
|
@ -54,7 +54,7 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
type: ImageTypes.Url,
|
type: ImageTypes.CustomImage,
|
||||||
notebookName: props.notebookName,
|
notebookName: props.notebookName,
|
||||||
notebookDescription: "",
|
notebookDescription: "",
|
||||||
notebookTags: "",
|
notebookTags: "",
|
||||||
@ -120,6 +120,7 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
|
|||||||
this.thumbnailUrlProps = {
|
this.thumbnailUrlProps = {
|
||||||
label: "Cover image url",
|
label: "Cover image url",
|
||||||
ariaLabel: "Cover image url",
|
ariaLabel: "Cover image url",
|
||||||
|
required: true,
|
||||||
onChange: (event, newValue) => {
|
onChange: (event, newValue) => {
|
||||||
this.props.onChangeImageSrc(newValue);
|
this.props.onChangeImageSrc(newValue);
|
||||||
this.setState({ imageSrc: newValue });
|
this.setState({ imageSrc: newValue });
|
||||||
@ -140,7 +141,7 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
|
|||||||
this.props.onError(formError, formErrorDetail, area);
|
this.props.onError(formError, formErrorDetail, area);
|
||||||
};
|
};
|
||||||
|
|
||||||
const options: ImageTypes[] = [ImageTypes.Url, ImageTypes.CustomImage];
|
const options: ImageTypes[] = [ImageTypes.CustomImage, ImageTypes.Url];
|
||||||
|
|
||||||
if (this.props.notebookParentDomElement) {
|
if (this.props.notebookParentDomElement) {
|
||||||
options.push(ImageTypes.TakeScreenshot);
|
options.push(ImageTypes.TakeScreenshot);
|
||||||
@ -151,10 +152,12 @@ export class PublishNotebookPaneComponent extends React.Component<PublishNoteboo
|
|||||||
|
|
||||||
this.thumbnailSelectorProps = {
|
this.thumbnailSelectorProps = {
|
||||||
label: "Cover image",
|
label: "Cover image",
|
||||||
defaultSelectedKey: ImageTypes.Url,
|
defaultSelectedKey: ImageTypes.CustomImage,
|
||||||
ariaLabel: "Cover image",
|
ariaLabel: "Cover image",
|
||||||
options: options.map((value: string) => ({ text: value, key: value })),
|
options: options.map((value: string) => ({ text: value, key: value })),
|
||||||
onChange: async (event, options) => {
|
onChange: async (event, options) => {
|
||||||
|
this.setState({ imageSrc: undefined });
|
||||||
|
this.props.onChangeImageSrc(undefined);
|
||||||
this.props.clearFormError();
|
this.props.clearFormError();
|
||||||
if (options.text === ImageTypes.TakeScreenshot) {
|
if (options.text === ImageTypes.TakeScreenshot) {
|
||||||
try {
|
try {
|
||||||
|
@ -52,28 +52,29 @@ exports[`PublishNotebookPaneComponent renders 1`] = `
|
|||||||
<StackItem>
|
<StackItem>
|
||||||
<StyledWithResponsiveMode
|
<StyledWithResponsiveMode
|
||||||
ariaLabel="Cover image"
|
ariaLabel="Cover image"
|
||||||
defaultSelectedKey="URL"
|
defaultSelectedKey="Custom Image"
|
||||||
label="Cover image"
|
label="Cover image"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
options={
|
options={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
|
||||||
"key": "URL",
|
|
||||||
"text": "URL",
|
|
||||||
},
|
|
||||||
Object {
|
Object {
|
||||||
"key": "Custom Image",
|
"key": "Custom Image",
|
||||||
"text": "Custom Image",
|
"text": "Custom Image",
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"key": "URL",
|
||||||
|
"text": "URL",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
<StyledTextFieldBase
|
<input
|
||||||
ariaLabel="Cover image url"
|
accept="image/*"
|
||||||
label="Cover image url"
|
id="selectImageFile"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
|
type="file"
|
||||||
/>
|
/>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
<StackItem>
|
<StackItem>
|
||||||
|
Loading…
Reference in New Issue
Block a user