Temporarily disabled compound props' context menu as it's not ready for the next release

This commit is contained in:
Aria Minaei 2021-09-30 10:27:16 +02:00
parent 0e0bb1f3fc
commit 3ccef9694f

View file

@ -1,11 +1,8 @@
import type {PropTypeConfig_Compound} from '@theatre/core/propTypes' import type {PropTypeConfig_Compound} from '@theatre/core/propTypes'
import {isPropConfigComposite} from '@theatre/shared/propTypes/utils' import {isPropConfigComposite} from '@theatre/shared/propTypes/utils'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject' import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import type { import type {$IntentionalAny} from '@theatre/shared/utils/types'
$IntentionalAny, import {getPointerParts} from '@theatre/dataverse'
SerializableMap,
} from '@theatre/shared/utils/types'
import {getPointerParts, val} from '@theatre/dataverse'
import last from 'lodash-es/last' import last from 'lodash-es/last'
import {darken, transparentize} from 'polished' import {darken, transparentize} from 'polished'
import React from 'react' import React from 'react'
@ -18,11 +15,7 @@ import {
} from './utils/SingleRowPropEditor' } from './utils/SingleRowPropEditor'
import DefaultOrStaticValueIndicator from './utils/DefaultValueIndicator' import DefaultOrStaticValueIndicator from './utils/DefaultValueIndicator'
import {pointerEventsAutoInNormalMode} from '@theatre/studio/css' import {pointerEventsAutoInNormalMode} from '@theatre/studio/css'
import type {IContextMenuItem} from '@theatre/studio/uiComponents/simpleContextMenu/useContextMenu'
import useContextMenu from '@theatre/studio/uiComponents/simpleContextMenu/useContextMenu'
import useRefAndState from '@theatre/studio/utils/useRefAndState' import useRefAndState from '@theatre/studio/utils/useRefAndState'
import getStudio from '@theatre/studio/getStudio'
import getDeep from '@theatre/shared/utils/getDeep'
const Container = styled.div` const Container = styled.div`
--step: 8px; --step: 8px;
@ -53,7 +46,7 @@ const PropName = styled.div`
align-items: center; align-items: center;
user-select: none; user-select: none;
&:hover { &:hover {
color: white; /* color: white; */
} }
${() => propNameText}; ${() => propNameText};
@ -85,61 +78,61 @@ const CompoundPropEditor: React.FC<{
const [propNameContainerRef, propNameContainer] = const [propNameContainerRef, propNameContainer] =
useRefAndState<HTMLDivElement | null>(null) useRefAndState<HTMLDivElement | null>(null)
const [contextMenu] = useContextMenu(propNameContainer, { // const [contextMenu] = useContextMenu(propNameContainer, {
items: () => { // items: () => {
const items: IContextMenuItem[] = [] // const items: IContextMenuItem[] = []
const pathToProp = getPointerParts(pointerToProp).path // const pathToProp = getPointerParts(pointerToProp).path
const validSequencedTracks = val( // const validSequencedTracks = val(
obj.template.getMapOfValidSequenceTracks_forStudio(), // obj.template.getMapOfValidSequenceTracks_forStudio(),
) // )
const possibleSequenceTrackIds = getDeep(validSequencedTracks, pathToProp) // const possibleSequenceTrackIds = getDeep(validSequencedTracks, pathToProp)
const hasSequencedTracks = !!( // const hasSequencedTracks = !!(
typeof possibleSequenceTrackIds === 'object' && // typeof possibleSequenceTrackIds === 'object' &&
possibleSequenceTrackIds && // possibleSequenceTrackIds &&
Object.keys(possibleSequenceTrackIds).length > 0 // Object.keys(possibleSequenceTrackIds).length > 0
) // )
if (hasSequencedTracks) { // if (hasSequencedTracks) {
items.push({ // items.push({
label: 'Make All Static', // label: 'Make All Static',
enabled: hasSequencedTracks, // enabled: hasSequencedTracks,
callback: () => { // callback: () => {
getStudio()!.transaction(({stateEditors}) => { // getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp} // const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setCompoundPropAsStatic( // stateEditors.coreByProject.historic.sheetsById.sequence.setCompoundPropAsStatic(
{ // {
...propAddress, // ...propAddress,
value: obj.getValueByPointer( // value: obj.getValueByPointer(
pointerToProp, // pointerToProp,
) as unknown as SerializableMap, // ) as unknown as SerializableMap,
}, // },
) // )
}) // })
}, // },
}) // })
} // }
items.push({ // items.push({
label: 'Reset all', // label: 'Reset all',
callback: () => { // callback: () => {
getStudio()!.transaction(({unset}) => { // getStudio()!.transaction(({unset}) => {
unset(pointerToProp) // unset(pointerToProp)
}) // })
}, // },
}) // })
return items // return items
}, // },
}) // })
const lastSubPropIsComposite = compositeSubs.length > 0 const lastSubPropIsComposite = compositeSubs.length > 0
return ( return (
<Container> <Container>
{contextMenu} {/* {contextMenu} */}
<Header <Header
// @ts-ignore // @ts-ignore
style={{'--depth': depth - 1}} style={{'--depth': depth - 1}}