From 172caedcde549806a817300be3d4a6294a00b3a2 Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Wed, 22 Jan 2025 14:06:37 +0000 Subject: [PATCH] backport PR 12886 --- shell/components/Tabbed/index.vue | 36 ++++++++++++++++++-- shell/components/form/ResourceTabs/index.vue | 23 ------------- shell/core/plugin.ts | 9 ++++- shell/package.json | 2 +- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/shell/components/Tabbed/index.vue b/shell/components/Tabbed/index.vue index 65f8425855f..bbd90e9c577 100644 --- a/shell/components/Tabbed/index.vue +++ b/shell/components/Tabbed/index.vue @@ -4,10 +4,15 @@ import isEmpty from 'lodash/isEmpty'; import { addObject, removeObject, findBy } from '@shell/utils/array'; import { sortBy } from '@shell/utils/sort'; import findIndex from 'lodash/findIndex'; +import { ExtensionPoint, TabLocation } from '@shell/core/types'; +import { getApplicableExtensionEnhancements } from '@shell/core/plugin-helpers'; +import Tab from '@shell/components/Tabbed/Tab'; export default { name: 'Tabbed', + components: { Tab }, + props: { defaultTab: { type: String, @@ -80,9 +85,18 @@ export default { }, data() { + const extensionTabs = getApplicableExtensionEnhancements(this, ExtensionPoint.TAB, TabLocation.RESOURCE_DETAIL, this.$route, this, this.extensionParams) || []; + const parsedExtTabs = extensionTabs.map((item) => { + return { + ...item, + active: false + }; + }); + return { - tabs: [], - activeTabName: null, + tabs: [...parsedExtTabs], + extensionTabs: parsedExtTabs, + activeTabName: null }; }, @@ -320,6 +334,24 @@ export default { }" > + + + + diff --git a/shell/components/form/ResourceTabs/index.vue b/shell/components/form/ResourceTabs/index.vue index e468e9c6482..fc4e635bbfa 100644 --- a/shell/components/form/ResourceTabs/index.vue +++ b/shell/components/form/ResourceTabs/index.vue @@ -11,8 +11,6 @@ import { EVENT } from '@shell/config/types'; import SortableTable from '@shell/components/SortableTable'; import { _VIEW } from '@shell/config/query-params'; import RelatedResources from '@shell/components/RelatedResources'; -import { ExtensionPoint, TabLocation } from '@shell/core/types'; -import { getApplicableExtensionEnhancements } from '@shell/core/plugin-helpers'; import { isConditionReadyAndWaiting } from '@shell/plugins/dashboard-store/resource-class'; export default { @@ -77,7 +75,6 @@ export default { allEvents: [], selectedTab: this.defaultTab, didLoadEvents: false, - extensionTabs: getApplicableExtensionEnhancements(this, ExtensionPoint.TAB, TabLocation.RESOURCE_DETAIL, this.$route, this, this.extensionParams), inStore, showConditions: false, }; @@ -246,25 +243,5 @@ export default { direction="to" /> - - - - - diff --git a/shell/core/plugin.ts b/shell/core/plugin.ts index 7eac98dda68..084e524233b 100644 --- a/shell/core/plugin.ts +++ b/shell/core/plugin.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { RouteConfig } from 'vue-router'; import { DSL as STORE_DSL } from '@shell/store/type-map'; +import { _DETAIL } from '@shell/config/query-params'; import { CoreStoreInit, Action, @@ -11,7 +12,7 @@ import { IPlugin, LocationConfig, ExtensionPoint, - + TabLocation, PluginRouteConfig, RegisterStore, UnregisterStore, CoreStoreSpecifics, CoreStoreConfig, OnNavToPackage, OnNavAwayFromPackage, OnLogOut } from './types'; import coreStore, { coreStoreModule, coreStoreState } from '@shell/plugins/dashboard-store'; @@ -166,6 +167,12 @@ export class Plugin implements IPlugin { * Adds a tab to the UI */ addTab(where: string, when: LocationConfig | string, tab: Tab): void { + // tackling https://github.com/rancher/dashboard/issues/11122, we don't want the tab to added in _EDIT view, unless overriden + // on extensions side we won't document the mode param for this extension point + if (where === TabLocation.RESOURCE_DETAIL && (typeof when === 'object' && !when.mode)) { + when.mode = [_DETAIL]; + } + this._addUIConfig(ExtensionPoint.TAB, where, when, tab); } diff --git a/shell/package.json b/shell/package.json index 0505b0860eb..1c35e49014f 100644 --- a/shell/package.json +++ b/shell/package.json @@ -1,6 +1,6 @@ { "name": "@rancher/shell", - "version": "2.0.3", + "version": "2.0.4", "description": "Rancher Dashboard Shell", "repository": "https://github.com/rancherlabs/dashboard", "license": "Apache-2.0",