Skip to content

Commit

Permalink
[desk-tool] Enable review changes for liveEdit documents
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and rexxars committed Oct 6, 2020
1 parent f30c8f7 commit 80c1c67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@ export function DocumentPanel(props: DocumentPanelProps) {
const menuItems = useMemo(() => {
return (
getMenuItems({
canShowHistoryList: true,
features,
isHistoryEnabled: true,
isHistoryOpen: props.isHistoryOpen,
isLiveEditEnabled: props.schemaType.liveEdit === true,
rev: revTime ? revTime.id : null,
value: props.value
}) || []
)
}, [props.isHistoryOpen, props.schemaType, revTime, props.value])
}, [features, props.isHistoryOpen, revTime, props.value])

const handleContextMenuAction = useCallback(
item => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,23 @@ import {Doc} from '../../types'
import styles from './menuItems.css'

interface Params {
canShowHistoryList?: boolean
features: DeskToolFeatures
isHistoryOpen?: boolean
isHistoryEnabled?: boolean
isLiveEditEnabled?: boolean
rev: string | null
value: Doc | null
}

const getHistoryMenuItem = (params: Params): MenuItemType | null => {
const {
features,
value,
isLiveEditEnabled,
isHistoryEnabled,
isHistoryOpen,
canShowHistoryList
} = params
const {features, value, isHistoryOpen} = params

if (isLiveEditEnabled || !canShowHistoryList) {
return null
}
if (!features.reviewChanges) return null

if (isHistoryEnabled) {
return {
action: 'reviewChanges',
title: 'Review changes',
icon: HistoryIcon,
isDisabled: !features.reviewChanges || isHistoryOpen || !value
}
return {
action: 'reviewChanges',
title: 'Review changes',
icon: HistoryIcon,
isDisabled: isHistoryOpen || !value
}

return null
}

const getInspectItem = ({value}: Params): MenuItemType => ({
Expand Down

0 comments on commit 80c1c67

Please sign in to comment.