-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adjusted app to work as core-registry-ui child application fix: data table key error
- Loading branch information
Showing
18 changed files
with
332 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { isIframe } from '@/utils/unified-ui-utils'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
|
||
/** | ||
* MUST be run in a react router context | ||
* hook to manage loading the last saved location when running as a child application. | ||
*/ | ||
const useManageSavedLocation = () => { | ||
const isCoreRegistryUiChildApp = isIframe(); | ||
const savedUrlString = localStorage.getItem('explorerUiLocation'); | ||
const [savedUrlLoaded, setSavedUrlLoaded] = useState(false); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
|
||
//navigate to the last location saved to local storage | ||
useEffect(() => { | ||
if (isCoreRegistryUiChildApp && !savedUrlLoaded && savedUrlString) { | ||
navigate(savedUrlString, { replace: true }); | ||
} | ||
setTimeout(() => setSavedUrlLoaded(true), 200); | ||
}, [isCoreRegistryUiChildApp, navigate, savedUrlLoaded, savedUrlString]); | ||
|
||
// save the current location to local storage for recall when the parent app refreshes | ||
useEffect(() => { | ||
if (isCoreRegistryUiChildApp && location && savedUrlLoaded) { | ||
const reactAppCurrentLocation: string = location.pathname + location.hash + location.search; | ||
|
||
if (reactAppCurrentLocation !== '/' && reactAppCurrentLocation !== savedUrlString) { | ||
localStorage.setItem('explorerUiLocation', reactAppCurrentLocation); | ||
} | ||
} | ||
}, [ | ||
isCoreRegistryUiChildApp, | ||
location.pathname, | ||
location.search, | ||
location.hash, | ||
savedUrlString, | ||
location, | ||
savedUrlLoaded, | ||
]); | ||
}; | ||
|
||
export { useManageSavedLocation }; |
Oops, something went wrong.