Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ui/src/workflow/common/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export const dataSourceLocalNode = {
height: 728.375,
stepName: t('views.workflow.nodes.dataSourceLocalNode.label'),
input_field_list: [],
node_data: {},
config: {
fields: [
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no major irregularities or significant issues in the provided code snippet. However, there is an unnecessary property (node_data) being defined within the config object. This could be removed as it seems to serve no purpose at this point.

Here's a revised version of the code that removes the unused node_data property:

// ...

export const dataSourceLocalNode = {
  height: 728.375,
  stepName: t('views.workflow.nodes.dataSourceLocalNode.label'),
  input_field_list: [],
  // Removed: node_data: {},
  config: {
    fields: [
      {
        // ...
      }
    ],
    // Other configuration properties...
  },
};

This change reduces redundancy and maintains clarity in the component's structure.

Expand Down
6 changes: 3 additions & 3 deletions ui/src/workflow/nodes/data-source-local-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ const props = defineProps<{ nodeModel: any }>()

const file_type_list_options = ['TXT', 'DOCX', 'PDF', 'HTML', 'XLS', 'XLSX', 'ZIP', 'CSV']
const form = {
file_type_list: [],
file_size_limit: 50,
file_count_limit: 100,
file_type_list: ['TXT', 'DOCX', 'PDF', 'HTML', 'XLS', 'XLSX', 'ZIP', 'CSV'],
file_size_limit: 100,
file_count_limit: 50,
}

const form_data = computed({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code does not contain any immediate irregularities, but there are some areas where it can be improved or optimized:

  1. Prop Default Values: The nodeModel prop is defined with any, which should ideally specify a more specific type for better TypeScript type checking.

  2. Form Initialization: While the current initial values of form_type_list and file_count_limit seem appropriate, having these hard-coded in JavaScript literals can make it harder to modify later if needed. Consider using an environment variable or configuration file to manage static data like this.

  3. Computed Properties: Using computed to calculate properties that only depend on reactive data is generally good practice. However, ensure there's no unnecessary computation happening within these computed properties.

  4. Code Style Consistency: Ensure consistent spacing and indentation throughout the codebase, as it improves readability and maintainability.

Here's a slightly modified version with some of these considerations:

import { defineProps, computed } from 'vue';

const props = defineProps<{ nodeModel: any }>();

// Define static constants outside components to improve reusability and maintainability
export const FILE_TYPE_LIST_OPTIONS = [
  'TXT',
  'DOCX',
  'PDF',
  'HTML',
  'XLS',
  'XLSX',
  'ZIP',
  'CSV'
];

const form = {
  file_type_list: FILE_TYPE_LIST_OPTIONS,
  // Set reasonable limits for file size and count considering typical use cases
  file_size_limit: 100 * 1024 * 1024, // e.g., 100 MB
  file_count_limit: 50,
};

const formData = computed(() => ({
  selectedFileTypeList: getSelectedFileTypes(), // Implement a helper function separately
}));

// Helper function to filter out unselected types dynamically based on user input
function getSelectedFileTypes() {
  // Example logic: return checked/selected file types here
}

Summary:

  • Use defineProps consistently throughout your Vue.js application.
  • Separate dynamic configuration (like default values) into modules or external files.
  • Avoid redundant computations within computed properties unless absolutely necessary.
  • Maintain consistency through proper coding style practices.

Expand Down
Loading