Skip to content

Commit 523889f

Browse files
feat: a dropdown menu for less frequently used items on Dashboard (#3000)
1 parent 68d8b2e commit 523889f

File tree

5 files changed

+101
-14
lines changed

5 files changed

+101
-14
lines changed

cypress.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"www.googletagmanager.com",
1414
"www.honeybadger.io"
1515
],
16-
"viewportWidth": 1200,
16+
"viewportWidth": 1400,
1717
"viewportHeight": 1000
1818
}

cypress/e2e/shared/dashboardsView.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ describe('Dashboard', () => {
146146
})
147147

148148
// toggle presentation mode
149+
cy.getByTestID('collapsible_menu').click()
149150
cy.getByTestID('presentation-mode-toggle').click()
151+
150152
// ensure a notification is sent when toggling to presentation mode
151153
cy.getByTestID('notification-primary--children').should('exist')
152154
// escape to toggle the presentation mode off
@@ -1334,9 +1336,12 @@ csv.from(csv: data) |> filter(fn: (r) => r.bucket == v.bucketsCSV)`
13341336
})
13351337
})
13361338
})
1339+
cy.getByTestID('collapsible_menu').click()
1340+
13371341
cy.getByTestID('select-group--option')
13381342
.last()
13391343
.click() // light mode
1344+
13401345
cy.getByTestID('app-wrapper')
13411346
.invoke('css', 'background-color')
13421347
.should('equal', 'rgb(241, 241, 243)')

src/annotations/components/AnnotationsControlBarToggleButton.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ import {
1919
// Utils
2020
import {event} from 'src/cloud/utils/reporting'
2121

22+
interface Props {
23+
className?: string
24+
}
2225
/**
2326
* This turns annotation on and off.
2427
* the control bar itself just shows messages at this point.
2528
* */
26-
export const AnnotationsControlBarToggleButton: FC = () => {
29+
export const AnnotationsControlBarToggleButton: FC<Props> = ({className}) => {
2730
const dispatch = useDispatch()
2831
const inAnnotationsMode = useSelector(isAnnotationsModeEnabled)
2932

@@ -47,6 +50,7 @@ export const AnnotationsControlBarToggleButton: FC = () => {
4750
checked={inAnnotationsMode}
4851
testID="toggle-annotations-controls"
4952
onChange={handleClick}
53+
className={className}
5054
>
5155
<InputLabel
5256
htmlFor="toggle-annotations-controls"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@media (max-width: 1350px) {
2+
.control_buttons_collapsible {
3+
display: none;
4+
}
5+
}
6+
7+
@media (min-width: 1350px) {
8+
.control_buttons_in_collapsed_menu {
9+
display: none;
10+
}
11+
}

src/dashboards/components/DashboardHeader.tsx

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
// Libraries
2-
import React, {FC, useEffect, useCallback} from 'react'
2+
import React, {FC, useCallback, useContext, useEffect} from 'react'
33
import {connect, ConnectedProps} from 'react-redux'
4-
import {withRouter, RouteComponentProps} from 'react-router-dom'
4+
import {RouteComponentProps, withRouter} from 'react-router-dom'
55

66
// Components
77
import AutoRefreshDropdown from 'src/shared/components/dropdown_auto_refresh/AutoRefreshDropdown'
88
import TimeRangeDropdown from 'src/shared/components/TimeRangeDropdown'
9-
import PresentationModeToggle from 'src/shared/components/PresentationModeToggle'
109
import DashboardLightModeToggle from 'src/dashboards/components/DashboardLightModeToggle'
1110
import GraphTips from 'src/shared/components/graph_tips/GraphTips'
1211
import RenamablePageTitle from 'src/pageLayout/components/RenamablePageTitle'
1312
import TimeZoneDropdown from 'src/shared/components/TimeZoneDropdown'
1413
import {
14+
Appearance,
1515
Button,
16-
IconFont,
1716
ComponentColor,
18-
Page,
19-
Appearance,
17+
Dropdown,
18+
FlexBox,
19+
IconFont,
2020
InputLabel,
2121
InputToggleType,
22+
JustifyContent,
23+
Page,
2224
Toggle,
2325
} from '@influxdata/clockface'
2426
import {AnnotationsControlBarToggleButton} from 'src/annotations/components/AnnotationsControlBarToggleButton'
@@ -27,16 +29,16 @@ import {AnnotationsControlBarToggleButton} from 'src/annotations/components/Anno
2729
import {toggleShowVariablesControls as toggleShowVariablesControlsAction} from 'src/userSettings/actions'
2830
import {updateDashboard as updateDashboardAction} from 'src/dashboards/actions/thunks'
2931
import {
30-
setAutoRefreshStatus as setAutoRefreshStatusAction,
3132
resetDashboardAutoRefresh as resetDashboardAutoRefreshAction,
33+
setAutoRefreshStatus as setAutoRefreshStatusAction,
3234
} from 'src/shared/actions/autoRefresh'
3335
import {
3436
setDashboardTimeRange as setDashboardTimeRangeAction,
3537
updateQueryParams as updateQueryParamsAction,
3638
} from 'src/dashboards/actions/ranges'
3739
import {
38-
showOverlay as showOverlayAction,
3940
dismissOverlay as dismissOverlayAction,
41+
showOverlay as showOverlayAction,
4042
} from 'src/overlays/actions/overlays'
4143

4244
// Utils
@@ -52,10 +54,12 @@ import {getOrg} from 'src/organizations/selectors'
5254
// Constants
5355
import {DemoDataDashboardNames} from 'src/cloud/constants'
5456
import {
55-
DEFAULT_DASHBOARD_NAME,
5657
DASHBOARD_NAME_MAX_LENGTH,
58+
DEFAULT_DASHBOARD_NAME,
5759
} from 'src/dashboards/constants/index'
5860

61+
import './DashboardHeader.scss'
62+
5963
// Types
6064
import {
6165
AppState,
@@ -65,6 +69,7 @@ import {
6569
ResourceType,
6670
TimeRange,
6771
} from 'src/types'
72+
import {AppSettingContext} from '../../shared/contexts/app'
6873

6974
interface OwnProps {
7075
autoRefresh: AutoRefresh
@@ -143,6 +148,8 @@ const DashboardHeader: FC<Props> = ({
143148
const isActive =
144149
autoRefresh?.status && autoRefresh.status === AutoRefreshStatus.Active
145150

151+
const {setPresentationMode, presentationMode} = useContext(AppSettingContext)
152+
146153
return (
147154
<>
148155
<Page.Header fullWidth={true}>
@@ -176,6 +183,7 @@ const DashboardHeader: FC<Props> = ({
176183
checked={showVariablesControls}
177184
testID="variables--button"
178185
onChange={toggleShowVariablesControls}
186+
className="control_buttons_collapsible"
179187
>
180188
<InputLabel
181189
htmlFor="variables--button"
@@ -185,9 +193,68 @@ const DashboardHeader: FC<Props> = ({
185193
Show Variables
186194
</InputLabel>
187195
</Toggle>
188-
<AnnotationsControlBarToggleButton />
189-
<DashboardLightModeToggle />
190-
<PresentationModeToggle />
196+
<AnnotationsControlBarToggleButton className="control_buttons_collapsible" />
197+
198+
<Dropdown
199+
style={{width: '40px'}}
200+
button={(active, onClick) => (
201+
<Button
202+
icon={IconFont.More}
203+
onClick={onClick}
204+
active={active}
205+
testID="collapsible_menu"
206+
/>
207+
)}
208+
menu={() => (
209+
<Dropdown.Menu style={{width: '200px'}}>
210+
<Toggle
211+
id="variables--button"
212+
type={InputToggleType.Checkbox}
213+
fill={Appearance.Solid}
214+
titleText="Variables"
215+
checked={showVariablesControls}
216+
testID="variables--button"
217+
onChange={toggleShowVariablesControls}
218+
style={{marginBottom: '8px'}}
219+
className="control_buttons_in_collapsed_menu"
220+
>
221+
<InputLabel
222+
htmlFor="variables--button"
223+
active={showVariablesControls}
224+
style={{fontWeight: 500}}
225+
>
226+
Show Variables
227+
</InputLabel>
228+
</Toggle>
229+
<AnnotationsControlBarToggleButton className="control_buttons_in_collapsed_menu" />
230+
<Toggle
231+
id="toggle_presentation"
232+
type={InputToggleType.Checkbox}
233+
onChange={() => {
234+
setPresentationMode(true)
235+
}}
236+
fill={Appearance.Solid}
237+
style={{marginTop: '8px'}}
238+
testID="presentation-mode-toggle"
239+
checked={presentationMode}
240+
>
241+
<InputLabel
242+
active={presentationMode}
243+
style={{fontWeight: 500}}
244+
htmlFor="toggle_presentation"
245+
>
246+
Presentation Mode
247+
</InputLabel>
248+
</Toggle>
249+
<FlexBox
250+
justifyContent={JustifyContent.Center}
251+
style={{marginTop: '8px'}}
252+
>
253+
<DashboardLightModeToggle />
254+
</FlexBox>
255+
</Dropdown.Menu>
256+
)}
257+
/>
191258
<GraphTips />
192259
</Page.ControlBarLeft>
193260
<Page.ControlBarRight>

0 commit comments

Comments
 (0)