Skip to content

Commit

Permalink
fix(presentation-mode-notification): Triggers a notification when tog…
Browse files Browse the repository at this point in the history
…gling dashboard presentation mode (#18471)
  • Loading branch information
asalem1 authored Jun 11, 2020
1 parent 5bc049c commit a205c01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
1. [18345](https://github.com/influxdata/influxdb/pull/18345): Have influx delete cmd respect the config
1. [18385](https://github.com/influxdata/influxdb/pull/18385): Store initialization for pkger enforced on reads
1. [18434](https://github.com/influxdata/influxdb/pull/18434): Backfill missing fillColumns field for histograms in pkger
1. [18471](https://github.com/influxdata/influxdb/pull/18471): Notifies the user how to escape presentation mode when the feature is toggled

### UI Improvements

Expand Down
13 changes: 12 additions & 1 deletion ui/cypress/e2e/dashboardsView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Dashboard', () => {
cy.getByTestID('dashboard-card').should('contain', newName)
})

it('can create and destroy cells', () => {
it('can create and destroy cells & toggle in and out of presentation mode', () => {
cy.get('@org').then(({id: orgID}: Organization) => {
cy.createDashboard(orgID).then(({body}) => {
cy.fixture('routes').then(({orgs}) => {
Expand All @@ -54,6 +54,17 @@ describe('Dashboard', () => {
cy.getByTestID('save-cell--button').click()
cy.getByTestID('cell--view-empty').should('have.length', 1)

// toggle presentation mode
cy.getByTestID('presentation-mode-toggle').click()
// ensure a notification is sent when toggling to presentation mode
cy.getByTestID('notification-primary--children').should('exist')
// escape to toggle the presentation mode off
cy.get('body').trigger('keyup', {
keyCode: 27,
code: 'Escape',
key: 'Escape',
})

// Remove view cell
cy.getByTestID('cell-context--toggle').click()
cy.getByTestID('cell-context--delete').click()
Expand Down
5 changes: 4 additions & 1 deletion ui/src/dashboards/components/DashboardLightModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ type Props = OwnProps & StateProps & DispatchProps

const DashboardLightModeToggle: FC<Props> = ({theme, onSetTheme}) => {
return (
<SelectGroup testID="presentation-mode-toggle" shape={ButtonShape.Square}>
<SelectGroup
testID="presentation-mode-toggle-group"
shape={ButtonShape.Square}
>
<SelectGroup.Option
onClick={() => onSetTheme('dark')}
value={false}
Expand Down
11 changes: 8 additions & 3 deletions ui/src/shared/actions/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {PRESENTATION_MODE_ANIMATION_DELAY} from '../constants'

import {notify} from 'src/shared/actions/notifications'
import {
notify,
PublishNotificationAction,
} from 'src/shared/actions/notifications'
import {presentationMode} from 'src/shared/copy/notifications'

import {Dispatch} from 'redux'
Expand Down Expand Up @@ -39,11 +42,13 @@ export const disablePresentationMode = () =>
} as const)

export const delayEnablePresentationMode = () => (
dispatch: Dispatch<ReturnType<typeof enablePresentationMode>>
dispatch: Dispatch<
ReturnType<typeof enablePresentationMode> | PublishNotificationAction
>
): NodeJS.Timer =>
setTimeout(() => {
dispatch(enablePresentationMode())
notify(presentationMode())
dispatch(notify(presentationMode()))
}, PRESENTATION_MODE_ANIMATION_DELAY)

// persistent state action creators
Expand Down

0 comments on commit a205c01

Please sign in to comment.