import { DefaultButton, Icon, IconButton, Image, IPivotItemProps, Pivot, PivotItem, PrimaryButton, Stack, Text, TextField, } from "@fluentui/react"; import { distributeTableCommand, distributeTableCommandForDisplay, loadDataCommand, loadDataCommandForDisplay, newTableCommand, newTableCommandForDisplay, queryCommand, queryCommandForDisplay, } from "Explorer/Quickstart/PostgreQuickstartCommands"; import { useTerminal } from "hooks/useTerminal"; import React, { useState } from "react"; import Youtube from "react-youtube"; import Pivot1SelectedIcon from "../../../images/Pivot1_selected.svg"; import Pivot2Icon from "../../../images/Pivot2.svg"; import Pivot2SelectedIcon from "../../../images/Pivot2_selected.svg"; import Pivot3Icon from "../../../images/Pivot3.svg"; import Pivot3SelectedIcon from "../../../images/Pivot3_selected.svg"; import Pivot4Icon from "../../../images/Pivot4.svg"; import Pivot4SelectedIcon from "../../../images/Pivot4_selected.svg"; import Pivot5Icon from "../../../images/Pivot5.svg"; import Pivot5SelectedIcon from "../../../images/Pivot5_selected.svg"; import CompleteIcon from "../../../images/QuickstartComplete.svg"; import { ReactTabKind, useTabs } from "../../hooks/useTabs"; enum GuideSteps { Login, NewTable, DistributeTable, LoadData, Query, } export const QuickstartGuide: React.FC = (): JSX.Element => { const [currentStep, setCurrentStep] = useState(0); const onCopyBtnClicked = (selector: string): void => { const textfield: HTMLInputElement = document.querySelector(selector); textfield.select(); document.execCommand("copy"); }; const getPivotHeaderIcon = (step: number): string => { switch (step) { case 0: return Pivot1SelectedIcon; case 1: return step === currentStep ? Pivot2SelectedIcon : Pivot2Icon; case 2: return step === currentStep ? Pivot3SelectedIcon : Pivot3Icon; case 3: return step === currentStep ? Pivot4SelectedIcon : Pivot4Icon; case 4: return step === currentStep ? Pivot5SelectedIcon : Pivot5Icon; default: return ""; } }; const customPivotHeaderRenderer = ( link: IPivotItemProps, defaultRenderer: (link?: IPivotItemProps) => JSX.Element | null, step: number ): JSX.Element | null => { if (!link || !defaultRenderer) { return null; } return ( {currentStep > step ? ( ) : ( )} {defaultRenderer({ ...link, itemIcon: undefined })} ); }; return ( Quick start guide Gettings started in Cosmos DB {currentStep < 5 && ( customPivotHeaderRenderer(props, defaultRenderer, 0)} itemKey={GuideSteps[0]} onClick={() => setCurrentStep(0)} > This tutorial guides you to create and query distributed tables using a sample dataset.

To begin, please enter the cluster's password in the PostgreSQL terminal.
customPivotHeaderRenderer(props, defaultRenderer, 1)} itemKey={GuideSteps[1]} onClick={() => setCurrentStep(1)} > Let’s create two tables github_users and github_events in “cosmosdb_tutorial” schema. useTerminal.getState().sendMessage(newTableCommand)} > Create new table onCopyBtnClicked("#newTableCommand")} /> customPivotHeaderRenderer(props, defaultRenderer, 2)} itemKey={GuideSteps[2]} onClick={() => setCurrentStep(2)} > Let’s distribute the two tables using the create_distributed_table() function.

We are choosing “user_id” as the distribution column for our sample dataset.
useTerminal.getState().sendMessage(distributeTableCommand)} > Create distributed table onCopyBtnClicked("#distributeTableCommand")} />
customPivotHeaderRenderer(props, defaultRenderer, 3)} itemKey={GuideSteps[3]} onClick={() => setCurrentStep(3)} > Let's load the two tables with a sample dataset generated from the GitHub API. useTerminal.getState().sendMessage(loadDataCommand)} > Load data onCopyBtnClicked("#loadDataCommand")} /> customPivotHeaderRenderer(props, defaultRenderer, 4)} itemKey={GuideSteps[4]} onClick={() => setCurrentStep(4)} > Congratulations on creating and distributing your tables. Now, it's time to run your first query! useTerminal.getState().sendMessage(queryCommand)} > Try queries onCopyBtnClicked("#queryCommand")} />
)} {currentStep === 5 && ( You are all set! You have completed the quick start guide.{" "} )}
setCurrentStep(currentStep - 1)}> Previous {currentStep < 5 && ( setCurrentStep(currentStep + 1)} style={{ marginLeft: 8 }}> Next )} {currentStep === 5 && ( useTabs.getState().closeReactTab(ReactTabKind.Quickstart)} style={{ marginLeft: 8 }} > Close )}
); };