Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): remove notebook's unused buttons #7008

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions src/flows/components/header/MenuButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, {FC, createRef, RefObject, useContext, useState} from 'react'
import React, {createRef, FC, RefObject, useContext, useState} from 'react'
import {
IconFont,
Icon,
IconFont,
InfluxColors,
List,
Popover,
PopoverInteraction,
SquareButton,
InfluxColors,
RemoteDataState,
SpinnerContainer,
SquareButton,
TechnoSpinner,
} from '@influxdata/clockface'
import {useSelector} from 'react-redux'
Expand Down Expand Up @@ -170,23 +170,7 @@ const MenuButton: FC<Props> = ({handleResetShare}) => {
)
}

const menuItems: any[] = [
{
type: 'menuitem',
title: 'Version history',
onClick: handleViewPublish,
icon: IconFont.History,
disabled: () => {
const [first, second] = versions
// accounts for the draft state
let versionId = first?.id
if (first?.id === 'draft' && second?.id) {
versionId = second?.id
}
return !(versionId !== 'draft' && typeof versionId !== undefined)
},
},
{title: 'divider', type: 'divider'},
let menuItems: any[] = [
{
type: 'menuitem',
title: 'Download as PNG',
Expand All @@ -209,6 +193,26 @@ const MenuButton: FC<Props> = ({handleResetShare}) => {
]

if (CLOUD) {
menuItems = [
{
type: 'menuitem',
title: 'Version history',
onClick: handleViewPublish,
icon: IconFont.History,
disabled: () => {
const [first, second] = versions
// accounts for the draft state
let versionId = first?.id
if (first?.id === 'draft' && second?.id) {
versionId = second?.id
}
return !(versionId !== 'draft' && typeof versionId !== undefined)
},
},
{title: 'divider', type: 'divider'},
...menuItems,
]

menuItems.splice(3, 0, {
type: 'menuitem',
title: 'Clone',
Expand Down
59 changes: 32 additions & 27 deletions src/flows/components/header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libraries
import React, {FC, useCallback, useContext, useState, useEffect} from 'react'
import React, {FC, useCallback, useContext, useEffect, useState} from 'react'
import {useDispatch, useSelector} from 'react-redux'

// Contexts
Expand All @@ -12,11 +12,11 @@ import {AppSettingProvider} from 'src/shared/contexts/app'

// Components
import {
Page,
SquareButton,
IconFont,
ComponentColor,
ComponentStatus,
IconFont,
Page,
SquareButton,
} from '@influxdata/clockface'

import AutoRefreshButton from 'src/flows/components/header/AutoRefreshButton'
Expand All @@ -40,6 +40,7 @@ import {RemoteDataState} from 'src/types'

// Constants
import {DEFAULT_PROJECT_NAME, PROJECT_NAME} from 'src/flows'
import {CLOUD} from 'src/shared//constants'

interface Share {
id: string
Expand Down Expand Up @@ -159,31 +160,35 @@ const FlowHeader: FC = () => {
<PresentationMode />
<TimeZoneDropdown />
<TimeRangeDropdown />
<SquareButton
icon={IconFont.Save}
onClick={handlePublish}
color={ComponentColor.Default}
titleText="Save to version history"
/>
{CLOUD && (
<SquareButton
icon={IconFont.Save}
onClick={handlePublish}
color={ComponentColor.Default}
titleText="Save to version history"
/>
)}
{flow?.id && (
<>
<SquareButton
icon={IconFont.Share}
onClick={
!!share
? () => openShareLinkOverlay(share)
: () => generateLink()
}
color={
!!share ? ComponentColor.Primary : ComponentColor.Secondary
}
status={
linkLoading === RemoteDataState.Loading
? ComponentStatus.Loading
: ComponentStatus.Default
}
titleText={`Share ${PROJECT_NAME}`}
/>
{CLOUD && (
<SquareButton
icon={IconFont.Share}
onClick={
!!share
? () => openShareLinkOverlay(share)
: () => generateLink()
}
color={
!!share ? ComponentColor.Primary : ComponentColor.Secondary
}
status={
linkLoading === RemoteDataState.Loading
? ComponentStatus.Loading
: ComponentStatus.Default
}
titleText={`Share ${PROJECT_NAME}`}
/>
)}
<MenuButton handleResetShare={() => setShare(null)} />
</>
)}
Expand Down