From f44ec2eb5de4fdf1c5d2fbba7a727a5d64c8cbb1 Mon Sep 17 00:00:00 2001 From: Richard87 Date: Tue, 10 Sep 2024 08:33:48 +0200 Subject: [PATCH] Scale popup --- .../active-component-toolbar.tsx | 83 ++++++++++--------- .../component-status.tsx | 4 +- .../page-active-component/style.css | 7 ++ src/store/radix-api.ts | 4 +- 4 files changed, 54 insertions(+), 44 deletions(-) diff --git a/src/components/page-active-component/active-component-toolbar.tsx b/src/components/page-active-component/active-component-toolbar.tsx index aeb9f0eaf..490c3be25 100644 --- a/src/components/page-active-component/active-component-toolbar.tsx +++ b/src/components/page-active-component/active-component-toolbar.tsx @@ -1,11 +1,11 @@ import { Button, CircularProgress, + Dialog, Slider, - TextField, Typography, } from '@equinor/eds-core-react'; -import { type ChangeEvent, useState } from 'react'; +import { useState } from 'react'; import { type Component, useRestartComponentMutation, @@ -13,7 +13,7 @@ import { useStopComponentMutation, } from '../../store/radix-api'; import { handlePromiseWithToast } from '../global-top-nav/styled-toaster'; -import { ScrimPopup } from '../scrim-popup'; +import './style.css'; type Props = { component: Component; @@ -35,14 +35,18 @@ export function ActiveComponentToolbar({ component, appName, envName }: Props) { <>
- @@ -87,17 +91,20 @@ type ScaleProps = { appName: string; envName: string; componentName: string; + currentReplicas: number; }; -function ScaleButtonPopover({ +function ScaleButtonPopup({ disabled, appName, envName, componentName, + currentReplicas, }: ScaleProps) { - const [replicas, setReplicas] = useState(0); + const [replicas, setReplicas] = useState(null); const [visibleScrim, setVisibleScrim] = useState(false); const [scaleTrigger, scaleState] = useScaleComponentMutation(); + const current = replicas ?? currentReplicas; const onScale = handlePromiseWithToast( async () => { @@ -105,9 +112,10 @@ function ScaleButtonPopover({ appName, envName, componentName, - replicas: replicas.toFixed(), + replicas: current.toFixed(), }).unwrap(); setVisibleScrim(false); + setReplicas(null); }, 'Scaling component', 'Failed to scale component' @@ -119,48 +127,41 @@ function ScaleButtonPopover({ Scale - setVisibleScrim(false)} isDismissable + style={{ width: '400px' }} > - - ) => - setReplicas(Number(e.target.value)) - } - /> -
-
- - Manually scale component. This will disable any automatic scaling{' '} -
- untill manuall scaling is reset. -
-
- + + Scale Component + + + + This will disable any automatic scaling untill manuall scaling is + reset. + + setReplicas(values[0])} + aria-labelledby="simple-slider" + /> + + + +
- -
- +
+ +
); } diff --git a/src/components/page-active-component/component-status.tsx b/src/components/page-active-component/component-status.tsx index 2f7c4ae39..7f18ad530 100644 --- a/src/components/page-active-component/component-status.tsx +++ b/src/components/page-active-component/component-status.tsx @@ -59,8 +59,8 @@ export function ComponentStatus({ {isManuallyScaled && !isManuallyStopped && ( - Component has been manually scaled; Click reset to resume regular - scaling. + Component has been manually scaled to {component.replicasOverride}{' '} + replicas; Click reset to resume regular scaling.