-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from upalatucci/drawer-url-state
fix: move selectedInterface state into the url
- Loading branch information
Showing
9 changed files
with
90 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import NodeNetworkStateModel from 'src/console-models/NodeNetworkStateModel'; | ||
|
||
import { getResourceUrl } from '@utils/helpers'; | ||
|
||
export const baseListUrl = getResourceUrl({ model: NodeNetworkStateModel }); |
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import { useHistory, useLocation } from 'react-router'; | ||
|
||
import { NodeNetworkConfigurationInterface, V1beta1NodeNetworkState } from '@types'; | ||
|
||
import { baseListUrl } from '../constants'; | ||
|
||
const useDrawerInterface = () => { | ||
const history = useHistory(); | ||
const { search } = useLocation(); | ||
|
||
const params = new URLSearchParams(search); | ||
|
||
const selectedInterfaceName = params.get('selectedInterface') as string; | ||
const selectedInterfaceType = params.get('selectedInterfaceType') as string; | ||
const selectedStateName = params.get('selectedState') as string; | ||
|
||
return { | ||
selectedInterfaceName, | ||
selectedInterfaceType, | ||
selectedStateName, | ||
setSelectedInterfaceName: ( | ||
nodeNetworkState?: V1beta1NodeNetworkState, | ||
nodeNetworkInterface?: NodeNetworkConfigurationInterface, | ||
) => { | ||
if (!nodeNetworkInterface) return history.push(baseListUrl); | ||
|
||
const query = new URLSearchParams({ | ||
selectedInterface: nodeNetworkInterface.name, | ||
selectedInterfaceType: nodeNetworkInterface.type, | ||
selectedState: nodeNetworkState?.metadata?.name, | ||
}); | ||
|
||
history.push(`${baseListUrl}?${query.toString()}`); | ||
}, | ||
}; | ||
}; | ||
|
||
export default useDrawerInterface; |