fix: The user input parameter was set to non mandatory, but after re entering the canvas editing, it became a mandatory parameter#4521
Merged
shaohuzhang1 merged 1 commit intov2from Dec 16, 2025
Conversation
…entering the canvas editing, it became a mandatory parameter
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
shaohuzhang1
commented
Dec 16, 2025
| item.required = item.required == undefined ? item.is_required : item.required | ||
| switch (item.type) { | ||
| case 'input': | ||
| item.input_type = 'TextInput' |
Contributor
Author
There was a problem hiding this comment.
{
"type": "error",
"message": "The line `item.required = item.required == undefined ? item.is_required : item.required;` can be simplified to use JavaScript's nullish coalescing operator (`??`) and logical OR operator (||) for better readability.",
"solutions": [
"Replace the line with:\n```javascript\nitem.required ||= item.is_required;\n```\nor if you prefer a more explicit version based on truthy values of `null`, `undefined`, or empty strings:\n```javascript\n// Option 1: Only consider non-empty strings or falsy but not true for required field.\ncurrentRequired = !!(item.required || '');\nif (!currentRequired && !!item.is_required) {\n currentRequired = item.is_required;\n}\notherwise...\n// Option 2: Use ternary operator directly.\nitem.required = item.required ?? item.is_required;\nmaybeOption3..\n```\nor simply,\nnormalized option without using conditionals for clarity:\n```javascript\nitem.normalizedRequiredValue = normalizeBoolean(item?.required ?? '');
function normalizeBoolean(rawValue) { // Helper function could also apply custom parsing logic here if needed.\n return rawValue !== false && rawValue !== '';\n}
```\n**Important Note:** Ensure consistency within your application regarding how boolean flags are handled before applying these solutions."
]
}
# Updated TypeScript Function Definition:
---
Now, please ensure that all files referenced in the above changes have their respective imports included:
- Import lodash for array cloning functionality.
- Import Vue components necessary for dynamic rendering within Vue templates.
Here is how it would look in one comprehensive solution format:
```typescript
import { ref, onMounted } from 'vue';
import { set, cloneDeep} from 'lodash';
import Sortable from 'sortablejs';
onMounted(async () => {
const inputFieldList = ref<Array<{ label?: string, field?: string, type: string, value?: any, input_type?: string, options?: object, required?: boolean | null }>>([
...
]);
}
/* Define a utility/helper function called normalizeBoolean here */
export async function validateInput(value): Promise<boolean> {
/* Check against some specific criteria to determine validity. For example,
valid inputs might include true/false, strings like 'enabled', 'yes',
numbers 1/0, etc. */
try {
if (/^true|false$/i.test(String(value))) {// Assuming 'value' is either a string or number
return String(value).toLowerCase() === 'true';
// Convert the given string into lower case for comparison ('true' & 'False' both will be considered as True)
}
throw new Error("Invalid boolean value!");
} catch(err){
console.error('An error occurred while validating:', err);
}
};
// And then call this helper whenever you need to validate any Boolean values.
shaohuzhang1
added a commit
that referenced
this pull request
Dec 17, 2025
…entering the canvas editing, it became a mandatory parameter (#4521)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: The user input parameter was set to non mandatory, but after re entering the canvas editing, it became a mandatory parameter