mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
fix(apps): update associated resources on deletion [r8s-124] (#75)
This commit is contained in:
parent
d418784346
commit
c1316532eb
15 changed files with 281 additions and 90 deletions
|
@ -1,4 +1,4 @@
|
|||
import { RawParams } from '@uirouter/react';
|
||||
import { RawParams, useCurrentStateAndParams } from '@uirouter/react';
|
||||
import clsx from 'clsx';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { Link } from '@@/Link';
|
|||
|
||||
export interface Tab {
|
||||
name: ReactNode;
|
||||
icon: ReactNode;
|
||||
icon?: ReactNode;
|
||||
widget: ReactNode;
|
||||
selectedTabParam: string;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ export function WidgetTabs({ currentTabIndex, tabs }: Props) {
|
|||
)}
|
||||
data-cy={`tab-${index}`}
|
||||
>
|
||||
<Icon icon={icon} />
|
||||
{icon && <Icon icon={icon} />}
|
||||
{name}
|
||||
</Link>
|
||||
))}
|
||||
|
@ -67,5 +67,15 @@ export function findSelectedTabIndex(
|
|||
const currentTabIndex = tabs.findIndex(
|
||||
(tab) => tab.selectedTabParam === selectedTabParam
|
||||
);
|
||||
return currentTabIndex || 0;
|
||||
if (currentTabIndex === -1) {
|
||||
return 0;
|
||||
}
|
||||
return currentTabIndex;
|
||||
}
|
||||
|
||||
export function useCurrentTabIndex(tabs: Tab[]) {
|
||||
const prarms = useCurrentStateAndParams();
|
||||
const currentTabIndex = findSelectedTabIndex(prarms, tabs);
|
||||
|
||||
return [currentTabIndex];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue