mirror of https://github.com/rancher/dashboard.git
Merge pull request #15011 from richard-cox/fix-resource-detail-updates
Fix general and specific resource detail watch issues
This commit is contained in:
parent
521ad9014d
commit
8c474ff64c
|
|
@ -311,6 +311,16 @@ export default {
|
|||
|
||||
this.matchingIngresses = matchingIngresses;
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
async 'value.jobRelationships.length'(neu, old) {
|
||||
// If there are MORE jobs ensure we go out and fetch them (changes and removals are tracked by watches)
|
||||
if (neu > old) {
|
||||
// We don't need to worry about spam, this won't be called often and it will be infrequent
|
||||
await this.value.matchingJobs();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
unmounted() {
|
||||
async beforeUnmount() {
|
||||
if (this.havePaginated) {
|
||||
// of type @STEVE_WATCH_PARAMS
|
||||
const watchArgs = {
|
||||
|
|
@ -360,9 +360,8 @@ export default {
|
|||
mode: STEVE_WATCH_MODE.RESOURCE_CHANGES,
|
||||
};
|
||||
|
||||
this.$store.dispatch(`${ this.overrideInStore || this.inStore }/forgetType`, this.resource, (watchParams) => {
|
||||
return watchParams.type === watchArgs.type &&
|
||||
watchParams.mode === watchArgs.type.mode;
|
||||
await this.$store.dispatch(`${ this.overrideInStore || this.inStore }/forgetType`, this.resource, (watchParams) => {
|
||||
return watchParams.type === watchArgs.type && watchParams.mode === watchArgs.type.mode;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { findBy, insertAt } from '@shell/utils/array';
|
||||
import { CATTLE_PUBLIC_ENDPOINTS } from '@shell/config/labels-annotations';
|
||||
import { WORKLOAD_TYPES, SERVICE, POD } from '@shell/config/types';
|
||||
import { get, set } from '@shell/utils/object';
|
||||
import { set } from '@shell/utils/object';
|
||||
import day from 'dayjs';
|
||||
import { convertSelectorObj, parse } from '@shell/utils/selector';
|
||||
import { SEPARATOR } from '@shell/config/workload';
|
||||
|
|
@ -632,7 +632,7 @@ export default class Workload extends WorkloadService {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return (get(this, 'metadata.relationships') || []).filter((relationship) => relationship.toType === WORKLOAD_TYPES.JOB);
|
||||
return this.metadata?.relationships?.filter((relationship) => relationship.toType === WORKLOAD_TYPES.JOB) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -79,6 +79,29 @@ const findAllGetter = (getters, type, opt) => {
|
|||
return opt.namespaced ? getters.matching(type, null, opt.namespaced, { skipSelector: true }) : getters.all(type);
|
||||
};
|
||||
|
||||
const createFindWatchArg = ({
|
||||
type, id, opt, res
|
||||
}) => {
|
||||
const revision = typeof opt.revision !== 'undefined' ? opt.revision : res?.metadata?.resourceVersion;
|
||||
const watchMsg = {
|
||||
type,
|
||||
id,
|
||||
// Although not used by sockets, we need this for when resyncWatch calls find... which needs namespace to construct the url
|
||||
namespace: opt.namespaced,
|
||||
revision: revision || '',
|
||||
force: opt.forceWatch === true,
|
||||
};
|
||||
|
||||
const idx = id.indexOf('/');
|
||||
|
||||
if ( idx > 0 ) {
|
||||
watchMsg.namespace = id.substr(0, idx);
|
||||
watchMsg.id = id.substr(idx + 1);
|
||||
}
|
||||
|
||||
return watchMsg;
|
||||
};
|
||||
|
||||
export default {
|
||||
request() {
|
||||
throw new Error('Not Implemented');
|
||||
|
|
@ -657,6 +680,12 @@ export default {
|
|||
out = getters.byId(type, id);
|
||||
|
||||
if ( out ) {
|
||||
if ( opt.watch !== false ) {
|
||||
dispatch('watch', createFindWatchArg({
|
||||
type, id, opt, res: undefined
|
||||
}));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
@ -669,26 +698,9 @@ export default {
|
|||
await dispatch('load', { data: res });
|
||||
|
||||
if ( opt.watch !== false ) {
|
||||
const watchMsg = {
|
||||
type,
|
||||
id,
|
||||
// Although not used by sockets, we need this for when resyncWatch calls find... which needs namespace to construct the url
|
||||
namespace: opt.namespaced,
|
||||
// Override the revision. Used in cases where we need to avoid using the resource's own revision which would be `too old`.
|
||||
// For the above case opt.revision will be `null`. If left as `undefined` the subscribe mechanism will try to determine a revision
|
||||
// from resources in store (which would be this one, with the too old revision)
|
||||
revision: typeof opt.revision !== 'undefined' ? opt.revision : res?.metadata?.resourceVersion,
|
||||
force: opt.forceWatch === true,
|
||||
};
|
||||
|
||||
const idx = id.indexOf('/');
|
||||
|
||||
if ( idx > 0 ) {
|
||||
watchMsg.namespace = id.substr(0, idx);
|
||||
watchMsg.id = id.substr(idx + 1);
|
||||
}
|
||||
|
||||
dispatch('watch', watchMsg);
|
||||
dispatch('watch', createFindWatchArg({
|
||||
type, id, opt, res
|
||||
}));
|
||||
}
|
||||
|
||||
out = getters.byId(type, id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue