Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster Explorer: Restrict / Remove usages of findAll: traditional types #13025

Merged
merged 93 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
25c0c70
cluster list now uses resource table
richard-cox Aug 6, 2024
eda38cf
New PaginatedResourceTable
richard-cox Aug 6, 2024
8e120d0
WIP
richard-cox Aug 8, 2024
203cdfd
add context to pag setting
richard-cox Aug 12, 2024
a0a6883
tidying up
richard-cox Aug 12, 2024
8b03d56
Add server-side pagination to cluster explorer events and general eve…
richard-cox Aug 20, 2024
dcd69ed
Servier-side pagination for catalog apps, cluster repo and operation
richard-cox Aug 23, 2024
34e173b
Servier-side pagination for Service --> HPA, inmgress, services
richard-cox Aug 23, 2024
8e0fabc
Server-side pagination for home page clusters list and side bar clusters
richard-cox Nov 14, 2024
bbf4bcd
Merge branch 'pagination-home-page' into pagination-cluster-explorer
richard-cox Nov 14, 2024
6bfc45d
fixes after merge. apply PagResTable to node list, vue3 fixes
richard-cox Nov 14, 2024
1f61ce5
- Fix issue where list components containing PaginatedResourceTables …
richard-cox Nov 15, 2024
16d1a0f
policy section
richard-cox Nov 15, 2024
006debb
fix async button in manual refresh mode
richard-cox Nov 15, 2024
2454ad3
fgh
richard-cox Nov 15, 2024
a94360e
aaaaa
richard-cox Dec 2, 2024
419cc30
Server-side pagination for home page clusters list and side bar clusters
richard-cox Nov 14, 2024
f1858b6
Iteration
richard-cox Dec 2, 2024
475aaef
Merge branch 'pagination-home-page' into pagination-cluster-explorer
richard-cox Dec 2, 2024
96b6b9a
Fix dupe inStore
richard-cox Dec 3, 2024
c61ad5f
Merge remote-tracking branch 'origin/pagination-home-page' into pagin…
richard-cox Dec 3, 2024
442d85c
Fix dupe inStore
richard-cox Dec 3, 2024
fdc99ee
Merge remote-tracking branch 'origin/pagination-home-page' into pagin…
richard-cox Dec 3, 2024
cb18993
Two fixes
richard-cox Dec 4, 2024
0054f40
Merge remote-tracking branch 'origin/pagination-home-page' into pagin…
richard-cox Dec 4, 2024
66f73da
fixes / updates
richard-cox Dec 4, 2024
a6810c1
testing/tidying
richard-cox Dec 4, 2024
6f56573
WIP - Rest of workload lists
richard-cox Dec 4, 2024
d626da2
finish off workloads
richard-cox Dec 5, 2024
850721b
tidying up
richard-cox Dec 5, 2024
aa269e4
fix non-generic list filtering by namespace
richard-cox Dec 5, 2024
0cc6ba3
remove comment, backport fix
richard-cox Dec 5, 2024
559e33e
test fixes
richard-cox Dec 5, 2024
eb96204
E2E: Ensure we wait for cluster entries to exist before clicking on them
richard-cox Dec 5, 2024
3907b29
backport fix for local/api filtering
richard-cox Dec 5, 2024
545da46
Remove debug code
richard-cox Dec 6, 2024
28135a1
Changes after review
richard-cox Dec 9, 2024
8130cca
e2e fixes / debugging
richard-cox Dec 9, 2024
7b89a85
More e2e fixes
richard-cox Dec 9, 2024
f16a1de
More e2e fixes
richard-cox Dec 9, 2024
3dd8839
More e2e fixes
richard-cox Dec 9, 2024
f2c555f
Fix generic pages that filter on pagination
richard-cox Dec 9, 2024
d7fc78c
Attempt to fix flaky vai test
richard-cox Dec 10, 2024
c2c96a5
Merge remote-tracking branch 'upstream/master' into pagination-home-page
richard-cox Dec 10, 2024
c18fd7a
Fix after merge from master
richard-cox Dec 10, 2024
9d01007
Updates following new indexed files
richard-cox Dec 10, 2024
439f223
Fix lint and test
richard-cox Dec 10, 2024
9b5d420
Changes given real cluster tests
richard-cox Dec 11, 2024
051a144
Merge remote-tracking branch 'upstream/master' into pagination-home-page
richard-cox Dec 12, 2024
39c2cd7
Fix issues with diplaying rke1 data in home page
richard-cox Dec 16, 2024
6b445fd
Fix unit tests
richard-cox Dec 16, 2024
95c693f
Merge branch 'pagination-home-page' into pagination-cluster-explorer
richard-cox Dec 16, 2024
710c3a5
remove invalid sort/filter type
richard-cox Dec 16, 2024
f837f88
Running through new indexed fields
richard-cox Dec 16, 2024
d8e12ba
fix unit tests
richard-cox Dec 16, 2024
8f02e8a
lint fixes
richard-cox Dec 16, 2024
958e9d0
Fixes after small review
richard-cox Dec 17, 2024
c3ae825
lint
richard-cox Dec 17, 2024
3844e8f
Test for check-plugin-gates pkg build from shell
richard-cox Dec 17, 2024
4ddf08a
e2e fixes
richard-cox Dec 17, 2024
182eded
Merge remote-tracking branch 'upstream/master' into pagination-cluste…
richard-cox Dec 18, 2024
096d290
Testing new indexed fields with dev image
richard-cox Dec 18, 2024
3d1b497
Merge remote-tracking branch 'upstream/master' into pagination-home-page
richard-cox Dec 18, 2024
766cf93
Merge remote-tracking branch 'origin/pagination-home-page' into pagin…
richard-cox Dec 18, 2024
aa73f3d
tidyuing up imports in hope to fix ts error in check-plugins gate
richard-cox Dec 18, 2024
7e4ee6a
Merge remote-tracking branch 'upstream/master' into pagination-cluste…
richard-cox Dec 18, 2024
5916758
Fix failing check-plugin-gates
richard-cox Dec 18, 2024
dca2c2e
Merge remote-tracking branch 'upstream/master' into pagination-cluste…
richard-cox Jan 3, 2025
595ea90
tidying up a smidge
richard-cox Jan 3, 2025
e227f3e
Many tweaks
richard-cox Jan 6, 2025
a9ea060
Improve location of new place where componentWillFetch is set
richard-cox Jan 6, 2025
dc5a5a3
fix lint, comment updated
richard-cox Jan 6, 2025
00db7c9
Fix failing e2e tests
richard-cox Jan 7, 2025
11eda66
WIP
richard-cox Jan 7, 2025
cb87aa3
Remove ununused component, tweaks, update ResourceTabs events to be s…
richard-cox Jan 7, 2025
f589ccf
wip
richard-cox Jan 8, 2025
05eabe9
Merge remote-tracking branch 'upstream/master' into pagination-remove…
richard-cox Jan 8, 2025
92430b3
Finish off questions/reference
richard-cox Jan 8, 2025
31b3bd7
Namespace detail - workloads list
richard-cox Jan 8, 2025
17778da
Update ingress detail and edit pages
richard-cox Jan 8, 2025
fb203f9
tidying up ready for review
richard-cox Jan 9, 2025
86ae345
Tidying up ready to review
richard-cox Jan 9, 2025
221e787
Merge branch 'pagination-remove-findall-1' into pagination-remove-fin…
richard-cox Jan 9, 2025
0919441
finish off functional stuff
richard-cox Jan 9, 2025
7cb061b
fix lint
richard-cox Jan 13, 2025
1fe4b89
Merge remote-tracking branch 'upstream/master' into pagination-remove…
richard-cox Jan 13, 2025
96e30e2
Tidy up event headers
richard-cox Jan 13, 2025
898b903
Fix lint and unit test
richard-cox Jan 13, 2025
972e85e
Changes following review
richard-cox Jan 23, 2025
51f21ab
Merge remote-tracking branch 'upstream/master' into pagination-remove…
richard-cox Jan 23, 2025
bec8e7a
missed a param
richard-cox Jan 23, 2025
c19aabe
Move PaginatedResourceTable and ResourceLabeledSelect to type file, i…
richard-cox Jan 23, 2025
8ff97aa
fix linting
richard-cox Jan 23, 2025
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
2 changes: 1 addition & 1 deletion cypress/e2e/tests/pages/fleet/advanced/workspaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Workspaces', { testIsolation: 'off', tags: ['@fleet', '@adminUser'] },
let initialCount: number;

it('check table headers are available in list and details view', () => {
FleetWorkspaceListPagePo.navTo();
fleetWorkspacesPage.goTo();
fleetWorkspacesPage.waitForPage();
fleetWorkspacesPage.sortableTable().noRowsShouldNotExist();
fleetWorkspacesPage.sortableTable().filter(defaultWorkspace);
Expand Down
11 changes: 4 additions & 7 deletions shell/components/PaginatedResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
import { defineComponent } from 'vue';
import ResourceFetch from '@shell/mixins/resource-fetch';
import ResourceTable from '@shell/components/ResourceTable.vue';
import { StorePaginationResult } from '@shell/types/store/pagination.types';

export type FetchSecondaryResourcesOpts = { canPaginate: boolean }
export type FetchSecondaryResources = (opts: FetchSecondaryResourcesOpts) => Promise<any>

export type FetchPageSecondaryResourcesOpts = { canPaginate: boolean, force: boolean, page: any[], pagResult: StorePaginationResult }
export type FetchPageSecondaryResources = (opts: FetchPageSecondaryResourcesOpts) => Promise<any>

/**
* This is meant to enable ResourceList like capabilities outside of List pages / components
Expand Down Expand Up @@ -57,6 +50,8 @@ export default defineComponent({
* Information may be required from resources other than the primary one shown per row
*
* This will fetch them ALL and will be run in a non-server-side pagination world
*
* of type PagTableFetchSecondaryResources
*/
fetchSecondaryResources: {
type: Function,
Expand All @@ -69,6 +64,8 @@ export default defineComponent({
* This will fetch only those relevant to the current page using server-side pagination based filters
*
* called from shell/mixins/resource-fetch-api-pagination.js
*
* of type PagTableFetchPageSecondaryResources
*/
fetchPageSecondaryResources: {
type: Function,
Expand Down
85 changes: 57 additions & 28 deletions shell/components/Questions/Reference.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
import { LabeledInput } from '@components/Form/LabeledInput';
import LabeledSelect from '@shell/components/form/LabeledSelect';
import { filterBy } from '@shell/utils/array';
import ResourceLabeledSelect from '@shell/components/form/ResourceLabeledSelect.vue';
import { PaginationParamFilter } from '@shell/types/store/pagination.types';

import { PVC, STORAGE_CLASS } from '@shell/config/types';
import Question from './Question';

Expand All @@ -14,7 +15,7 @@ const LEGACY_MAP = {
export default {
emits: ['update:value'],

components: { LabeledInput, LabeledSelect },
components: { LabeledInput, ResourceLabeledSelect },
mixins: [Question],

props: {
Expand All @@ -29,12 +30,6 @@ export default {
},
},

async fetch() {
if ( this.typeSchema ) {
this.all = await this.$store.dispatch(`${ this.inStore }/findAll`, { type: this.typeName });
}
},

data() {
const t = this.question.type;

Expand All @@ -57,29 +52,61 @@ export default {
return {
typeName,
typeSchema,
all: [],
all: [],
allResourceSettings: {
updateResources: (all) => {
// Filter to only include required namespaced resources
const resources = this.isNamespaced ? all.filter((r) => r.metadata.namespace === this.targetNamespace) : all;

return this.mapResourcesToOptions(resources);
}
},
paginateResourceSetting: {
updateResources: (resources) => {
return this.mapResourcesToOptions(resources);
},
/**
* of type PaginateTypeOverridesFn
* @param [LabelSelectPaginationFunctionOptions] opts
* @returns LabelSelectPaginationFunctionOptions
*/
requestSettings: (opts) => {
// Filter to only include required namespaced resources
const filters = this.isNamespaced ? [
PaginationParamFilter.createSingleField({ field: 'metadata.namespace', value: this.targetNamespace }),
] : [];

return {
...opts,
filters,
groupByNamespace: false,
classify: true,
};
}
},
};
},

methods: {
mapResourcesToOptions(resources) {
return resources.map((r) => {
if (r.id) {
return {
label: r.nameDisplay || r.metadata.name,
value: r.metadata.name
};
} else {
return r;
}
});
},

},

computed: {
isNamespaced() {
return !!this.typeSchema?.attributes?.namespaced;
},

options() {
let out = this.all;

if ( this.isNamespaced ) {
out = filterBy(this.all, 'metadata.namespace', this.targetNamespace);
}

return out.map((x) => {
return {
label: x.nameDisplay || x.metadata.name,
value: x.metadata.name
};
});
}
},
};
</script>
Expand All @@ -90,15 +117,17 @@ export default {
class="row"
>
<div class="col span-6">
<LabeledSelect
:mode="mode"
:options="options"
<ResourceLabeledSelect
:resource-type="typeName"
:in-store="inStore"
:disabled="$fetchState.pending || disabled"
:label="displayLabel"
:placeholder="question.description"
:required="question.required"
:value="value"
:tooltip="displayTooltip"
:paginated-resource-settings="paginateResourceSetting"
:all-resources-settings="allResourceSettings"
Comment on lines +129 to +130
Copy link
Contributor

@codyrancher codyrancher Jan 22, 2025

Choose a reason for hiding this comment

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

By any chance do we want to keep the interface consistent with PaginatedResourceTable? i.e. api-filter and local-filter.

Or maybe update PaginatedResourceTable to use a settings style object.

Copy link
Member Author

Choose a reason for hiding this comment

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

when i stumbled over this again i had the same thought.

i'll update cover

  • prop names
  • make a common type to fetch / filter the resources

Copy link
Member Author

Choose a reason for hiding this comment

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

went full circle.

the prop names here better describe what the control is doing (showing all in a dropdown or showing pages in a dropdown), the function calls are also different in nature.

did tidy it up though and move the types into their own file, added jsdocs, etc c19aabe

@update:value="!$fetchState.pending && $emit('update:value', $event)"
/>
</div>
Expand Down
50 changes: 0 additions & 50 deletions shell/components/RelatedWorkloadsTable.vue

This file was deleted.

2 changes: 1 addition & 1 deletion shell/components/form/LabeledSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export default {

<template #list-footer>
<div
v-if="canPaginate && totalResults"
v-if="canPaginate && totalResults && pages > 1"
class="pagination-slot"
>
<div class="load-more">
Expand Down
66 changes: 13 additions & 53 deletions shell/components/form/ResourceLabeledSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,8 @@ import { PropType, defineComponent } from 'vue';
import LabeledSelect from '@shell/components/form/LabeledSelect.vue';
import { PaginationParamFilter } from '@shell/types/store/pagination.types';
import { labelSelectPaginationFunction, LabelSelectPaginationFunctionOptions } from '@shell/components/form/labeled-select-utils/labeled-select.utils';
import { LabelSelectPaginateFn, LabelSelectPaginateFnOptions, LabelSelectPaginateFnResponse } from '@shell/types/components/labeledSelect';

type PaginateTypeOverridesFn = (opts: LabelSelectPaginationFunctionOptions) => LabelSelectPaginationFunctionOptions;

interface SharedSettings {
/**
* Provide specific LabelSelect options for this mode (paginated / not paginated)
*/
labelSelectOptions?: { [key: string]: any },
/**
* Map the resources shown in LabelSelect
*/
mapResult?: (resources: any[]) => any[]
}

/**
* Settings to use when the LabelSelect is paginating
*/
export interface ResourceLabeledSelectPaginateSettings extends SharedSettings {
/**
* Override the convience function which fetches a page of results
*/
overrideRequest?: LabelSelectPaginateFn,
/**
* Override the default settings used in the convenience function to fetch a page of results
*/
requestSettings?: PaginateTypeOverridesFn,
}

/**
* Settings to use when the LabelSelect is fetching all resources (not paginating)
*/
export type ResourceLabeledSelectSettings = SharedSettings

/**
* Force a specific mode
*/
export enum RESOURCE_LABEL_SELECT_MODE {
/**
* Fetch all resources
*/
ALL_RESOURCES = 'ALL', // eslint-disable-line no-unused-vars
/**
* Determine if all resources are fetched given system settings
*/
DYNAMIC = 'DYNAMIC', // eslint-disable-line no-unused-vars
}
import { LabelSelectPaginateFnOptions, LabelSelectPaginateFnResponse } from '@shell/types/components/labeledSelect';
import { RESOURCE_LABEL_SELECT_MODE, ResourceLabeledSelectPaginateSettings, ResourceLabeledSelectSettings } from '@shell/types/components/resourceLabeledSelect';

/**
* Convenience wrapper around the LabelSelect component to support pagination
Expand All @@ -66,6 +21,8 @@ export default defineComponent({

components: { LabeledSelect },

emits: ['update:value'],

props: {
/**
* Resource to show
Expand All @@ -89,15 +46,15 @@ export default defineComponent({
},

/**
* Specific settings to use when we're showing all results
* Specific settings to use when we're showing all results in the drop down
*/
allResourcesSettings: {
type: Object as PropType<ResourceLabeledSelectSettings>,
default: null,
},

/**
* Specific settings to use when we're showing paginated results
* Specific settings to use when we're showing paginated results in the drop down
*/
paginatedResourceSettings: {
type: Object as PropType<ResourceLabeledSelectPaginateSettings>,
Expand All @@ -120,6 +77,7 @@ export default defineComponent({
}

if (!this.paginate) {
// The resource won't be paginated and component expects everything up front
await this.$store.dispatch(`${ this.inStore }/findAll`, { type: this.resourceType });
}
},
Expand Down Expand Up @@ -148,13 +106,14 @@ export default defineComponent({

const all = this.$store.getters[`${ this.inStore }/all`](this.resourceType);

return this.allResourcesSettings?.mapResult ? this.allResourcesSettings.mapResult(all) : all;
return this.allResourcesSettings?.updateResources ? this.allResourcesSettings.updateResources(all) : all;
}
},

methods: {
/**
* Typeof LabelSelectPaginateFn
* Make the request to fetch the resource given the state of the label select (filter, page, page size, etc see LabelSelectPaginateFn)
* opts: Typeof LabelSelectPaginateFn
*/
async paginateType(opts: LabelSelectPaginateFnOptions): Promise<LabelSelectPaginateFnResponse> {
if (this.paginatedResourceSettings?.overrideRequest) {
Expand All @@ -175,9 +134,9 @@ export default defineComponent({
const options = this.paginatedResourceSettings?.requestSettings ? this.paginatedResourceSettings.requestSettings(defaultOptions) : defaultOptions;
const res = await labelSelectPaginationFunction(options);

return this.paginatedResourceSettings?.mapResult ? {
return this.paginatedResourceSettings?.updateResources ? {
...res,
page: this.paginatedResourceSettings.mapResult(res.page)
page: this.paginatedResourceSettings.updateResources(res.page)
} : res;
},
},
Expand All @@ -190,5 +149,6 @@ export default defineComponent({
:loading="$fetchState.pending"
:options="allOfType"
:paginate="paginateType"
@update:value="$emit('update:value', $event)"
/>
</template>
1 change: 1 addition & 0 deletions shell/components/form/ResourceSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
},

async fetch() {
// Used in conjunction with `matches/match/label selectors`. Requires https://github.com/rancher/dashboard/issues/10417 to fix
const hash = await allHash({ allResources: this.$store.dispatch('cluster/findAll', { type: this.type }) });

this.allResources = hash.allResources;
Expand Down
Loading
Loading