diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 1ec53288..8d4774c2 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: ".nvmrc" cache: "npm" @@ -26,9 +26,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: ".nvmrc" cache: "npm" @@ -43,9 +43,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: ".nvmrc" cache: "npm" diff --git a/app/components/atoms/DataTable.vue b/app/components/atoms/DataTable.vue index 755fc5ac..cd23b95d 100644 --- a/app/components/atoms/DataTable.vue +++ b/app/components/atoms/DataTable.vue @@ -7,20 +7,27 @@ const emit = defineEmits<{ invalidate: [] }>() -const props = defineProps<{ - columns: ColumnDef[] - data: any[] - loading: boolean - options?: Partial> - emptyMessage?: string - permission?: boolean | ((item: any) => Promise) - expandedMarkup?: (row: Row) => VNode -}>() +const props = withDefaults( + defineProps<{ + columns: ColumnDef[] + data: any[] + loading: boolean + options?: Partial> + emptyMessage?: string + permission?: boolean | ((item: any) => Promise) + expandedMarkup?: (row: Row) => VNode + pageSize?: number + }>(), + { + pageSize: 10, + }, +) const globalFilter = ref('') const sorting = ref(props.options?.initialState?.sorting || []) -const pagination = ref({ pageIndex: 0, pageSize: 10 }) +const pagination = ref({ pageIndex: 0, pageSize: props.pageSize }) const rowSelectionPermissions = ref>({}) +const permissionFetchVersion = ref(0) // Convert 0-based to 1-based for Radix const internalPage = computed({ @@ -31,18 +38,19 @@ const internalPage = computed({ const selectedRowLength = computed(() => table.getSelectedRowModel().rows.length) watch( - () => props.data?.length, - async (length) => { - if (length) await fetchPermissions() - }, - { immediate: true }, -) + () => ({ + permission: props.permission, + ids: (props.data || []).map(item => String(item.id)), + }), + async ({ ids }) => { + if (!ids.length) { + rowSelectionPermissions.value = {} + return + } -watch( - () => props.permission, - async () => { - if (props.data?.length) await fetchPermissions() + await fetchPermissions() }, + { immediate: true }, ) const table = useVueTable({ @@ -79,6 +87,7 @@ const search = ref(table.getState().globalFilter) watch(search, newValue => table.setGlobalFilter(newValue)) async function fetchPermissions() { + const currentFetchVersion = ++permissionFetchVersion.value const permissions: Record = {} for (const item of props.data) { @@ -87,6 +96,8 @@ async function fetchPermissions() { else permissions[item.id] = true } + if (currentFetchVersion !== permissionFetchVersion.value) return + rowSelectionPermissions.value = permissions } diff --git a/app/components/ui/alert-dialog/AlertDialogAction.vue b/app/components/ui/alert-dialog/AlertDialogAction.vue index bc6363f0..2e1c9ec8 100644 --- a/app/components/ui/alert-dialog/AlertDialogAction.vue +++ b/app/components/ui/alert-dialog/AlertDialogAction.vue @@ -16,7 +16,7 @@ const delegatedProps = computed(() => {