diff --git a/configs/mpac.json b/configs/mpac.json index dd9a572a1..e06baa8ec 100644 --- a/configs/mpac.json +++ b/configs/mpac.json @@ -1,3 +1,4 @@ { - "JUNO_ENDPOINT": "https://tools-staging.cosmos.azure.com" + "JUNO_ENDPOINT": "https://tools-staging.cosmos.azure.com", + "ENABLE_GALLERY_PUBLISH": true } diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index 18a1f1fa0..39bf29003 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -26,6 +26,7 @@ export interface ConfigContext { GITHUB_CLIENT_SECRET?: string; // No need to inject secret for prod. Juno already knows it. hostedExplorerURL: string; armAPIVersion?: string; + ENABLE_GALLERY_PUBLISH?: boolean; } // Default configuration diff --git a/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponent.tsx b/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponent.tsx index 3e2b5f605..6a3d3280e 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryAndNotebookViewerComponent.tsx @@ -7,6 +7,7 @@ import Explorer from "../../Explorer"; export interface GalleryAndNotebookViewerComponentProps { container?: Explorer; + isGalleryPublishEnabled: boolean; junoClient: JunoClient; notebookUrl?: string; galleryItem?: IGalleryItem; @@ -60,6 +61,7 @@ export class GalleryAndNotebookViewerComponent extends React.Component< const props: GalleryViewerComponentProps = { container: this.props.container, + isGalleryPublishEnabled: this.props.isGalleryPublishEnabled, junoClient: this.props.junoClient, selectedTab: this.state.selectedTab, sortBy: this.state.sortBy, diff --git a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.test.tsx b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.test.tsx index d5e2adecf..a290428b2 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.test.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.test.tsx @@ -5,6 +5,7 @@ import { GalleryViewerComponent, GalleryViewerComponentProps, GalleryTab, SortBy describe("GalleryViewerComponent", () => { it("renders", () => { const props: GalleryViewerComponentProps = { + isGalleryPublishEnabled: false, junoClient: undefined, selectedTab: GalleryTab.OfficialSamples, sortBy: SortBy.MostViewed, diff --git a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx index 2233ffc3c..f4035b9ad 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx @@ -34,6 +34,7 @@ import { Action } from "../../../Shared/Telemetry/TelemetryConstants"; export interface GalleryViewerComponentProps { container?: Explorer; + isGalleryPublishEnabled: boolean; junoClient: JunoClient; selectedTab: GalleryTab; sortBy: SortBy; @@ -151,7 +152,7 @@ export class GalleryViewerComponent extends React.Component - {(!this.props.container || this.props.container.isGalleryPublishEnabled()) && ( + {this.props.isGalleryPublishEnabled && ( diff --git a/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap b/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap index 17ae29657..760df58ea 100644 --- a/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap +++ b/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap @@ -77,9 +77,6 @@ exports[`GalleryViewerComponent renders 1`] = ` selectedKey={0} /> - - - (false); this.shouldShowDataAccessExpiryDialog = ko.observable(false); this.shouldShowContextSwitchPrompt = ko.observable(false); - this.isGalleryPublishEnabled = ko.computed(() => - this.isFeatureEnabled(Constants.Features.enableGalleryPublish) + this.isGalleryPublishEnabled = ko.computed( + () => configContext.ENABLE_GALLERY_PUBLISH || this.isFeatureEnabled(Constants.Features.enableGalleryPublish) ); this.isLinkInjectionEnabled = ko.computed(() => this.isFeatureEnabled(Constants.Features.enableLinkInjection) diff --git a/src/Explorer/Tabs/GalleryTab.tsx b/src/Explorer/Tabs/GalleryTab.tsx index a2e23fa7f..3e16092ce 100644 --- a/src/Explorer/Tabs/GalleryTab.tsx +++ b/src/Explorer/Tabs/GalleryTab.tsx @@ -31,6 +31,7 @@ export default class GalleryTab extends TabsBase { this.galleryAndNotebookViewerComponentProps = { container: options.container, + isGalleryPublishEnabled: options.container.isGalleryPublishEnabled(), junoClient: options.junoClient, notebookUrl: options.notebookUrl, galleryItem: options.galleryItem, diff --git a/src/GalleryViewer/GalleryViewer.tsx b/src/GalleryViewer/GalleryViewer.tsx index f8993ff30..1eb18c538 100644 --- a/src/GalleryViewer/GalleryViewer.tsx +++ b/src/GalleryViewer/GalleryViewer.tsx @@ -3,7 +3,7 @@ import { initializeIcons } from "office-ui-fabric-react/lib/Icons"; import { Text, Link } from "office-ui-fabric-react"; import * as React from "react"; import * as ReactDOM from "react-dom"; -import { initializeConfiguration } from "../ConfigContext"; +import { configContext, initializeConfiguration } from "../ConfigContext"; import { GalleryHeaderComponent } from "../Explorer/Controls/Header/GalleryHeaderComponent"; import { GalleryAndNotebookViewerComponent, @@ -24,6 +24,7 @@ const onInit = async () => { const galleryViewerProps = GalleryUtils.getGalleryViewerProps(window.location.search); const props: GalleryAndNotebookViewerComponentProps = { + isGalleryPublishEnabled: configContext.ENABLE_GALLERY_PUBLISH, junoClient: new JunoClient(), selectedTab: galleryViewerProps.selectedTab || GalleryTab.OfficialSamples, sortBy: galleryViewerProps.sortBy || SortBy.MostViewed,