Reset region and Account when switching inventory (#54287)
This commit is contained in:
parent
303e4842ea
commit
e1e1d964c6
|
@ -28,6 +28,8 @@ interface WaffleInventorySwitcherProps {
|
|||
changeNodeType: (nodeType: InfraNodeType) => void;
|
||||
changeGroupBy: (groupBy: InfraSnapshotGroupbyInput[]) => void;
|
||||
changeMetric: (metric: InfraSnapshotMetricInput) => void;
|
||||
changeAccount: (id: string) => void;
|
||||
changeRegion: (name: string) => void;
|
||||
}
|
||||
|
||||
const getDisplayNameForType = (type: InventoryItemType) => {
|
||||
|
@ -39,6 +41,8 @@ export const WaffleInventorySwitcher: React.FC<WaffleInventorySwitcherProps> = (
|
|||
changeNodeType,
|
||||
changeGroupBy,
|
||||
changeMetric,
|
||||
changeAccount,
|
||||
changeRegion,
|
||||
nodeType,
|
||||
}) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
@ -49,12 +53,14 @@ export const WaffleInventorySwitcher: React.FC<WaffleInventorySwitcherProps> = (
|
|||
closePopover();
|
||||
changeNodeType(targetNodeType);
|
||||
changeGroupBy([]);
|
||||
changeAccount('');
|
||||
changeRegion('');
|
||||
const inventoryModel = findInventoryModel(targetNodeType);
|
||||
changeMetric({
|
||||
type: inventoryModel.metrics.defaultSnapshot as InfraSnapshotMetricType,
|
||||
});
|
||||
},
|
||||
[closePopover, changeNodeType, changeGroupBy, changeMetric]
|
||||
[closePopover, changeNodeType, changeGroupBy, changeMetric, changeAccount, changeRegion]
|
||||
);
|
||||
const goToHost = useCallback(() => goToNodeType('host' as InfraNodeType), [goToNodeType]);
|
||||
const goToK8 = useCallback(() => goToNodeType('pod' as InfraNodeType), [goToNodeType]);
|
||||
|
|
|
@ -23,12 +23,21 @@ export const SnapshotToolbar = () => (
|
|||
<EuiFlexGroup alignItems="center" justifyContent="spaceBetween" gutterSize="m">
|
||||
<EuiFlexItem grow={false}>
|
||||
<WithWaffleOptions>
|
||||
{({ changeMetric, changeNodeType, changeGroupBy, nodeType }) => (
|
||||
{({
|
||||
changeMetric,
|
||||
changeNodeType,
|
||||
changeGroupBy,
|
||||
changeAccount,
|
||||
changeRegion,
|
||||
nodeType,
|
||||
}) => (
|
||||
<WaffleInventorySwitcher
|
||||
nodeType={nodeType}
|
||||
changeNodeType={changeNodeType}
|
||||
changeMetric={changeMetric}
|
||||
changeGroupBy={changeGroupBy}
|
||||
changeAccount={changeAccount}
|
||||
changeRegion={changeRegion}
|
||||
/>
|
||||
)}
|
||||
</WithWaffleOptions>
|
||||
|
|
Loading…
Reference in a new issue