mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add +/- buttons in scale deployment popup screen (#1191)
* Add @testing-library/jest-dom and @testing-library/react for writing test cases * Make eslint check __mocks__/*.ts files * Mock electron.ipcRenderer.on to prevent errors in React compoment test cases * Mock <Trans /> from @lingui/macro as a component simplely returns children components * Use optional chaining operator (?.) to avoid TypeError: Cannot read property 'replicas' of undefined * Add jest-fetch-mock for mocking global.fetch, activate for all test cases in jest.setup.ts * Add basic tests for <DeploymentScaleDialog /> to ensure it initialises/renders without errors * Add +/- button for changing desired replicas, and its test cases * Adjust the styles of +/- buttons container to make sure it aligns with the slider * Refactor after rebase from master * Use var defined in vars.scss * Add flex align-center to slider-container and remove margin-top: -4px * Use <Icon /> to replace <i/> * Add flex gaps to plus-minus-container Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
10 files changed
+414
-11
No files matched your search
@@ -83,21 +83,41 @@ export class DeploymentScaleDialog extends Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
desiredReplicasUp = () => {
|
||||
this.desiredReplicas < this.scaleMax && this.desiredReplicas++
|
||||
}
|
||||
|
||||
desiredReplicasDown = () => {
|
||||
this.desiredReplicas > 1 && this.desiredReplicas--
|
||||
};
|
||||
|
||||
renderContents() {
|
||||
const { currentReplicas, desiredReplicas, onChange, scaleMax } = this;
|
||||
const warning = currentReplicas < 10 && desiredReplicas > 90;
|
||||
return (
|
||||
<>
|
||||
<div className="current-scale">
|
||||
<div className="current-scale" data-testid="current-scale">
|
||||
<Trans>Current replica scale: {currentReplicas}</Trans>
|
||||
</div>
|
||||
<div className="flex gaps align-center">
|
||||
<div className="desired-scale">
|
||||
<div className="desired-scale" data-testid="desired-scale">
|
||||
<Trans>Desired number of replicas</Trans>: {desiredReplicas}
|
||||
</div>
|
||||
<div className="slider-container">
|
||||
<div className="slider-container flex align-center">
|
||||
<Slider value={desiredReplicas} max={scaleMax} onChange={onChange as any /** see: https://github.com/mui-org/material-ui/issues/20191 */}/>
|
||||
</div>
|
||||
<div className="plus-minus-container flex gaps">
|
||||
<Icon
|
||||
material="add_circle_outline"
|
||||
onClick={this.desiredReplicasUp}
|
||||
data-testid="desired-replicas-up"
|
||||
/>
|
||||
<Icon
|
||||
material="remove_circle_outline"
|
||||
onClick={this.desiredReplicasDown}
|
||||
data-testid="desired-replicas-down"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{warning &&
|
||||
<div className="warning">
|
||||
@@ -139,4 +159,4 @@ export class DeploymentScaleDialog extends Component<Props> {
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user