Skip to content

Commit

Permalink
unlock experimental features (prepare to v2) (#3670)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
  • Loading branch information
SteRiccio and SteRiccio authored Nov 27, 2024
1 parent a36d3ae commit 75431a4
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 72 deletions.
7 changes: 1 addition & 6 deletions webapp/components/expression/functionExamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ const functionExamples = {
},
}

const experimentalFunctions = [
functionNames.geoPolygon,
functionNames.userEmail,
functionNames.userName,
functionNames.userProp,
]
const experimentalFunctions = []

const isFunctionAvailable = (functionName) =>
ProcessUtils.ENV.experimentalFeatures || !experimentalFunctions.includes(functionName)
Expand Down
7 changes: 1 addition & 6 deletions webapp/components/expression/nodes/binaryOperand.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import PropTypes from 'prop-types'
import * as A from '@core/arena'
import * as Expression from '@core/expressionParser/expression'
import * as NodeDef from '@core/survey/nodeDef'
import * as ProcessUtils from '@core/processUtils'

import { Button } from '@webapp/components/buttons'

const { types } = Expression

const availableOperandExpressionTypes = [
types.Identifier,
types.Literal,
...(ProcessUtils.ENV.experimentalFeatures ? [types.CallExpression] : []),
]
const availableOperandExpressionTypes = [types.Identifier, types.Literal, types.CallExpression]

const expressionTypeAcronymByType = {
[types.CallExpression]: 'call',
Expand Down
31 changes: 14 additions & 17 deletions webapp/components/survey/NodeDefDetails/FileProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from 'prop-types'
import * as A from '@core/arena'
import * as NodeDef from '@core/survey/nodeDef'
import * as Validation from '@core/validation/validation'
import * as ProcessUtils from '@core/processUtils'

import { useI18n } from '@webapp/store/system'

Expand Down Expand Up @@ -58,22 +57,20 @@ const FileProps = (props) => {
validation={Validation.getFieldValidation(NodeDef.propKeys.maxFileSize)(validation)}
/>
</FormItem>
{ProcessUtils.ENV.experimentalFeatures && (
<FormItem label="nodeDefEdit.fileProps.fileNameExpression">
<NodeDefSingleExpressionProp
canBeConstant
excludeCurrentNodeDef
isBoolean={false}
nodeDef={nodeDef}
onChange={({ query: value }) => {
Actions.setProp({ state, key: NodeDef.keysPropsAdvanced.fileNameExpression, value })
}}
qualifier="fileNameExpression"
query={NodeDef.getFileNameExpression(nodeDef)}
validation={Validation.getFieldValidation(NodeDef.keysPropsAdvanced.fileNameExpression)(validation)}
/>
</FormItem>
)}
<FormItem label="nodeDefEdit.fileProps.fileNameExpression">
<NodeDefSingleExpressionProp
canBeConstant
excludeCurrentNodeDef
isBoolean={false}
nodeDef={nodeDef}
onChange={({ query: value }) => {
Actions.setProp({ state, key: NodeDef.keysPropsAdvanced.fileNameExpression, value })
}}
qualifier="fileNameExpression"
query={NodeDef.getFileNameExpression(nodeDef)}
validation={Validation.getFieldValidation(NodeDef.keysPropsAdvanced.fileNameExpression)(validation)}
/>
</FormItem>
<FormItem label="nodeDefEdit.fileProps.fileType">
<ButtonGroup selectedItemKey={NodeDef.getFileType(nodeDef)} onChange={selectFileType} items={fileTypes} />
</FormItem>
Expand Down
13 changes: 5 additions & 8 deletions webapp/components/survey/SurveyForm/SurveyForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as Survey from '@core/survey/survey'
import * as NodeDef from '@core/survey/nodeDef'
import * as NodeDefLayout from '@core/survey/nodeDefLayout'
import * as Record from '@core/record/record'
import * as ProcessUtils from '@core/processUtils'

import { appModuleUri, designerModules } from '@webapp/app/appModules'
import { SurveyState, useSurvey } from '@webapp/store/survey'
Expand Down Expand Up @@ -200,13 +199,11 @@ const SurveyForm = (props) => {
onSelect={onNodeDefTreeSelect}
/>
<div className="display-flex sidebar-bottom-bar">
{edit && ProcessUtils.ENV.experimentalFeatures && (
<ButtonGroup
items={treeSelectViewModeItems}
onChange={(mode) => dispatch(SurveyFormActions.setTreeSelectViewMode(mode))}
selectedItemKey={treeSelectViewMode}
/>
)}
<ButtonGroup
items={treeSelectViewModeItems}
onChange={(mode) => dispatch(SurveyFormActions.setTreeSelectViewMode(mode))}
selectedItemKey={treeSelectViewMode}
/>
{edit && canEditDef && viewOnlyPages && <FormPagesEditButtons />}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TestId } from '@webapp/utils/testId'

import * as NodeDefUIProps from '../nodeDefs/nodeDefUIProps'

const experimentalNodeDefTypes = [NodeDef.nodeDefType.geo]
const experimentalNodeDefTypes = []

const AddNodeDefButtons = (props) => {
const { surveyCycleKey, nodeDef, addNodeDef } = props
Expand Down
22 changes: 9 additions & 13 deletions webapp/views/App/views/Home/SurveyInfo/SurveyInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import './SurveyInfo.scss'

import React from 'react'

import * as ProcessUtils from '@core/processUtils'

import { useAuthCanEditSurvey, useAuthCanUseAnalysis, useUserIsSystemAdmin } from '@webapp/store/user'
import { TestId } from '@webapp/utils/testId'

Expand Down Expand Up @@ -76,17 +74,15 @@ const SurveyInfo = () => {
})
}
if (!readOnly) {
if (ProcessUtils.ENV.experimentalFeatures) {
tabs.push({
key: 'extraProps',
component: SurveyUserExtraPropDefsEditor,
label: 'homeView.surveyInfo.userExtraProps.title',
props: {
extraPropDefs: userExtraPropDefs,
onExtraPropDefsUpdate: setUserExtraPropDefs,
},
})
}
tabs.push({
key: 'extraProps',
component: SurveyUserExtraPropDefsEditor,
label: 'homeView.surveyInfo.userExtraProps.title',
props: {
extraPropDefs: userExtraPropDefs,
onExtraPropDefsUpdate: setUserExtraPropDefs,
},
})
if (isSystemAdmin) {
tabs.push({
key: 'configuration',
Expand Down
19 changes: 8 additions & 11 deletions webapp/views/App/views/Users/UserEdit/UserEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useNavigate, useParams } from 'react-router'
import { Objects } from '@openforis/arena-core'

import * as AuthGroup from '@core/auth/authGroup'
import * as ProcessUtils from '@core/processUtils'
import * as Survey from '@core/survey/survey'
import * as User from '@core/user/user'
import * as Validation from '@core/validation/validation'
Expand Down Expand Up @@ -122,7 +121,7 @@ const UserEdit = () => {
</FormItem>
)}

{ProcessUtils.ENV.experimentalFeatures && <UserExtraPropsEditor onChange={onExtraChange} user={userToUpdate} />}
<UserExtraPropsEditor onChange={onExtraChange} user={userToUpdate} />

{canEditSystemAdmin && (
<FormItem label="authGroups.systemAdmin.label">
Expand Down Expand Up @@ -168,15 +167,13 @@ const UserEdit = () => {
/>
</FormItem>
)}
{ProcessUtils.ENV.experimentalFeatures && (
<ExpansionPanel
buttonLabel="usersView.surveyExtraProp.label_other"
className="extra-props"
startClosed={Objects.isEmpty(User.getAuthGroupExtraProps(userToUpdate))}
>
<UserAuthGroupExtraPropsEditor onChange={onSurveyExtraPropsChange} userToUpdate={userToUpdate} />
</ExpansionPanel>
)}
<ExpansionPanel
buttonLabel="usersView.surveyExtraProp.label_other"
className="extra-props"
startClosed={Objects.isEmpty(User.getAuthGroupExtraProps(userToUpdate))}
>
<UserAuthGroupExtraPropsEditor onChange={onSurveyExtraPropsChange} userToUpdate={userToUpdate} />
</ExpansionPanel>
</>
)}
{editingSameUser && hideSurveyGroup && canUseMap && (
Expand Down
17 changes: 7 additions & 10 deletions webapp/views/App/views/Users/UsersListSurvey/Row/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as AuthGroup from '@core/auth/authGroup'
import * as Survey from '@core/survey/survey'
import * as User from '@core/user/user'
import * as DateUtils from '@core/dateUtils'
import * as ProcessUtils from '@core/processUtils'

import { TestId } from '@webapp/utils/testId'
import { useI18n } from '@webapp/store/system'
Expand Down Expand Up @@ -87,15 +86,13 @@ const Row = (props) => {
<div data-testid={TestId.userList.edit}>
<span className={`icon icon-12px icon-action ${canEditUser ? 'icon-pencil2' : 'icon-eye'}`} />
</div>
{canEditUser && ProcessUtils.ENV.experimentalFeatures && (
<Button
iconClassName="icon-cog"
title="usersView.editSurveyUserExtraPropsForUser"
titleParams={{ userName: User.getName(userListItem) ?? User.getEmail(userListItem) }}
onClick={(event) => onEditSurveyUserExtraProps({ event, userListItem })}
variant="text"
/>
)}
<Button
iconClassName="icon-cog"
title="usersView.editSurveyUserExtraPropsForUser"
titleParams={{ userName: User.getName(userListItem) ?? User.getEmail(userListItem) }}
onClick={(event) => onEditSurveyUserExtraProps({ event, userListItem })}
variant="text"
/>
</>
)
}
Expand Down

0 comments on commit 75431a4

Please sign in to comment.