mirror of https://github.com/rancher/dashboard.git
fix namespace recent events page
This commit is contained in:
parent
ef6d0a8ffb
commit
87faeeb904
|
|
@ -5815,6 +5815,8 @@ resourceTabs:
|
||||||
tab: Conditions
|
tab: Conditions
|
||||||
events:
|
events:
|
||||||
tab: Recent Events
|
tab: Recent Events
|
||||||
|
namespaceTab: "Events in Namespace"
|
||||||
|
namespaceCaption: "Shows all events from resources in <span class='namespace-name'><b>{namespace}</b></span> namespace"
|
||||||
related:
|
related:
|
||||||
tab: Related Resources
|
tab: Related Resources
|
||||||
from: Referred To By
|
from: Referred To By
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import Tabbed from '@shell/components/Tabbed';
|
||||||
import Tab from '@shell/components/Tabbed/Tab';
|
import Tab from '@shell/components/Tabbed/Tab';
|
||||||
import CreateEditView from '@shell/mixins/create-edit-view';
|
import CreateEditView from '@shell/mixins/create-edit-view';
|
||||||
import Conditions from '@shell/components/form/Conditions';
|
import Conditions from '@shell/components/form/Conditions';
|
||||||
import { EVENT } from '@shell/config/types';
|
import { EVENT, NAMESPACE } from '@shell/config/types';
|
||||||
import PaginatedResourceTable from '@shell/components/PaginatedResourceTable.vue';
|
import PaginatedResourceTable from '@shell/components/PaginatedResourceTable.vue';
|
||||||
import { _VIEW } from '@shell/config/query-params';
|
import { _VIEW } from '@shell/config/query-params';
|
||||||
import RelatedResources from '@shell/components/RelatedResources';
|
import RelatedResources from '@shell/components/RelatedResources';
|
||||||
|
|
@ -119,6 +119,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
isNamespace() {
|
||||||
|
return this.value?.type === NAMESPACE;
|
||||||
|
},
|
||||||
showEvents() {
|
showEvents() {
|
||||||
return this.isView && this.needEvents && this.eventSchema;
|
return this.isView && this.needEvents && this.eventSchema;
|
||||||
},
|
},
|
||||||
|
|
@ -190,7 +193,9 @@ export default {
|
||||||
* Filter out hidden repos from list of all repos
|
* Filter out hidden repos from list of all repos
|
||||||
*/
|
*/
|
||||||
filterEventsLocal(rows) {
|
filterEventsLocal(rows) {
|
||||||
return rows.filter((event) => event.involvedObject?.uid === this.value?.metadata?.uid);
|
return rows.filter((event) => {
|
||||||
|
return this.isNamespace ? event.metadata?.namespace === this.value?.metadata?.name : event.involvedObject?.uid === this.value?.metadata?.uid;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -204,27 +209,22 @@ export default {
|
||||||
pagination.filters = [];
|
pagination.filters = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const field = `involvedObject.uid`;
|
// Determine the field and value based on type
|
||||||
|
const field = this.isNamespace ? 'metadata.namespace' : 'involvedObject.uid';
|
||||||
|
const value = this.isNamespace ? this.value.metadata.name : this.value.metadata.uid;
|
||||||
|
|
||||||
// of type PaginationParamFilter
|
// Check if a filter for this field already exists
|
||||||
let existing = null;
|
const existing = pagination.filters.find((f) => f.fields.some((ff) => ff.field === field));
|
||||||
|
|
||||||
for (let i = 0; i < pagination.filters.length; i++) {
|
|
||||||
const filter = pagination.filters[i];
|
|
||||||
|
|
||||||
if (!!filter.fields.find((f) => f.field === field)) {
|
|
||||||
existing = filter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create the required filter
|
||||||
const required = PaginationParamFilter.createSingleField({
|
const required = PaginationParamFilter.createSingleField({
|
||||||
field,
|
field,
|
||||||
exact: true,
|
exact: true,
|
||||||
value: this.value.metadata.uid,
|
value,
|
||||||
equals: true
|
equals: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Merge or add the filter
|
||||||
if (!!existing) {
|
if (!!existing) {
|
||||||
Object.assign(existing, required);
|
Object.assign(existing, required);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -260,10 +260,16 @@ export default {
|
||||||
|
|
||||||
<Tab
|
<Tab
|
||||||
v-if="showEvents"
|
v-if="showEvents"
|
||||||
label-key="resourceTabs.events.tab"
|
:label="isNamespace ? t('resourceTabs.events.namespaceTab') : t('resourceTabs.events.tab')"
|
||||||
name="events"
|
name="events"
|
||||||
:weight="-2"
|
:weight="-2"
|
||||||
>
|
>
|
||||||
|
<!-- Caption for namespace pages -->
|
||||||
|
<div
|
||||||
|
v-if="isNamespace"
|
||||||
|
v-clean-html="t('resourceTabs.events.namespaceCaption', { namespace: value.metadata.name }, true)"
|
||||||
|
class="tab-caption"
|
||||||
|
/>
|
||||||
<!-- namespaced: false given we don't want the default handling of namespaced resource (apply header filter) -->
|
<!-- namespaced: false given we don't want the default handling of namespaced resource (apply header filter) -->
|
||||||
<PaginatedResourceTable
|
<PaginatedResourceTable
|
||||||
:schema="eventSchema"
|
:schema="eventSchema"
|
||||||
|
|
@ -318,4 +324,17 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Caption for namespace events tab */
|
||||||
|
.tab-caption {
|
||||||
|
align-items: center;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
|
||||||
|
.namespace-name {
|
||||||
|
display: inline;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-right: 0 4px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue