-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flows): redesign add cell UX (#18973)
* refactor: consolidate header component & remove add buttons * feat: render add cell buttons in empty state * refactor: make inline insert button more visible on hover * refactor: remove feature flag around Data Source cell type * feat: group cell types into "families" * refactor: rename "Data Source" to "Bucket" * refactor: render cell types in families inside add cell menu * fix: make it a little more flexible (#18976) Co-authored-by: drdelambre <drdelambre> * fix: linting issue Co-authored-by: Alex Boatwright <drdelambre@gmail.com> Co-authored-by: drdelambre <drdelambre>
- Loading branch information
1 parent
c476da2
commit 6c714b1
Showing
22 changed files
with
217 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@import '@influxdata/clockface/dist/variables.scss'; | ||
|
||
.add-cell-menu { | ||
display: flex; | ||
align-items: stretch; | ||
} | ||
|
||
.add-cell-menu--column { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
flex: 1 0 142px; | ||
width: 142px; | ||
background-color: $g1-raven; | ||
border-radius: $cf-radius; | ||
padding: 0 $cf-marg-c; | ||
margin-right: $cf-marg-a; | ||
|
||
&:last-child { | ||
margin-right: 0; | ||
} | ||
} | ||
|
||
.add-cell-menu--column .cf-button { | ||
margin-bottom: $cf-marg-b; | ||
} | ||
|
||
.add-cell-menu--column-title { | ||
white-space: nowrap; | ||
margin: $cf-marg-b 0; | ||
text-align: center; | ||
padding: 0 $cf-marg-b; | ||
user-select: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Libraries | ||
import React, {FC, ReactNode, Children} from 'react' | ||
|
||
interface Props { | ||
title: string | ||
children: ReactNode | ||
} | ||
|
||
const CellFamily: FC<Props> = ({title, children}) => { | ||
if (Children.count(children) === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="add-cell-menu--column"> | ||
<h6 className="add-cell-menu--column-title">{title}</h6> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export default CellFamily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
import React, {FC, useContext} from 'react' | ||
// Libraries | ||
import React, {FC, useContext, useCallback} from 'react' | ||
|
||
// Contexts | ||
import {NotebookContext} from 'src/notebooks/context/notebook' | ||
import {TimeProvider, TimeContext, TimeBlock} from 'src/notebooks/context/time' | ||
import AppSettingProvider from 'src/notebooks/context/app' | ||
|
||
// Components | ||
import {Page} from '@influxdata/clockface' | ||
import AddButtons from 'src/notebooks/components/AddButtons' | ||
import Buttons from 'src/notebooks/components/header/Buttons' | ||
import {NotebookContext} from 'src/notebooks/context/notebook.current' | ||
import TimeZoneDropdown from 'src/notebooks/components/header/TimeZoneDropdown' | ||
import TimeRangeDropdown from 'src/notebooks/components/header/TimeRangeDropdown' | ||
import AutoRefreshDropdown from 'src/notebooks/components/header/AutoRefreshDropdown' | ||
import Submit from 'src/notebooks/components/header/Submit' | ||
import PresentationMode from 'src/notebooks/components/header/PresentationMode' | ||
|
||
const FULL_WIDTH = true | ||
|
||
const Header: FC = () => { | ||
const {notebook} = useContext(NotebookContext) | ||
export interface TimeContextProps { | ||
context: TimeBlock | ||
update: (data: TimeBlock) => void | ||
} | ||
|
||
const NotebookHeader: FC = () => { | ||
const {id} = useContext(NotebookContext) | ||
const {timeContext, addTimeContext, updateTimeContext} = useContext( | ||
TimeContext | ||
) | ||
|
||
const update = useCallback( | ||
(data: TimeBlock) => { | ||
updateTimeContext(id, data) | ||
}, | ||
[id, updateTimeContext] | ||
) | ||
|
||
if (!timeContext.hasOwnProperty(id)) { | ||
addTimeContext(id) | ||
return null | ||
} | ||
|
||
return ( | ||
<> | ||
<Page.Header fullWidth={FULL_WIDTH}> | ||
<Page.Title title="Flows" /> | ||
</Page.Header> | ||
<Page.ControlBar fullWidth={FULL_WIDTH}> | ||
{!notebook.readOnly && ( | ||
<Page.ControlBarLeft> | ||
<h3 className="notebook--add-cell-label">Add Cell:</h3> | ||
<AddButtons eventName="Notebook Add Button Clicked" /> | ||
</Page.ControlBarLeft> | ||
)} | ||
<Page.ControlBarLeft> | ||
<Submit /> | ||
</Page.ControlBarLeft> | ||
<Page.ControlBarRight> | ||
<Buttons /> | ||
<PresentationMode /> | ||
<TimeZoneDropdown /> | ||
<TimeRangeDropdown context={timeContext[id]} update={update} /> | ||
<AutoRefreshDropdown context={timeContext[id]} update={update} /> | ||
</Page.ControlBarRight> | ||
</Page.ControlBar> | ||
</> | ||
) | ||
} | ||
|
||
export default Header | ||
export default () => ( | ||
<TimeProvider> | ||
<AppSettingProvider> | ||
<NotebookHeader /> | ||
</AppSettingProvider> | ||
</TimeProvider> | ||
) |
Oops, something went wrong.