Skip to content

Commit

Permalink
Merge pull request #11510 from richard-cox/fix-pag-label-select
Browse files Browse the repository at this point in the history
Paginated Label Select Fixes
  • Loading branch information
richard-cox authored Jul 23, 2024
2 parents 9171bfe + 08f05e2 commit e108b95
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions shell/components/form/ResourceLabeledSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ export default defineComponent({
computed: {
labelSelectAttributes() {
// This component is a wrapper for LabelSelect, so pass through everything
const allAttrs = {
...this.$attrs, // Attributes (other than props)
...this.$props, // Attributes that are props
};
return this.paginate ? {
...this.$attrs,
...allAttrs,
...this.paginatedResourceSettings?.labelSelectOptions || {}
} : {
...this.$attrs,
...allAttrs,
...this.allResourcesSettings?.labelSelectOptions || {}
};
},
Expand All @@ -156,7 +162,9 @@ export default defineComponent({
}
const { filter } = opts;
const filters = !!filter ? [PaginationParamFilter.createSingleField({ field: 'metadata.name', value: filter })] : [];
const filters = !!filter ? [PaginationParamFilter.createSingleField({
field: 'metadata.name', value: filter, exact: false
})] : [];
const defaultOptions: LabelSelectPaginationFunctionOptions = {
opts,
filters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export async function labelSelectPaginationFunction<T>({

return {
page: resPage,
pages: res.pages,
pages: res.pages || Math.ceil(res.count / (pageSize || Number.MAX_SAFE_INTEGER)),
total: res.count
};
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion shell/plugins/dashboard-store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export default {
},
result: {
count: out.count,
pages: out.pages,
pages: out.pages || Math.ceil(out.count / (opt.pagination.pageSize || Number.MAX_SAFE_INTEGER)),
timestamp: new Date().getTime()
}
} : undefined,
Expand Down
2 changes: 1 addition & 1 deletion shell/types/store/pagination.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class PaginationParamFilter extends PaginationParam {
/**
* Convenience method when you just want an instance of {@link PaginationParamFilter} with a simple `filter=x=y` param
*/
static createSingleField(field: { field?: string; value: string; equals?: boolean; }): PaginationParam {
static createSingleField(field: { field?: string; value: string; equals?: boolean; exact?: boolean }): PaginationParam {
return new PaginationParamFilter({ fields: [new PaginationFilterField(field)] });
}

Expand Down

0 comments on commit e108b95

Please sign in to comment.