mirror of https://github.com/rancher/dashboard.git
Remove ununused component, tweaks, update ResourceTabs events to be super ok
This commit is contained in:
parent
11eda663bf
commit
cb87aa3b6e
|
|
@ -1,50 +0,0 @@
|
||||||
<script>
|
|
||||||
import {
|
|
||||||
STATE, NAME, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, TYPE, AGE
|
|
||||||
} from '@shell/config/table-headers';
|
|
||||||
import { WORKLOAD_TYPES } from '@shell/config/types';
|
|
||||||
import ResourceTable from '@shell/components/ResourceTable';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: { ResourceTable },
|
|
||||||
props: {
|
|
||||||
filter: {
|
|
||||||
type: Function,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async fetch() {
|
|
||||||
// Enumerating instead of using Object.values() because it looks like we don't want to include replica sets for this.
|
|
||||||
const types = [
|
|
||||||
WORKLOAD_TYPES.DEPLOYMENT,
|
|
||||||
WORKLOAD_TYPES.CRON_JOB,
|
|
||||||
WORKLOAD_TYPES.DAEMON_SET,
|
|
||||||
WORKLOAD_TYPES.JOB,
|
|
||||||
WORKLOAD_TYPES.STATEFUL_SET
|
|
||||||
];
|
|
||||||
const allWorkloadsNested = await Promise.all(types.map((type) => this.$store.dispatch('cluster/findAll', { type }))); // TODO: RC
|
|
||||||
const allWorkloads = allWorkloadsNested.flat();
|
|
||||||
|
|
||||||
this.relatedWorkloadRows = allWorkloads.filter(this.filter);
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
const relatedWorkloadHeaders = [STATE, NAME, WORKLOAD_IMAGES, WORKLOAD_ENDPOINTS, TYPE, AGE];
|
|
||||||
|
|
||||||
return {
|
|
||||||
relatedWorkloadRows: [],
|
|
||||||
relatedWorkloadHeaders,
|
|
||||||
schema: this.$store.getters['cluster/schemaFor'](WORKLOAD_TYPES.DEPLOYMENT)
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<ResourceTable
|
|
||||||
:schema="schema"
|
|
||||||
:rows="relatedWorkloadRows"
|
|
||||||
:headers="relatedWorkloadHeaders"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
@ -120,7 +120,8 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.paginate) {
|
if (!this.paginate) {
|
||||||
await this.$store.dispatch(`${ this.inStore }/findAll`, { type: this.resourceType }); // TODO: RC
|
// The resource won't be paginated and component expects everything up front
|
||||||
|
await this.$store.dispatch(`${ this.inStore }/findAll`, { type: this.resourceType });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -154,7 +155,8 @@ export default defineComponent({
|
||||||
|
|
||||||
methods: {
|
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> {
|
async paginateType(opts: LabelSelectPaginateFnOptions): Promise<LabelSelectPaginateFnResponse> {
|
||||||
if (this.paginatedResourceSettings?.overrideRequest) {
|
if (this.paginatedResourceSettings?.overrideRequest) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetch() {
|
async fetch() {
|
||||||
const hash = await allHash({ allResources: this.$store.dispatch('cluster/findAll', { type: this.type }) }); // TODO: RC
|
// TODO: RC find all 10417, update comment
|
||||||
|
// https://github.com/rancher/dashboard/issues/10417 require in order to scale application of labelSelects
|
||||||
|
const hash = await allHash({ allResources: this.$store.dispatch('cluster/findAll', { type: this.type }) });
|
||||||
|
|
||||||
this.allResources = hash.allResources;
|
this.allResources = hash.allResources;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ 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 } from '@shell/config/types';
|
||||||
import SortableTable from '@shell/components/SortableTable';
|
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';
|
||||||
import { isConditionReadyAndWaiting } from '@shell/plugins/dashboard-store/resource-class';
|
import { isConditionReadyAndWaiting } from '@shell/plugins/dashboard-store/resource-class';
|
||||||
|
import { PaginationParamFilter } from '@shell/types/store/pagination.types';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ export default {
|
||||||
Tabbed,
|
Tabbed,
|
||||||
Tab,
|
Tab,
|
||||||
Conditions,
|
Conditions,
|
||||||
SortableTable,
|
PaginatedResourceTable,
|
||||||
RelatedResources,
|
RelatedResources,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -71,10 +72,10 @@ export default {
|
||||||
const inStore = this.$store.getters['currentStore'](EVENT);
|
const inStore = this.$store.getters['currentStore'](EVENT);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasEvents: this.$store.getters[`${ inStore }/schemaFor`](EVENT), // @TODO be smarter about which resources actually ever have events
|
eventSchema: this.$store.getters[`${ inStore }/schemaFor`](EVENT), // @TODO be smarter about which resources actually ever have events
|
||||||
allEvents: [],
|
EVENT,
|
||||||
selectedTab: this.defaultTab,
|
selectedTab: this.defaultTab,
|
||||||
didLoadEvents: false,
|
// didLoadEvents: false,
|
||||||
inStore,
|
inStore,
|
||||||
showConditions: false,
|
showConditions: false,
|
||||||
};
|
};
|
||||||
|
|
@ -92,7 +93,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
showEvents() {
|
showEvents() {
|
||||||
return this.isView && this.needEvents && this.hasEvents;
|
return this.isView && this.needEvents && this.eventSchema;
|
||||||
},
|
},
|
||||||
showRelated() {
|
showRelated() {
|
||||||
return this.isView && this.needRelated;
|
return this.isView && this.needRelated;
|
||||||
|
|
@ -128,18 +129,6 @@ export default {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
events() {
|
|
||||||
return this.allEvents.filter((event) => {
|
|
||||||
return event.involvedObject?.uid === this.value?.metadata?.uid;
|
|
||||||
}).map((event) => {
|
|
||||||
return {
|
|
||||||
reason: (`${ event.reason || this.t('generic.unknown') }${ event.count > 1 ? ` (${ event.count })` : '' }`).trim(),
|
|
||||||
message: event.message || this.t('generic.unknown'),
|
|
||||||
date: event.lastTimestamp || event.firstTimestamp || event.metadata.creationTimestamp,
|
|
||||||
eventType: event.eventType
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
conditionsHaveIssues() {
|
conditionsHaveIssues() {
|
||||||
if (this.showConditions) {
|
if (this.showConditions) {
|
||||||
return this.value.status?.conditions?.filter((cond) => !isConditionReadyAndWaiting(cond)).some((cond) => cond.error);
|
return this.value.status?.conditions?.filter((cond) => !isConditionReadyAndWaiting(cond)).some((cond) => cond.error);
|
||||||
|
|
@ -153,16 +142,6 @@ export default {
|
||||||
// Ensures we only fetch events and show the table when the events tab has been activated
|
// Ensures we only fetch events and show the table when the events tab has been activated
|
||||||
tabChange(neu) {
|
tabChange(neu) {
|
||||||
this.selectedTab = neu?.selectedName;
|
this.selectedTab = neu?.selectedName;
|
||||||
|
|
||||||
if (!this.didLoadEvents && this.selectedTab === 'events') {
|
|
||||||
const inStore = this.$store.getters['currentStore'](EVENT);
|
|
||||||
|
|
||||||
// TODO: RC
|
|
||||||
this.$store.dispatch(`${ inStore }/findAll`, { type: EVENT }).then((events) => {
|
|
||||||
this.allEvents = events;
|
|
||||||
this.didLoadEvents = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -181,6 +160,54 @@ export default {
|
||||||
this.showConditions = this.$store.getters[`${ this.inStore }/pathExistsInSchema`](this.value.type, 'status.conditions');
|
this.showConditions = this.$store.getters[`${ this.inStore }/pathExistsInSchema`](this.value.type, 'status.conditions');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter out hidden repos from list of all repos
|
||||||
|
*/
|
||||||
|
filterRowsLocal(rows) {
|
||||||
|
return rows.filter((event) => event.involvedObject?.uid === this.value?.metadata?.uid);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter out hidden repos via api
|
||||||
|
*
|
||||||
|
* pagination: PaginationArgs
|
||||||
|
* returns: PaginationArgs
|
||||||
|
*/
|
||||||
|
filterRowsApi(pagination) {
|
||||||
|
if (!pagination.filters) {
|
||||||
|
pagination.filters = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = `involvedObject.uid`; // Pending API Support - https://github.com/rancher/rancher/issues/48603
|
||||||
|
|
||||||
|
// of type PaginationParamFilter
|
||||||
|
let existing = null;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const required = PaginationParamFilter.createSingleField({
|
||||||
|
field,
|
||||||
|
exact: true,
|
||||||
|
value: this.value.metadata.uid,
|
||||||
|
equals: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!existing) {
|
||||||
|
Object.assign(existing, required);
|
||||||
|
} else {
|
||||||
|
pagination.filters.push(required);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pagination;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -209,15 +236,12 @@ export default {
|
||||||
name="events"
|
name="events"
|
||||||
:weight="-2"
|
:weight="-2"
|
||||||
>
|
>
|
||||||
<SortableTable
|
<PaginatedResourceTable
|
||||||
v-if="selectedTab === 'events'"
|
v-if="selectedTab === 'events'"
|
||||||
:rows="events"
|
:schema="eventSchema"
|
||||||
:headers="eventHeaders"
|
:local-filter="filterRowsLocal"
|
||||||
key-field="id"
|
:api-filter="filterRowsApi"
|
||||||
:search="false"
|
:use-query-params-for-simple-filtering="false"
|
||||||
:table-actions="false"
|
|
||||||
:row-actions="false"
|
|
||||||
default-sort-by="date"
|
|
||||||
/>
|
/>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ class StevePaginationUtils extends NamespaceProjectFilters {
|
||||||
{ field: '_type' },
|
{ field: '_type' },
|
||||||
{ field: 'reason' },
|
{ field: 'reason' },
|
||||||
{ field: 'involvedObject.kind' },
|
{ field: 'involvedObject.kind' },
|
||||||
|
// { field: 'involvedObject.uid' }, // Pending API Support - https://github.com/rancher/rancher/issues/48603
|
||||||
{ field: 'message' },
|
{ field: 'message' },
|
||||||
],
|
],
|
||||||
[CATALOG.CLUSTER_REPO]: [
|
[CATALOG.CLUSTER_REPO]: [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue