mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
chore(kubernetes): Migrate Helm Templates View to React R8S-239 (#587)
This commit is contained in:
parent
ad89df4d0d
commit
264ff5457b
20 changed files with 635 additions and 372 deletions
17
app/react/hooks/useCanExit.ts
Normal file
17
app/react/hooks/useCanExit.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* Copied from https://github.com/ui-router/react/blob/master/src/hooks/useCanExit.ts
|
||||
* TODO: Use package version of this hook when it becomes available: https://github.com/ui-router/react/pull/1227
|
||||
*/
|
||||
import { useParentView, useTransitionHook } from '@uirouter/react';
|
||||
|
||||
/**
|
||||
* A hook that can stop the router from exiting the state the hook is used in.
|
||||
* If the callback returns true/undefined (or a Promise that resolves to true/undefined), the Transition will be allowed to continue.
|
||||
* If the callback returns false (or a Promise that resolves to false), the Transition will be cancelled.
|
||||
*/
|
||||
export function useCanExit(
|
||||
canExitCallback: () => boolean | undefined | Promise<boolean | undefined>
|
||||
) {
|
||||
const stateName = useParentView().context.name;
|
||||
useTransitionHook('onBefore', { exiting: stateName }, canExitCallback);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue