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

Remove usages of findAll for core resources in cluster explorer view - 1 #13006

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 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
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
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
:resourceType="typeName"
:inStore="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"
@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 @@ -383,7 +383,7 @@ export default {

<template #list-footer>
<div
v-if="canPaginate && totalResults"
v-if="canPaginate && totalResults && pages > 1"
Copy link
Member Author

Choose a reason for hiding this comment

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

hide the bottom area of the open drawer if there's no page controls

(visible here, removed if there's a single page)
image

class="pagination-slot"
>
<div class="load-more">
Expand Down
19 changes: 12 additions & 7 deletions shell/components/form/ResourceLabeledSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ interface SharedSettings {
*/
labelSelectOptions?: { [key: string]: any },
/**
* Map the resources shown in LabelSelect
* Map, filter, tweak, etc the resources to show in the LabelSelect
*/
mapResult?: (resources: any[]) => any[]
updateResources?: (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
* Override the convenience function which fetches a page of results
*/
overrideRequest?: LabelSelectPaginateFn,
/**
Expand Down Expand Up @@ -66,6 +66,8 @@ export default defineComponent({

components: { LabeledSelect },

emits: ['update:value'],

props: {
/**
* Resource to show
Expand Down Expand Up @@ -120,6 +122,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 +151,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 +179,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 +194,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