Skip to content

fix: Doc status filter#4893

Merged
zhanweizhang7 merged 1 commit intov2from
pr@v2@fix_doc_status
Mar 17, 2026
Merged

fix: Doc status filter#4893
zhanweizhang7 merged 1 commit intov2from
pr@v2@fix_doc_status

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Doc status filter

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 17, 2026

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.

Details

Instructions 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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 17, 2026

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

</template>
<template #default="{ row }">
<StatusValue :status="row.status" :status-meta="row.status_meta"></StatusValue>
</template>
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 snippet has several improvements that can be made to improve its readability and functionality. Here are some notes:

  1. Consistent Spacing: Ensure consistent spacing around operators and braces for better readability.

  2. Comments Formatting: Add comments with proper formatting to explain each part of the template.

  3. Code Duplication: The filterMethod is checked multiple times in different places, which could lead to duplication. Consider abstracting this logic into a helper function.

  4. Template String Consistency: Use single quotes consistently for string interpolation within templates.

  5. Dropdown Styling: Improve the styling of the dropdown button by adding more specific CSS classes or using Flexbox for center alignment.

Here's an improved version of the code with these considerations taken into account:

<template>
  <v-data-table header-class="custom-header" :items-per-page.sync="page_size">
    <!-- Table Header -->
    <template #[`item.${column.name}`] v-for="column in headers" :key="column.value">
      <!-- Custom Status Status Column -->
      <div v-if="column.value === 'fileStatus'" slot-scope="{ item }">
        <div>
          <span>{{ $t('views.document.fileStatus.label') }}</span>
          <el-dropdown trigger="click" @command="dropdownHandle">
            <el-button
              style="margin-top: 1px"
              link
              :type="filterMethod && filterMethod['status'] ? 'primary' : ''"
            >
              <el-icon><Filter /></el-icon>
            </el-button>
            <template #dropdown>
              <el-dropdown-menu class="dropdown-container">
                <el-dropdown-item
                  :class="(filterMethod && filterMethod['status']) !== state.ALL_STATUS ? '' : 'is-active'"
                  command="ALL_STATUS"
                  class="justify-center"
                >
                  {{ $t('common.status.all') }}
                </el-dropdown-item>
                <!-- ... (remaining items) ... -->
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>

        <!-- Conditionally render status value component if needed -->
        <StatusValue v-if="displayCondition(item)" :status="item.status" :status-meta="item.status_meta"></StatusValue>
      </div>
      <!-- Render other table columns similarly -->
    </template>
  </v-data-table>
</template>

<script>
import { ref, computed } from '@vue/composition-api';
import { State, TaskType } from '@/enums'; // Adjust import path based on actual context

export default {
  setup() {
    const page_size = ref(10);
    const headers = [
      // Your data.table.headers definition
    ];
    const displayCondition = (row) => {
      // Example condition to determine if status value column should be rendered
      return row.someAttribute; // Replace 'someAttribute' with appropriate logic
    };

    const dropdownHandle = (command) => {
      switch (command) {
        case state.ALL_STATUS:
          // Handle all statuses command
          break;
       case State.SUCCESS:
          // Handle success status command
          break;
        case State.FAILURE:
          // Handle failure status command
          break;
        // Add cases for other status values and task types if needed
        default:
          console.warn(`Unsupported filter method: ${command}`);
          break;
      }
    };

    // Define filterMethods and other helpers as necessary
    const filterMethods = reactive({
      status: null,
    });

    const beforeCommand = (property, subProperty) => () => ({
      property,
      subProperty,
    });

    return {
      page_size,
      headers,
      displayCondition,
      dropdownHandle,
      filterMethod: computed(() => Object.assign({}, filterMethods)),
      // Bind beforeCommand for filtering purposes
      before_command(property, subProperty) {
        setImmediate(() => {
          filterMethods[property] = subProperty;
          performFilter();
        });
      },
    };
  },
};
</script>

<style scoped>
.custom-header {
  /* Add custom styles here */
}
.dropdown-container {
  max-width: 100%;
  padding: 10px;
}
.el-icon {
  vertical-align: middle;
}
</style>

These changes address most of the identified issues. You can further optimize based on your specific requirements.

@zhanweizhang7 zhanweizhang7 merged commit ec3257c into v2 Mar 17, 2026
3 of 4 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_doc_status branch March 17, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants