-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTranslationModalActions.js
More file actions
63 lines (57 loc) · 1.79 KB
/
TranslationModalActions.js
File metadata and controls
63 lines (57 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { useDhis2ConnectionStatus } from '@dhis2/app-runtime'
import { Button, ButtonStrip, ModalActions } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React from 'react'
import i18n from '../../../locales/index.js'
import { OfflineTooltip } from '../../OfflineTooltip.js'
const SaveButton = ({ disabled, loading, onClick }) => (
<Button primary onClick={onClick} loading={loading} disabled={disabled}>
{i18n.t('Save translations')}
</Button>
)
SaveButton.defaultProps = {
disabled: false,
loading: false,
onClick: Function.prototype,
}
SaveButton.propTypes = {
disabled: PropTypes.bool.isRequired,
loading: PropTypes.bool.isRequired,
onClick: PropTypes.func.isRequired,
}
export const TranslationModalActions = ({
onClose,
onSave,
saveInProgress,
saveButtonDisabled,
}) => {
const { isDisconnected: offline } = useDhis2ConnectionStatus()
return (
<ModalActions>
<ButtonStrip>
<Button secondary onClick={onClose}>
{i18n.t('Cancel')}
</Button>
{offline ? (
<OfflineTooltip
content={i18n.t('Cannot save while offline')}
>
<SaveButton disabled={true} />
</OfflineTooltip>
) : (
<SaveButton
onClick={onSave}
loading={saveInProgress}
disabled={saveButtonDisabled}
/>
)}
</ButtonStrip>
</ModalActions>
)
}
TranslationModalActions.propTypes = {
onClose: PropTypes.func.isRequired,
saveButtonDisabled: PropTypes.bool,
saveInProgress: PropTypes.bool,
onSave: PropTypes.func,
}