Skip to content

Commit

Permalink
backport PR 12886
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 committed Jan 22, 2025
1 parent e1a6686 commit 172caed
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
36 changes: 34 additions & 2 deletions shell/components/Tabbed/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
};
});

Check warning on line 95 in shell/components/Tabbed/index.vue

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
return {
tabs: [],
activeTabName: null,
tabs: [...parsedExtTabs],
extensionTabs: parsedExtTabs,
activeTabName: null
};
},
Expand Down Expand Up @@ -320,6 +334,24 @@ export default {
}"
>
<slot />
<!-- Extension tabs -->
<Tab
v-for="tab, i in extensionTabs"
:key="`${tab.name}${i}`"
:name="tab.name"
:label="tab.label"
:label-key="tab.labelKey"
:weight="tab.weight"
:tooltip="tab.tooltip"
:show-header="tab.showHeader"
:display-alert-icon="tab.displayAlertIcon"
:error="tab.error"
:badge="tab.badge"
>
<component
:is="tab.component"
/>
</Tab>
</div>
</div>
</template>
Expand Down
23 changes: 0 additions & 23 deletions shell/components/form/ResourceTabs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -246,25 +243,5 @@ export default {
direction="to"
/>
</Tab>
<!-- Extension tabs -->
<Tab
v-for="tab, i in extensionTabs"
:key="`${tab.name}${i}`"
:name="tab.name"
:label="tab.label"
:label-key="tab.labelKey"
:weight="tab.weight"
:tooltip="tab.tooltip"
:show-header="tab.showHeader"
:display-alert-icon="tab.displayAlertIcon"
:error="tab.error"
:badge="tab.badge"
>
<component
:is="tab.component"
:resource="value"
/>
</Tab>
</Tabbed>
</template>
9 changes: 8 additions & 1 deletion shell/core/plugin.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion shell/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 172caed

Please sign in to comment.