fix: STT model params add when create#4077
Conversation
|
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 |
| :disabled="!['TTS', 'LLM', 'IMAGE', 'TTI', 'TTV', 'ITV','STT'].includes(base_form_data.model_type)" | ||
| > | ||
| <AppIcon iconName="app-add-outlined" class="mr-4"/> {{ $t('common.add') }} | ||
| </el-button> |
There was a problem hiding this comment.
The code you provided is generally clean and well-formed, but there are a few small improvements that could be made for clarity and efficiency:
Improvements
-
Consistent Conditional Checks: Ensure consistency in how conditionals are checked. Here, it's good to use the
includesmethod consistently. -
Remove Unnecessary Disables: If an action should always be enabled (like adding), it might not need to be disabled under certain conditions.
Here's the updated code with these considerations:
<template>
<div v-if="base_form_data.model_type === 'RERANKER'">
<!-- Reranker specific content -->
</div>
<el-empty v-else-if="['EMBEDDING','STT'].some(type => type === base_form_data.model_type)">
:description="$t('views.model.tip.emptyMessage2')"
</el-empty>
<template v-else>
<div v-if="hasAddActionAvailable">{{ $t('common.add') }}</div>
<div v-else>-- Disabled --</div>
</template>
</template>
<script>
export default {
data() {
return {
hasAddActionAvailable: ['TTS', 'LLM', 'IMAGE', 'TTI', 'TTV', 'ITV','STT'].includes(this.base_form_data.model_type)
};
}
};
</script>Key Changes
-
Single Condition Check with Includes: Used
.some()method instead of multiple||checks to determine ifbase_form_data.model_typeis one of the values related to empty messages (RERANKER,'EMBEDDING',or'STT'). -
Computed Property: Introduced a computed property
hasAddActionAvailableto simplify disabling logic by directly checking against a predetermined list.
This approach maintains readability while optimizing the conditional checking process.
fix: STT model params add when create