Skip to content

Commit 4a63605

Browse files
authored
Fix [New function] No default for handler (#2078)
1 parent 4dabcd2 commit 4a63605

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/components/JobWizard/JobWizard.util.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
ENV_VARIABLE_TYPE_SECRET,
3939
ENV_VARIABLE_TYPE_VALUE,
4040
EXISTING_IMAGE_SOURCE,
41+
FUNCTION_DEFAULT_HANDLER,
4142
HYPERPARAMETER_STRATEGY_STEP,
4243
JOB_DEFAULT_OUTPUT_PATH,
4344
LIST_TUNING_STRATEGY,
@@ -385,9 +386,9 @@ const getDefaultMethod = (methodOptions, selectedFunctions) => {
385386
if (methodOptions.length) {
386387
method = methodOptions[0]?.id
387388
} else if (latestFunction) {
388-
method = latestFunction.spec.default_handler || 'handler'
389+
method = latestFunction.spec.default_handler || FUNCTION_DEFAULT_HANDLER
389390
} else {
390-
method = selectedFunctions[0]?.spec.default_handler || 'handler'
391+
method = selectedFunctions[0]?.spec.default_handler || FUNCTION_DEFAULT_HANDLER
391392
}
392393

393394
return method

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export const FUNCTION_INITIALIZED_STATE = 'initialized'
283283
export const FUNCTION_READY_STATE = 'ready'
284284
export const FUNCTION_PENDINDG_STATE = 'pending'
285285
export const FUNCTION_RUNNING_STATE = 'running'
286+
export const FUNCTION_DEFAULT_HANDLER = 'handler'
286287

287288
/*=========== ARTIFACTS =============*/
288289

src/elements/FunctionsPanelCode/FunctionsPanelCode.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
NEW_IMAGE,
3333
sourceCodeInBase64
3434
} from './functionsPanelCode.util'
35-
import { PANEL_CREATE_MODE, TAG_LATEST } from '../../constants'
35+
import { FUNCTION_DEFAULT_HANDLER, PANEL_CREATE_MODE, TAG_LATEST } from '../../constants'
3636
import { splitTrim, trimSplit } from '../../utils'
3737
import { useParams } from 'react-router-dom'
3838

@@ -59,7 +59,7 @@ const FunctionsPanelCode = ({
5959
const [data, setData] = useState({
6060
default_class: defaultData.default_class ?? '',
6161
entry: DEFAULT_ENTRY,
62-
handler: defaultData.default_handler ?? '',
62+
handler: defaultData.default_handler ?? FUNCTION_DEFAULT_HANDLER,
6363
image: defaultData.image ?? '',
6464
base_image: defaultData.build?.base_image ?? '',
6565
requirements: (defaultData.build?.requirements || []).join(', ') ?? '',
@@ -83,12 +83,6 @@ const FunctionsPanelCode = ({
8383
setNewFunctionSourceCode
8484
])
8585

86-
useEffect(() => {
87-
if (!functionsStore.newFunction.spec.default_handler) {
88-
setNewFunctionHandler('handler')
89-
}
90-
}, [functionsStore.newFunction.spec.default_handler, setNewFunctionHandler])
91-
9286
useEffect(() => {
9387
if (mode === PANEL_CREATE_MODE && imageType.length === 0) {
9488
if (appStore.frontendSpec.default_function_image_by_kind?.[functionsStore.newFunction.kind]) {

0 commit comments

Comments
 (0)