Skip to content

Commit 730efd8

Browse files
authored
node def entity clone: make feature experimental (#4215)
1 parent 89e96d0 commit 730efd8

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

webapp/components/survey/SurveyForm/nodeDefs/components/nodeDefEditButtonsMenu.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Button, ButtonDelete, ButtonMenu } from '@webapp/components'
1212

1313
import { NodeDefEntitySelectorDialog } from './nodeDefEntitySelectorDialog'
1414
import { NodeDefConversionDialog } from './nodeDefConversionDialog'
15+
import { useSystemConfigExperimentalFeatures } from '@webapp/store/system'
1516

1617
const actionsWithEntitySelection = { clone: 'clone', move: 'move' }
1718

@@ -39,7 +40,8 @@ const isEntitySelectableByAction = {
3940
}
4041

4142
const availabilityByAction = {
42-
[actionsWithEntitySelection.clone]: () => true,
43+
[actionsWithEntitySelection.clone]: ({ nodeDef, experimentalFeatures }) =>
44+
experimentalFeatures || NodeDef.isAttribute(nodeDef),
4345
[actionsWithEntitySelection.move]: ({ survey, cycle, nodeDef }) => {
4446
// published node defs cannot be moved
4547
if (NodeDef.isPublished(nodeDef)) return false
@@ -71,6 +73,7 @@ export const NodeDefEditButtonsMenu = (props) => {
7173
const dispatch = useDispatch()
7274
const navigate = useNavigate()
7375

76+
const experimentalFeatures = useSystemConfigExperimentalFeatures()
7477
const survey = useSurvey()
7578
const cycle = useSurveyCycleKey()
7679
const lang = useSurveyPreferredLang()
@@ -129,7 +132,7 @@ export const NodeDefEditButtonsMenu = (props) => {
129132
const _menuItems = []
130133
// items with entity selection (clone or move actions)
131134
const availableActions = Object.keys(actionsWithEntitySelection).filter((action) =>
132-
availabilityByAction[action]({ survey, cycle, nodeDef })
135+
availabilityByAction[action]({ survey, cycle, nodeDef, experimentalFeatures })
133136
)
134137
_menuItems.push(
135138
...availableActions.map((action) => ({
@@ -180,7 +183,16 @@ export const NodeDefEditButtonsMenu = (props) => {
180183
})
181184
}
182185
return _menuItems
183-
}, [cycle, dispatch, nodeDef, nodeDefLabel, openConvertIntoDialog, openEntitySelectDialog, survey])
186+
}, [
187+
cycle,
188+
dispatch,
189+
experimentalFeatures,
190+
nodeDef,
191+
nodeDefLabel,
192+
openConvertIntoDialog,
193+
openEntitySelectDialog,
194+
survey,
195+
])
184196

185197
if (menuItems.length === 0) return null
186198

webapp/store/system/info/hooks.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

webapp/store/system/info/hooks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { useSelector } from 'react-redux'
2+
3+
import * as SystemInfoState from './state'
4+
5+
export const useSystemAppInfo = () => useSelector(SystemInfoState.getAppInfo)
6+
export const useSystemConfig = () => useSelector(SystemInfoState.getConfig)
7+
export const useSystemConfigExperimentalFeatures = (): boolean =>
8+
useSelector(SystemInfoState.getConfigExperimentalFeatures)
9+
export const useSystemConfigFileUploadLimit = (): number => useSelector(SystemInfoState.getConfigFileUploadLimit)
10+
export const useSystemConfigFileUploadLimitMB = (): number => useSelector(SystemInfoState.getConfigFileUploadLimitMB)

0 commit comments

Comments
 (0)