Skip to content

Commit 86e8073

Browse files
PeterYurkovichopenshift-cherrypick-robot
authored andcommitted
fix: close troubleshooting panel when switching to perspectives it isn't supported in and ensure it doesn't open in the other perspectives as well
1 parent 3f33a13 commit 86e8073

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

web/src/components/Popover.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { TimesCircleIcon } from '@patternfly/react-icons';
77
import { State } from '../redux-reducers';
88
import { closeTP } from '../redux-actions';
99
import { useTranslation } from 'react-i18next';
10+
import { useActivePerspective } from '@openshift-console/dynamic-plugin-sdk';
1011

1112
export default function Popover() {
1213
const dispatch = useDispatch();
14+
const [activePerspective] = useActivePerspective();
1315
const { t } = useTranslation('plugin__troubleshooting-panel-console-plugin');
1416

1517
const isOpen = useSelector((state: State) => state.plugins?.tp?.get('isOpen'));
@@ -18,6 +20,12 @@ export default function Popover() {
1820
dispatch(closeTP());
1921
}, [dispatch]);
2022

23+
React.useEffect(() => {
24+
if (activePerspective !== 'admin' && isOpen) {
25+
close();
26+
}
27+
}, [activePerspective, isOpen, close]);
28+
2129
if (!isOpen) {
2230
return null;
2331
}

0 commit comments

Comments
 (0)