App.js: Update to use useChrome hook

This commit updates App.js to take advantage of the useChrome hook.

`init` and `identifyApp` are deprecated and have been removed.

The Chrome API documentation can be found here:
http://front-end-docs-insights.apps.ocp4.prod.psi.redhat.com/chrome/chrome-api
This commit is contained in:
lucasgarfield 2023-04-26 15:24:35 +02:00 committed by Lucas Garfield
parent b2e6e3cf04
commit ef1d077c2e

View file

@ -1,5 +1,6 @@
import React, { useEffect } from 'react';
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal';
import { useStore } from 'react-redux';
import { useNavigate } from 'react-router-dom';
@ -12,14 +13,12 @@ const App = (props) => {
const navigate = useNavigate();
const store = useStore();
const { hideGlobalFilter, on, updateDocumentTitle } = useChrome();
useEffect(() => {
document.title = 'Image Builder | Red Hat Insights';
insights.chrome.init();
insights.chrome.identifyApp('image-builder');
insights.chrome.hideGlobalFilter();
const unregister = insights.chrome.on('APP_NAVIGATION', () =>
navigate(resolveRelPath(''))
);
updateDocumentTitle('Image Builder | Red Hat Insights');
hideGlobalFilter();
const unregister = on('APP_NAVIGATION', () => navigate(resolveRelPath('')));
return () => {
unregister();
};