Skip to content

Commit 9c3e319

Browse files
committed
feat: Enhance tab functionality by adding defaultUrl to tab properties and refining terminal tab visibility logic
1 parent 423e678 commit 9c3e319

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/components/ResourceBrowser/ResourceList/ResourceList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,11 @@ const ResourceList = () => {
657657
const currentTab = tabs[index]
658658
// We will render the fixed tab if it is selected, alive or it should remain mounted
659659
// Not using filter, as the index is directly coupled with tabs indexes
660-
if (currentTab.isSelected || currentTab.shouldRemainMounted || currentTab.isAlive) {
660+
if (
661+
currentTab.isSelected ||
662+
currentTab.shouldRemainMounted ||
663+
(currentTab.isAlive && currentTab.id === ResourceBrowserTabsId.terminal)
664+
) {
661665
/* NOTE: need to retain terminal layout. Thus hiding it through visibility */
662666
const hideClassName =
663667
tabs[index].name === AppDetailsTabs.terminal

src/components/common/DynamicTabs/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ export interface PopulateTabDataPropsType
9494
| 'hideName'
9595
| 'id'
9696
>,
97-
Required<Pick<DynamicTabType, 'shouldRemainMounted' | 'title' | 'showNameOnSelect' | 'isAlpha'>> {}
97+
Required<
98+
Pick<DynamicTabType, 'shouldRemainMounted' | 'title' | 'showNameOnSelect' | 'isAlpha' | 'defaultUrl'>
99+
> {}
98100

99101
export interface AddTabParamsType
100102
extends Pick<PopulateTabDataPropsType, 'name' | 'url' | 'tippyConfig'>,

src/components/common/DynamicTabs/useTabs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export function useTabs(persistenceKey: string, fallbackTabIndex = FALLBACK_TAB)
7373
lastActiveTabId,
7474
shouldRemainMounted,
7575
isAlpha,
76+
defaultUrl,
7677
}: PopulateTabDataPropsType): DynamicTabType => ({
7778
id,
7879
name,
@@ -90,6 +91,7 @@ export function useTabs(persistenceKey: string, fallbackTabIndex = FALLBACK_TAB)
9091
lastActiveTabId,
9192
shouldRemainMounted,
9293
isAlpha: isAlpha || false,
94+
defaultUrl: defaultUrl || null,
9395
})
9496

9597
const getTabDataFromLocalStorage = () => localStorage.getItem(TAB_DATA_LOCAL_STORAGE_KEY)
@@ -162,6 +164,7 @@ export function useTabs(persistenceKey: string, fallbackTabIndex = FALLBACK_TAB)
162164
lastActiveTabId: null,
163165
shouldRemainMounted: _initTab.shouldRemainMounted,
164166
isAlpha: _initTab.isAlpha,
167+
defaultUrl: _initTab.defaultUrl,
165168
})
166169
}
167170

@@ -335,6 +338,7 @@ export function useTabs(persistenceKey: string, fallbackTabIndex = FALLBACK_TAB)
335338
lastActiveTabId: getLastActiveTabIdFromTabs(prevTabs, _id),
336339
shouldRemainMounted: false,
337340
isAlpha: false,
341+
defaultUrl: null,
338342
}),
339343
)
340344
}
@@ -373,6 +377,7 @@ export function useTabs(persistenceKey: string, fallbackTabIndex = FALLBACK_TAB)
373377
...tab,
374378
isSelected: false,
375379
isAlive: false,
380+
url: tab.defaultUrl || tab.url,
376381
}
377382
}
378383

0 commit comments

Comments
 (0)