From cf01ffa9575f6c291da05ac3e802ede1c26bcb00 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Fri, 26 Feb 2021 13:07:44 -0800 Subject: [PATCH] removed enableGalleryPublish, enableLinkInjection feature flags (#454) * removed enableGalleryPublish, enableLinkInjection * removed ENABLE_GALLERY_PUBLISH --- configs/mpac.json | 3 +- src/Common/Constants.ts | 3 - src/ConfigContext.ts | 1 - .../FeaturePanel/FeaturePanelComponent.tsx | 6 - .../FeaturePanelComponent.test.tsx.snap | 16 +-- .../GalleryAndNotebookViewerComponent.tsx | 2 - .../GalleryViewerComponent.test.tsx | 1 - .../GalleryViewerComponent.tsx | 50 +++---- .../GalleryViewerComponent.test.tsx.snap | 123 ++++++++++++++++++ .../SettingsComponent.test.tsx.snap | 8 -- src/Explorer/Explorer.tsx | 18 +-- .../CommandBarComponentButtonFactory.test.ts | 5 - src/Explorer/Notebook/NotebookManager.ts | 9 +- .../Panes/PublishNotebookPaneAdapter.tsx | 9 +- src/Explorer/Tabs/GalleryTab.tsx | 1 - src/Explorer/Tabs/NotebookV2Tab.ts | 18 ++- src/Explorer/Tree/ResourceTreeAdapter.tsx | 2 +- src/GalleryViewer/GalleryViewer.tsx | 1 - src/Juno/JunoClient.test.ts | 12 +- src/Juno/JunoClient.ts | 5 +- 20 files changed, 163 insertions(+), 130 deletions(-) diff --git a/configs/mpac.json b/configs/mpac.json index e06baa8ec..dd9a572a1 100644 --- a/configs/mpac.json +++ b/configs/mpac.json @@ -1,4 +1,3 @@ { - "JUNO_ENDPOINT": "https://tools-staging.cosmos.azure.com", - "ENABLE_GALLERY_PUBLISH": true + "JUNO_ENDPOINT": "https://tools-staging.cosmos.azure.com" } diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index a3ce1d6c6..2f831b77e 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -105,8 +105,6 @@ export class Features { public static readonly hostedDataExplorer = "hosteddataexplorerenabled"; public static readonly enableTtl = "enablettl"; public static readonly enableNotebooks = "enablenotebooks"; - public static readonly enableGalleryPublish = "enablegallerypublish"; - public static readonly enableLinkInjection = "enablelinkinjection"; public static readonly enableSpark = "enablespark"; public static readonly livyEndpoint = "livyendpoint"; public static readonly notebookServerUrl = "notebookserverurl"; @@ -130,7 +128,6 @@ export class Flights { public static readonly MongoIndexEditor = "mongoindexeditor"; public static readonly MongoIndexing = "mongoindexing"; public static readonly AutoscaleTest = "autoscaletest"; - public static readonly GalleryPublish = "gallerypublish"; } export class AfecFeatures { diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index 66cc14d00..654928c6b 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -26,7 +26,6 @@ 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/FeaturePanel/FeaturePanelComponent.tsx b/src/Explorer/Controls/FeaturePanel/FeaturePanelComponent.tsx index 2a1c38117..977e47ac6 100644 --- a/src/Explorer/Controls/FeaturePanel/FeaturePanelComponent.tsx +++ b/src/Explorer/Controls/FeaturePanel/FeaturePanelComponent.tsx @@ -47,13 +47,7 @@ export const FeaturePanelComponent: React.FunctionComponent = () => { { key: "feature.dataexplorerexecutesproc", label: "Execute stored procedure", value: "true" }, { key: "feature.hosteddataexplorerenabled", label: "Hosted Data Explorer (deprecated?)", value: "true" }, { key: "feature.enablettl", label: "Enable TTL", value: "true" }, - { key: "feature.enablegallerypublish", label: "Enable Notebook Gallery Publishing", value: "true" }, { key: "feature.selfServeType", label: "Self serve feature", value: "sample" }, - { - key: "feature.enableLinkInjection", - label: "Enable Injecting Notebook Viewer Link into the first cell", - value: "true", - }, { key: "feature.canexceedmaximumvalue", label: "Can exceed max value", value: "true" }, { key: "feature.enablefixedcollectionwithsharedthroughput", diff --git a/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap b/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap index b96478515..9e54966e5 100644 --- a/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap +++ b/src/Explorer/Controls/FeaturePanel/__snapshots__/FeaturePanelComponent.test.tsx.snap @@ -149,12 +149,6 @@ exports[`Feature panel renders all flags 1`] = ` label="Enable TTL" onChange={[Function]} /> - @@ -172,12 +166,6 @@ exports[`Feature panel renders all flags 1`] = ` className="checkboxRow" horizontalAlign="space-between" > - { 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 67e59b3d2..4b744d2a9 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx @@ -36,7 +36,6 @@ import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryCons export interface GalleryViewerComponentProps { container?: Explorer; - isGalleryPublishEnabled: boolean; junoClient: JunoClient; selectedTab: GalleryTab; sortBy: SortBy; @@ -140,17 +139,13 @@ export class GalleryViewerComponent extends React.Component - {this.props.isGalleryPublishEnabled && ( - - - - )} + + + {content} @@ -664,10 +653,7 @@ export class GalleryViewerComponent extends React.Component { - let isFavorite: boolean; - if (this.props.container?.isGalleryPublishEnabled()) { - isFavorite = this.favoriteNotebooks?.find((item) => item.id === data.id) !== undefined; - } + const isFavorite = this.favoriteNotebooks?.find((item) => item.id === data.id) !== undefined; const props: GalleryCardComponentProps = { data, isFavorite, diff --git a/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap b/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap index 3e79102ec..56ebdcc57 100644 --- a/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap +++ b/src/Explorer/Controls/NotebookGallery/__snapshots__/GalleryViewerComponent.test.tsx.snap @@ -72,11 +72,18 @@ exports[`GalleryViewerComponent renders 1`] = ` "key": 3, "text": "Most recent", }, + Object { + "key": 2, + "text": "Most favorited", + }, ] } selectedKey={0} /> + + + + +
+ + + + + + + + Sort by + + + + + + + + + + + + + +
+
+ + + + + + `; diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 526fc74cc..f69b1afa2 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -925,11 +925,9 @@ exports[`SettingsComponent renders 1`] = ` "isCopyNotebookPaneEnabled": [Function], "isEnableMongoCapabilityPresent": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], - "isGalleryPublishEnabled": [Function], "isGitHubPaneEnabled": [Function], "isHostedDataExplorerEnabled": [Function], "isLeftPaneExpanded": [Function], - "isLinkInjectionEnabled": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -2143,11 +2141,9 @@ exports[`SettingsComponent renders 1`] = ` "isCopyNotebookPaneEnabled": [Function], "isEnableMongoCapabilityPresent": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], - "isGalleryPublishEnabled": [Function], "isGitHubPaneEnabled": [Function], "isHostedDataExplorerEnabled": [Function], "isLeftPaneExpanded": [Function], - "isLinkInjectionEnabled": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -3374,11 +3370,9 @@ exports[`SettingsComponent renders 1`] = ` "isCopyNotebookPaneEnabled": [Function], "isEnableMongoCapabilityPresent": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], - "isGalleryPublishEnabled": [Function], "isGitHubPaneEnabled": [Function], "isHostedDataExplorerEnabled": [Function], "isLeftPaneExpanded": [Function], - "isLinkInjectionEnabled": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], @@ -4592,11 +4586,9 @@ exports[`SettingsComponent renders 1`] = ` "isCopyNotebookPaneEnabled": [Function], "isEnableMongoCapabilityPresent": [Function], "isFixedCollectionWithSharedThroughputSupported": [Function], - "isGalleryPublishEnabled": [Function], "isGitHubPaneEnabled": [Function], "isHostedDataExplorerEnabled": [Function], "isLeftPaneExpanded": [Function], - "isLinkInjectionEnabled": [Function], "isMongoIndexingEnabled": [Function], "isNotebookEnabled": [Function], "isNotebooksEnabledForAccount": [Function], diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 60c72cfc7..bb9abe807 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -205,8 +205,6 @@ export default class Explorer { public copyNotebookPaneAdapter: ReactAdapter; // features - public isGalleryPublishEnabled: ko.Computed; - public isLinkInjectionEnabled: ko.Computed; public isGitHubPaneEnabled: ko.Observable; public isPublishNotebookPaneEnabled: ko.Observable; public isCopyNotebookPaneEnabled: ko.Observable; @@ -382,12 +380,6 @@ export default class Explorer { this.resourceTokenCollection = ko.observable(); this.resourceTokenPartitionKey = ko.observable(); this.isAuthWithResourceToken = ko.observable(false); - this.isGalleryPublishEnabled = ko.computed( - () => configContext.ENABLE_GALLERY_PUBLISH || this.isFeatureEnabled(Constants.Features.enableGalleryPublish) - ); - this.isLinkInjectionEnabled = ko.computed(() => - this.isFeatureEnabled(Constants.Features.enableLinkInjection) - ); this.isGitHubPaneEnabled = ko.observable(false); this.isMongoIndexingEnabled = ko.observable(false); this.isPublishNotebookPaneEnabled = ko.observable(false); @@ -1514,9 +1506,6 @@ export default class Explorer { if (flights.indexOf(Constants.Flights.MongoIndexing) !== -1) { this.isMongoIndexingEnabled(true); } - if (flights.indexOf(Constants.Flights.GalleryPublish) !== -1) { - this.isGalleryPublishEnabled = ko.computed(() => true); - } } public findSelectedCollection(): ViewModels.Collection { @@ -1802,12 +1791,7 @@ export default class Explorer { public async publishNotebook(name: string, content: string | unknown, parentDomElement?: HTMLElement): Promise { if (this.notebookManager) { - await this.notebookManager.openPublishNotebookPane( - name, - content, - parentDomElement, - this.isLinkInjectionEnabled() - ); + await this.notebookManager.openPublishNotebookPane(name, content, parentDomElement); this.publishNotebookPaneAdapter = this.notebookManager.publishNotebookPaneAdapter; this.isPublishNotebookPaneEnabled(true); } diff --git a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts index fe13a1d70..9bec8f9e9 100644 --- a/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts +++ b/src/Explorer/Menus/CommandBar/CommandBarComponentButtonFactory.test.ts @@ -19,7 +19,6 @@ describe("CommandBarComponentButtonFactory tests", () => { mockExplorer.isPreferredApiCassandra = ko.computed(() => false); mockExplorer.isSparkEnabled = ko.observable(true); mockExplorer.isSynapseLinkUpdating = ko.observable(false); - mockExplorer.isGalleryPublishEnabled = ko.computed(() => false); mockExplorer.isDatabaseNodeOrNoneSelected = () => true; mockExplorer.isNotebookEnabled = ko.observable(false); @@ -61,7 +60,6 @@ describe("CommandBarComponentButtonFactory tests", () => { mockExplorer.isSynapseLinkUpdating = ko.observable(false); mockExplorer.isSparkEnabled = ko.observable(true); mockExplorer.isSynapseLinkUpdating = ko.observable(false); - mockExplorer.isGalleryPublishEnabled = ko.computed(() => false); mockExplorer.isDatabaseNodeOrNoneSelected = () => true; mockExplorer.isServerlessEnabled = ko.computed(() => false); @@ -125,7 +123,6 @@ describe("CommandBarComponentButtonFactory tests", () => { mockExplorer.isPreferredApiCassandra = ko.computed(() => false); mockExplorer.isSparkEnabled = ko.observable(true); mockExplorer.isSynapseLinkUpdating = ko.observable(false); - mockExplorer.isGalleryPublishEnabled = ko.computed(() => false); mockExplorer.isDatabaseNodeOrNoneSelected = () => true; mockExplorer.isServerlessEnabled = ko.computed(() => false); @@ -207,7 +204,6 @@ describe("CommandBarComponentButtonFactory tests", () => { mockExplorer.isPreferredApiMongoDB = ko.computed(() => false); mockExplorer.isSynapseLinkUpdating = ko.observable(false); mockExplorer.isSparkEnabled = ko.observable(true); - mockExplorer.isGalleryPublishEnabled = ko.computed(() => false); mockExplorer.isDatabaseNodeOrNoneSelected = () => true; mockExplorer.isServerlessEnabled = ko.computed(() => false); @@ -295,7 +291,6 @@ describe("CommandBarComponentButtonFactory tests", () => { mockExplorer.isDatabaseNodeOrNoneSelected = () => true; mockExplorer.isNotebooksEnabledForAccount = ko.observable(false); mockExplorer.isRunningOnNationalCloud = ko.observable(false); - mockExplorer.isGalleryPublishEnabled = ko.computed(() => false); mockExplorer.notebookManager = new NotebookManager(); mockExplorer.notebookManager.gitHubOAuthService = new GitHubOAuthService(undefined); mockExplorer.isServerlessEnabled = ko.computed(() => false); diff --git a/src/Explorer/Notebook/NotebookManager.ts b/src/Explorer/Notebook/NotebookManager.ts index ce482d9ef..16cfa65a3 100644 --- a/src/Explorer/Notebook/NotebookManager.ts +++ b/src/Explorer/Notebook/NotebookManager.ts @@ -87,9 +87,7 @@ export default class NotebookManager { this.notebookContentProvider ); - if (this.params.container.isGalleryPublishEnabled()) { - this.publishNotebookPaneAdapter = new PublishNotebookPaneAdapter(this.params.container, this.junoClient); - } + this.publishNotebookPaneAdapter = new PublishNotebookPaneAdapter(this.params.container, this.junoClient); this.copyNotebookPaneAdapter = new CopyNotebookPaneAdapter( this.params.container, @@ -125,10 +123,9 @@ export default class NotebookManager { public async openPublishNotebookPane( name: string, content: string | ImmutableNotebook, - parentDomElement: HTMLElement, - isLinkInjectionEnabled: boolean + parentDomElement: HTMLElement ): Promise { - await this.publishNotebookPaneAdapter.open(name, getFullName(), content, parentDomElement, isLinkInjectionEnabled); + await this.publishNotebookPaneAdapter.open(name, getFullName(), content, parentDomElement); } public openCopyNotebookPane(name: string, content: string): void { diff --git a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx index 5c1313020..b7c230c88 100644 --- a/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx +++ b/src/Explorer/Panes/PublishNotebookPaneAdapter.tsx @@ -32,7 +32,6 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { private notebookObject: ImmutableNotebook; private parentDomElement: HTMLElement; private isCodeOfConductAccepted: boolean; - private isLinkInjectionEnabled: boolean; constructor(private container: Explorer, private junoClient: JunoClient) { this.parameters = ko.observable(Date.now()); @@ -101,8 +100,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { name: string, author: string, notebookContent: string | ImmutableNotebook, - parentDomElement: HTMLElement, - isLinkInjectionEnabled: boolean + parentDomElement: HTMLElement ): Promise { try { const response = await this.junoClient.isCodeOfConductAccepted(); @@ -130,7 +128,6 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { this.parentDomElement = parentDomElement; this.isOpened = true; - this.isLinkInjectionEnabled = isLinkInjectionEnabled; this.triggerRender(); } @@ -166,8 +163,7 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { this.tags?.split(","), this.author, this.imageSrc, - this.content, - this.isLinkInjectionEnabled + this.content ); const data = response.data; @@ -248,6 +244,5 @@ export class PublishNotebookPaneAdapter implements ReactAdapter { this.notebookObject = undefined; this.parentDomElement = undefined; this.isCodeOfConductAccepted = undefined; - this.isLinkInjectionEnabled = undefined; }; } diff --git a/src/Explorer/Tabs/GalleryTab.tsx b/src/Explorer/Tabs/GalleryTab.tsx index 7597d8578..d776a50a7 100644 --- a/src/Explorer/Tabs/GalleryTab.tsx +++ b/src/Explorer/Tabs/GalleryTab.tsx @@ -31,7 +31,6 @@ 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/Explorer/Tabs/NotebookV2Tab.ts b/src/Explorer/Tabs/NotebookV2Tab.ts index 690302def..00764f943 100644 --- a/src/Explorer/Tabs/NotebookV2Tab.ts +++ b/src/Explorer/Tabs/NotebookV2Tab.ts @@ -162,16 +162,14 @@ export default class NotebookTabV2 extends TabsBase { }); } - if (this.container.isGalleryPublishEnabled()) { - saveButtonChildren.push({ - iconName: "PublishContent", - onCommandClick: async () => await this.publishToGallery(), - commandButtonLabel: publishLabel, - hasPopup: false, - disabled: false, - ariaLabel: publishLabel, - }); - } + saveButtonChildren.push({ + iconName: "PublishContent", + onCommandClick: async () => await this.publishToGallery(), + commandButtonLabel: publishLabel, + hasPopup: false, + disabled: false, + ariaLabel: publishLabel, + }); let buttons: CommandButtonComponentProps[] = [ { diff --git a/src/Explorer/Tree/ResourceTreeAdapter.tsx b/src/Explorer/Tree/ResourceTreeAdapter.tsx index 021b9400d..3f07f0b71 100644 --- a/src/Explorer/Tree/ResourceTreeAdapter.tsx +++ b/src/Explorer/Tree/ResourceTreeAdapter.tsx @@ -717,7 +717,7 @@ export class ResourceTreeAdapter implements ReactAdapter { }, ]; - if (this.container.isGalleryPublishEnabled() && item.type === NotebookContentItemType.Notebook) { + if (item.type === NotebookContentItemType.Notebook) { items.push({ label: "Publish to gallery", iconSrc: PublishIcon, diff --git a/src/GalleryViewer/GalleryViewer.tsx b/src/GalleryViewer/GalleryViewer.tsx index 1a49c22cf..c9fe954de 100644 --- a/src/GalleryViewer/GalleryViewer.tsx +++ b/src/GalleryViewer/GalleryViewer.tsx @@ -25,7 +25,6 @@ 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, diff --git a/src/Juno/JunoClient.test.ts b/src/Juno/JunoClient.test.ts index 155a12b7f..8950e18f4 100644 --- a/src/Juno/JunoClient.test.ts +++ b/src/Juno/JunoClient.test.ts @@ -354,21 +354,13 @@ describe("Gallery", () => { const author = "author"; const thumbnailUrl = "thumbnailUrl"; const content = `{ "key": "value" }`; - const addLinkToNotebookViewer = false; + const addLinkToNotebookViewer = true; window.fetch = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, json: () => undefined as any, }); - const response = await junoClient.publishNotebook( - name, - description, - tags, - author, - thumbnailUrl, - content, - addLinkToNotebookViewer - ); + const response = await junoClient.publishNotebook(name, description, tags, author, thumbnailUrl, content); const authorizationHeader = getAuthorizationHeader(); expect(response.status).toBe(HttpStatusCodes.OK); diff --git a/src/Juno/JunoClient.ts b/src/Juno/JunoClient.ts index 7c08fad4e..751b40fe7 100644 --- a/src/Juno/JunoClient.ts +++ b/src/Juno/JunoClient.ts @@ -362,8 +362,7 @@ export class JunoClient { tags: string[], author: string, thumbnailUrl: string, - content: string, - isLinkInjectionEnabled: boolean + content: string ): Promise> { const response = await window.fetch(`${this.getNotebooksSubscriptionIdAccountUrl()}/gallery`, { method: "PUT", @@ -375,7 +374,7 @@ export class JunoClient { author, thumbnailUrl, content: JSON.parse(content), - addLinkToNotebookViewer: isLinkInjectionEnabled, + addLinkToNotebookViewer: true, } as IPublishNotebookRequest), });