Skip to content

Commit

Permalink
chore: disable New button when offline
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Apr 23, 2021
1 parent 3389362 commit efe6f69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pages/view/DashboardsBar/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import PropTypes from 'prop-types'
import i18n from '@dhis2/d2-i18n'
import cx from 'classnames'
import { Redirect, withRouter } from 'react-router-dom'
import { Button, Tooltip, colors, IconAdd24 } from '@dhis2/ui'
import { Button, Tooltip, IconAdd24 } from '@dhis2/ui'
import { useOnlineStatus } from '../../../modules/useOnlineStatus'

import Chip from './Chip'
import Filter from './Filter'
Expand All @@ -26,6 +27,7 @@ const Content = ({
onSearchClicked,
}) => {
const [redirectUrl, setRedirectUrl] = useState(null)
const { isOnline } = useOnlineStatus()

const onSelectDashboard = () => {
const id = getFilteredDashboards(dashboards, filterText)[0]?.id
Expand Down Expand Up @@ -65,8 +67,9 @@ const Content = ({
<Tooltip content={i18n.t('Create a new dashboard')}>
<Button
className={classes.newButton}
disabled={!isOnline}
small
icon={<IconAdd24 color={colors.grey600} />}
icon={<IconAdd24 />}
onClick={enterNewMode}
dataTest="new-button"
/>
Expand Down

0 comments on commit efe6f69

Please sign in to comment.