Added publicgallery flight (#1262)

* added publicgallery flag

* fixed PR comments
This commit is contained in:
Srinath Narayanan 2022-05-04 03:50:44 +05:30 committed by GitHub
parent 27423e2321
commit da1169d0e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 107 deletions

View File

@ -99,6 +99,7 @@ export class Flights {
public static readonly PhoenixNotebooks = "phoenixnotebooks"; public static readonly PhoenixNotebooks = "phoenixnotebooks";
public static readonly PhoenixFeatures = "phoenixfeatures"; public static readonly PhoenixFeatures = "phoenixfeatures";
public static readonly NotebooksDownBanner = "notebooksdownbanner"; public static readonly NotebooksDownBanner = "notebooksdownbanner";
public static readonly PublicGallery = "publicgallery";
} }
export class AfecFeatures { export class AfecFeatures {

View File

@ -21,6 +21,7 @@ import {
Text, Text,
} from "@fluentui/react"; } from "@fluentui/react";
import * as React from "react"; import * as React from "react";
import { userContext } from "UserContext";
import { HttpStatusCodes } from "../../../Common/Constants"; import { HttpStatusCodes } from "../../../Common/Constants";
import { handleError } from "../../../Common/ErrorHandlingUtils"; import { handleError } from "../../../Common/ErrorHandlingUtils";
import { IGalleryItem, IJunoResponse, IPublicGalleryData, JunoClient } from "../../../Juno/JunoClient"; import { IGalleryItem, IJunoResponse, IPublicGalleryData, JunoClient } from "../../../Juno/JunoClient";
@ -148,19 +149,24 @@ export class GalleryViewerComponent extends React.Component<GalleryViewerCompone
public render(): JSX.Element { public render(): JSX.Element {
this.traceViewGallery(); this.traceViewGallery();
const tabs: GalleryTabInfo[] = [ const tabs: GalleryTabInfo[] = [];
if (userContext.features.publicGallery) {
tabs.push(
this.createPublicGalleryTab( this.createPublicGalleryTab(
GalleryTab.PublicGallery, GalleryTab.PublicGallery,
this.state.publicNotebooks, this.state.publicNotebooks,
this.state.isCodeOfConductAccepted this.state.isCodeOfConductAccepted
), )
this.createSamplesTab(GalleryTab.OfficialSamples, this.state.sampleNotebooks), );
]; }
tabs.push(this.createSamplesTab(GalleryTab.OfficialSamples, this.state.sampleNotebooks));
if (this.props.container) { if (this.props.container) {
tabs.push(this.createFavoritesTab(GalleryTab.Favorites, this.state.favoriteNotebooks)); tabs.push(this.createFavoritesTab(GalleryTab.Favorites, this.state.favoriteNotebooks));
if (userContext.features.publicGallery) {
tabs.push(this.createPublishedNotebooksTab(GalleryTab.Published, this.state.publishedNotebooks)); tabs.push(this.createPublishedNotebooksTab(GalleryTab.Published, this.state.publishedNotebooks));
} }
}
const pivotProps: IPivotProps = { const pivotProps: IPivotProps = {
onLinkClick: this.onPivotChange, onLinkClick: this.onPivotChange,

View File

@ -8,95 +8,6 @@ exports[`GalleryViewerComponent renders 1`] = `
onLinkClick={[Function]} onLinkClick={[Function]}
selectedKey="OfficialSamples" selectedKey="OfficialSamples"
> >
<PivotItem
headerText="Public gallery"
itemKey="PublicGallery"
key="PublicGallery"
style={
Object {
"marginTop": 20,
}
}
>
<div
className="publicGalleryTabContainer"
>
<Stack
tokens={
Object {
"childrenGap": 10,
}
}
>
<Stack
horizontal={true}
tokens={
Object {
"childrenGap": 20,
"padding": 10,
}
}
wrap={true}
>
<StackItem
grow={true}
>
<StyledSearchBox
onChange={[Function]}
placeholder="Search"
/>
</StackItem>
<StackItem>
<StyledLabelBase>
Sort by
</StyledLabelBase>
</StackItem>
<StackItem
styles={
Object {
"root": Object {
"minWidth": 200,
},
}
}
>
<Dropdown
onChange={[Function]}
options={
Array [
Object {
"key": 0,
"text": "Most viewed",
},
Object {
"key": 1,
"text": "Most downloaded",
},
Object {
"key": 3,
"text": "Most recent",
},
Object {
"key": 2,
"text": "Most favorited",
},
]
}
selectedKey={0}
/>
</StackItem>
<StackItem>
<InfoComponent />
</StackItem>
</Stack>
<StackItem>
<StyledSpinnerBase
size={3}
/>
</StackItem>
</Stack>
</div>
</PivotItem>
<PivotItem <PivotItem
headerText="Official samples" headerText="Official samples"
itemKey="OfficialSamples" itemKey="OfficialSamples"

View File

@ -1,6 +1,7 @@
import { stringifyNotebook, toJS } from "@nteract/commutable"; import { stringifyNotebook, toJS } from "@nteract/commutable";
import * as ko from "knockout"; import * as ko from "knockout";
import * as Q from "q"; import * as Q from "q";
import { userContext } from "UserContext";
import ClearAllOutputsIcon from "../../../images/notebook/Notebook-clear-all-outputs.svg"; import ClearAllOutputsIcon from "../../../images/notebook/Notebook-clear-all-outputs.svg";
import CopyIcon from "../../../images/notebook/Notebook-copy.svg"; import CopyIcon from "../../../images/notebook/Notebook-copy.svg";
import CutIcon from "../../../images/notebook/Notebook-cut.svg"; import CutIcon from "../../../images/notebook/Notebook-cut.svg";
@ -129,6 +130,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
}); });
} }
if (userContext.features.publicGallery) {
saveButtonChildren.push({ saveButtonChildren.push({
iconName: "PublishContent", iconName: "PublishContent",
onCommandClick: async () => await this.publishToGallery(), onCommandClick: async () => await this.publishToGallery(),
@ -137,6 +139,7 @@ export default class NotebookTabV2 extends NotebookTabBase {
disabled: false, disabled: false,
ariaLabel: publishLabel, ariaLabel: publishLabel,
}); });
}
let buttons: CommandButtonComponentProps[] = [ let buttons: CommandButtonComponentProps[] = [
{ {

View File

@ -299,7 +299,7 @@ export const ResourceTree: React.FC<ResourceTreeProps> = ({ container }: Resourc
}, },
]; ];
if (item.type === NotebookContentItemType.Notebook) { if (item.type === NotebookContentItemType.Notebook && userContext.features.publicGallery) {
items.push({ items.push({
label: "Publish to gallery", label: "Publish to gallery",
iconSrc: PublishIcon, iconSrc: PublishIcon,

View File

@ -38,6 +38,7 @@ export type Features = {
phoenixNotebooks?: boolean; phoenixNotebooks?: boolean;
phoenixFeatures?: boolean; phoenixFeatures?: boolean;
notebooksDownBanner: boolean; notebooksDownBanner: boolean;
publicGallery?: boolean;
}; };
export function extractFeatures(given = new URLSearchParams(window.location.search)): Features { export function extractFeatures(given = new URLSearchParams(window.location.search)): Features {

View File

@ -378,6 +378,9 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
if (inputs.flights.indexOf(Flights.NotebooksDownBanner) !== -1) { if (inputs.flights.indexOf(Flights.NotebooksDownBanner) !== -1) {
userContext.features.notebooksDownBanner = true; userContext.features.notebooksDownBanner = true;
} }
if (inputs.flights.indexOf(Flights.PublicGallery) !== -1) {
userContext.features.publicGallery = true;
}
} }
} }