1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

simpler type fixes

Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian Malton 2020-06-11 11:54:31 -04:00
parent 2fd4b504af
commit 75d648adb6
5 changed files with 23 additions and 18 deletions

View File

@ -96,7 +96,7 @@ export class DeploymentScaleDialog extends Component<Props> {
<Trans>Desired number of replicas</Trans>: {desiredReplicas}
</div>
<div className="slider-container">
<Slider value={desiredReplicas} max={scaleMax} onChange={onChange}/>
<Slider value={desiredReplicas} max={scaleMax} onChange={onChange as any /** see: https://github.com/mui-org/material-ui/issues/20191 */}/>
</div>
</div>
{warning &&

View File

@ -150,7 +150,7 @@ export function BarChart(props: Props) {
}
};
const options = merge(barOptions, customOptions);
if (!chartData.datasets.length) {
if (chartData.datasets.length == 0) {
return <NoMetrics/>
}
return (
@ -170,9 +170,17 @@ export const memoryOptions: ChartOptions = {
scales: {
yAxes: [{
ticks: {
callback: value => {
if (!value) return 0;
return parseFloat(value) < 1 ? value.toFixed(3) : bytesToUnits(parseInt(value));
callback: (value: number | string): string => {
if (typeof value == "string") {
const float = parseFloat(value);
if (float < 1) {
return float.toFixed(3);
}
return bytesToUnits(parseInt(value));
}
return `${value}`;
},
stepSize: 1
}
@ -194,11 +202,12 @@ export const cpuOptions: ChartOptions = {
scales: {
yAxes: [{
ticks: {
callback: value => {
if (value == 0) return 0;
if (value < 10) return value.toFixed(3);
if (value < 100) return value.toFixed(2);
return value.toFixed(1);
callback: (value: number | string): string => {
const float = parseFloat(`${value}`);
if (float == 0) return "0";
if (float < 10) return float.toFixed(3);
if (float < 100) return float.toFixed(2);
return float.toFixed(1);
}
}
}]

View File

@ -19,10 +19,7 @@ export interface ChartDataSet extends ChartDataSets {
}
export interface ChartProps {
data: {
labels?: Array<string | string[]>;
datasets?: ChartDataSet[];
};
data: ChartData;
width?: number | string;
height?: number | string;
options?: ChartOptions; // Passed to ChartJS instance

View File

@ -7,7 +7,6 @@ import { cssNames } from "../../utils";
import { themeStore } from "../../theme.store";
interface Props extends ChartProps {
data: ChartData;
title?: string;
}

View File

@ -10,7 +10,7 @@ import ReactSelect, { components as ReactSelectComponents } from "react-select"
import { Props as ReactSelectProps } from "react-select/base"
import Creatable, { CreatableProps } from "react-select/creatable"
import { StylesConfig } from "react-select/src/styles"
import { ActionMeta } from "react-select/src/types"
import { ActionMeta, OptionTypeBase } from "react-select/src/types"
import { themeStore } from "../../theme.store";
export { ReactSelectComponents }
@ -31,7 +31,7 @@ export interface SelectProps<T = any> extends ReactSelectProps<T>, CreatableProp
menuClass?: string;
isCreatable?: boolean;
autoConvertOptions?: boolean; // to internal format (i.e. {value: T, label: string}[]), not working with groups
onChange?(option: T, meta?: ActionMeta): void;
onChange?(option: T, meta?: ActionMeta<OptionTypeBase>): void;
}
@observer
@ -76,7 +76,7 @@ export class Select extends React.Component<SelectProps> {
}
@autobind()
onChange(value: SelectOption, meta: ActionMeta) {
onChange(value: SelectOption, meta: ActionMeta<OptionTypeBase>) {
if (this.props.onChange) {
this.props.onChange(value, meta);
}