diff --git a/src/Explorer/Panes/GenericRightPaneComponent.tsx b/src/Explorer/Panes/GenericRightPaneComponent.tsx index 30f278349..b3db7c358 100644 --- a/src/Explorer/Panes/GenericRightPaneComponent.tsx +++ b/src/Explorer/Panes/GenericRightPaneComponent.tsx @@ -16,7 +16,7 @@ export interface GenericRightPaneProps { onSubmit: () => void; submitButtonText: string; title: string; - isSubmitButtonVisible?: boolean; + isSubmitButtonHidden?: boolean; } export interface GenericRightPaneState { @@ -108,7 +108,7 @@ export class GenericRightPaneComponent extends React.Component
this.close(), onSubmit: () => this.submit(), - isSubmitButtonVisible: this.isCodeOfConductAccepted + isSubmitButtonHidden: !this.isCodeOfConductAccepted }; const publishNotebookPaneProps: PublishNotebookPaneProps = { diff --git a/src/Explorer/Panes/PublishNotebookPaneComponent.tsx b/src/Explorer/Panes/PublishNotebookPaneComponent.tsx index 986b42e2e..1980e7a77 100644 --- a/src/Explorer/Panes/PublishNotebookPaneComponent.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneComponent.tsx @@ -285,7 +285,7 @@ export class PublishNotebookPaneComponent extends React.Component this.close(), diff --git a/src/Explorer/Tabs/NotebookV2Tab.ts b/src/Explorer/Tabs/NotebookV2Tab.ts index 5f3de274b..e369bc7be 100644 --- a/src/Explorer/Tabs/NotebookV2Tab.ts +++ b/src/Explorer/Tabs/NotebookV2Tab.ts @@ -147,6 +147,30 @@ export default class NotebookTabV2 extends TabsBase { const cellCodeType = "code"; const cellMarkdownType = "markdown"; const cellRawType = "raw"; + + const saveButtonChildren = []; + if (this.container.notebookManager?.gitHubOAuthService.isLoggedIn()) { + saveButtonChildren.push({ + iconName: "Copy", + onCommandClick: () => this.copyNotebook(), + commandButtonLabel: copyToLabel, + hasPopup: false, + disabled: false, + ariaLabel: copyToLabel + }); + } + + if (this.container.isGalleryPublishEnabled()) { + saveButtonChildren.push({ + iconName: "PublishContent", + onCommandClick: async () => await this.publishToGallery(), + commandButtonLabel: publishLabel, + hasPopup: false, + disabled: false, + ariaLabel: publishLabel + }); + } + let buttons: CommandButtonComponentProps[] = [ { iconSrc: SaveIcon, @@ -156,34 +180,17 @@ export default class NotebookTabV2 extends TabsBase { hasPopup: false, disabled: false, ariaLabel: saveLabel, - children: this.container.isGalleryPublishEnabled() - ? [ - { - iconName: "Save", - onCommandClick: () => this.notebookComponentAdapter.notebookSave(), - commandButtonLabel: saveLabel, - hasPopup: false, - disabled: false, - ariaLabel: saveLabel - }, - { - iconName: "Copy", - onCommandClick: () => this.copyNotebook(), - commandButtonLabel: copyToLabel, - hasPopup: false, - disabled: false, - ariaLabel: copyToLabel - }, - { - iconName: "PublishContent", - onCommandClick: async () => await this.publishToGallery(), - commandButtonLabel: publishLabel, - hasPopup: false, - disabled: false, - ariaLabel: publishLabel - } - ] - : undefined + children: saveButtonChildren.length && [ + { + iconName: "Save", + onCommandClick: () => this.notebookComponentAdapter.notebookSave(), + commandButtonLabel: saveLabel, + hasPopup: false, + disabled: false, + ariaLabel: saveLabel + }, + ...saveButtonChildren + ] }, { iconSrc: null, diff --git a/src/Explorer/Tree/ResourceTreeAdapter.tsx b/src/Explorer/Tree/ResourceTreeAdapter.tsx index 2564a4930..7f9d8d6d5 100644 --- a/src/Explorer/Tree/ResourceTreeAdapter.tsx +++ b/src/Explorer/Tree/ResourceTreeAdapter.tsx @@ -546,43 +546,52 @@ export class ResourceTreeAdapter implements ReactAdapter { (activeTab as any).notebookPath() === item.path ); }, - contextMenu: createFileContextMenu - ? [ - { - label: "Rename", - iconSrc: NotebookIcon, - onClick: () => this.container.renameNotebook(item) - }, - { - label: "Delete", - iconSrc: DeleteIcon, - onClick: () => { - this.container.showOkCancelModalDialog( - "Confirm delete", - `Are you sure you want to delete "${item.name}"`, - "Delete", - () => this.container.deleteNotebookFile(item).then(() => this.triggerRender()), - "Cancel", - undefined - ); - } - }, - { - label: "Copy to ...", - iconSrc: CopyIcon, - onClick: () => this.copyNotebook(item) - }, - { - label: "Download", - iconSrc: NotebookIcon, - onClick: () => this.container.downloadFile(item) - } - ] - : undefined, + contextMenu: createFileContextMenu && this.createFileContextMenu(item), data: item }; } + private createFileContextMenu(item: NotebookContentItem): TreeNodeMenuItem[] { + let items: TreeNodeMenuItem[] = [ + { + label: "Rename", + iconSrc: NotebookIcon, + onClick: () => this.container.renameNotebook(item) + }, + { + label: "Delete", + iconSrc: DeleteIcon, + onClick: () => { + this.container.showOkCancelModalDialog( + "Confirm delete", + `Are you sure you want to delete "${item.name}"`, + "Delete", + () => this.container.deleteNotebookFile(item).then(() => this.triggerRender()), + "Cancel", + undefined + ); + } + }, + { + label: "Copy to ...", + iconSrc: CopyIcon, + onClick: () => this.copyNotebook(item) + }, + { + label: "Download", + iconSrc: NotebookIcon, + onClick: () => this.container.downloadFile(item) + } + ]; + + // "Copy to ..." isn't needed if github locations are not available + if (!this.container.notebookManager?.gitHubOAuthService.isLoggedIn()) { + items = items.filter(item => item.label !== "Copy to ..."); + } + + return items; + } + private copyNotebook = async (item: NotebookContentItem) => { const content = await this.container.readFile(item); if (content) {