From da1169d0e23a3db5f825f73289cd0553a9cda6b6 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Wed, 4 May 2022 03:50:44 +0530 Subject: [PATCH] Added publicgallery flight (#1262) * added publicgallery flag * fixed PR comments --- src/Common/Constants.ts | 1 + .../GalleryViewerComponent.tsx | 24 +++-- .../GalleryViewerComponent.test.tsx.snap | 89 ------------------- src/Explorer/Tabs/NotebookV2Tab.ts | 19 ++-- src/Explorer/Tree/ResourceTree.tsx | 2 +- src/Platform/Hosted/extractFeatures.ts | 1 + src/hooks/useKnockoutExplorer.ts | 3 + 7 files changed, 32 insertions(+), 107 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index e40977ded..537685a2c 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -99,6 +99,7 @@ export class Flights { public static readonly PhoenixNotebooks = "phoenixnotebooks"; public static readonly PhoenixFeatures = "phoenixfeatures"; public static readonly NotebooksDownBanner = "notebooksdownbanner"; + public static readonly PublicGallery = "publicgallery"; } export class AfecFeatures { diff --git a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx index 4dc772481..07b73c0e6 100644 --- a/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx +++ b/src/Explorer/Controls/NotebookGallery/GalleryViewerComponent.tsx @@ -21,6 +21,7 @@ import { Text, } from "@fluentui/react"; import * as React from "react"; +import { userContext } from "UserContext"; import { HttpStatusCodes } from "../../../Common/Constants"; import { handleError } from "../../../Common/ErrorHandlingUtils"; import { IGalleryItem, IJunoResponse, IPublicGalleryData, JunoClient } from "../../../Juno/JunoClient"; @@ -148,18 +149,23 @@ export class GalleryViewerComponent extends React.Component - -
- - - - - - - - Sort by - - - - - - - - - - - - - -
-
await this.publishToGallery(), - commandButtonLabel: publishLabel, - hasPopup: false, - disabled: false, - ariaLabel: publishLabel, - }); + if (userContext.features.publicGallery) { + 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/ResourceTree.tsx b/src/Explorer/Tree/ResourceTree.tsx index 181fd07d6..dd8c3c9c6 100644 --- a/src/Explorer/Tree/ResourceTree.tsx +++ b/src/Explorer/Tree/ResourceTree.tsx @@ -299,7 +299,7 @@ export const ResourceTree: React.FC = ({ container }: Resourc }, ]; - if (item.type === NotebookContentItemType.Notebook) { + if (item.type === NotebookContentItemType.Notebook && userContext.features.publicGallery) { items.push({ label: "Publish to gallery", iconSrc: PublishIcon, diff --git a/src/Platform/Hosted/extractFeatures.ts b/src/Platform/Hosted/extractFeatures.ts index 6489068f0..8d6a763cc 100644 --- a/src/Platform/Hosted/extractFeatures.ts +++ b/src/Platform/Hosted/extractFeatures.ts @@ -38,6 +38,7 @@ export type Features = { phoenixNotebooks?: boolean; phoenixFeatures?: boolean; notebooksDownBanner: boolean; + publicGallery?: boolean; }; export function extractFeatures(given = new URLSearchParams(window.location.search)): Features { diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index de019e599..7a0330ff3 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -378,6 +378,9 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) { if (inputs.flights.indexOf(Flights.NotebooksDownBanner) !== -1) { userContext.features.notebooksDownBanner = true; } + if (inputs.flights.indexOf(Flights.PublicGallery) !== -1) { + userContext.features.publicGallery = true; + } } }