Skip to content

Commit 758b6c0

Browse files
committed
Merge branch 'master' of https://github.com/OneUptime/oneuptime
2 parents 61ea40a + 8ed94c0 commit 758b6c0

46 files changed

Lines changed: 562 additions & 610 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

App/FeatureSet/Dashboard/src/Components/Form/Monitor/KubernetesMonitor/KubernetesMetricPicker.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const KubernetesMetricPicker: FunctionComponent<ComponentProps> = (
2727
const groupedOptions: Array<DropdownOptionGroup> = allCategories.map(
2828
(category: KubernetesMetricCategory) => {
2929
const categoryMetrics: Array<KubernetesMetricDefinition> =
30-
allMetrics.filter(
31-
(m: KubernetesMetricDefinition) => m.category === category,
32-
);
30+
allMetrics.filter((m: KubernetesMetricDefinition) => {
31+
return m.category === category;
32+
});
3333

3434
return {
3535
label: category,
@@ -45,9 +45,9 @@ const KubernetesMetricPicker: FunctionComponent<ComponentProps> = (
4545

4646
const selectedMetric: KubernetesMetricDefinition | undefined =
4747
props.selectedMetricId
48-
? allMetrics.find(
49-
(m: KubernetesMetricDefinition) => m.id === props.selectedMetricId,
50-
)
48+
? allMetrics.find((m: KubernetesMetricDefinition) => {
49+
return m.id === props.selectedMetricId;
50+
})
5151
: undefined;
5252

5353
const selectedOption: DropdownOption | undefined = selectedMetric
@@ -69,9 +69,9 @@ const KubernetesMetricPicker: FunctionComponent<ComponentProps> = (
6969

7070
const metricId: string = value as string;
7171
const metric: KubernetesMetricDefinition | undefined =
72-
allMetrics.find(
73-
(m: KubernetesMetricDefinition) => m.id === metricId,
74-
);
72+
allMetrics.find((m: KubernetesMetricDefinition) => {
73+
return m.id === metricId;
74+
});
7575

7676
if (metric) {
7777
props.onMetricSelected(metric);

App/FeatureSet/Dashboard/src/Components/Form/Monitor/KubernetesMonitor/KubernetesMonitorStepForm.tsx

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import RollingTimePicker from "Common/UI/Components/RollingTimePicker/RollingTim
1212
import RollingTimeUtil from "Common/Types/RollingTime/RollingTimeUtil";
1313
import FieldLabelElement from "Common/UI/Components/Forms/Fields/FieldLabel";
1414
import MetricViewData from "Common/Types/Metrics/MetricViewData";
15+
import MetricQueryConfigData from "Common/Types/Metrics/MetricQueryConfigData";
1516
import Dropdown, {
1617
DropdownOption,
1718
DropdownValue,
@@ -42,7 +43,6 @@ export interface ComponentProps {
4243
onChange: (
4344
monitorStepKubernetesMonitor: MonitorStepKubernetesMonitor,
4445
) => void;
45-
onMonitorStepOverride?: ((step: MonitorStep) => void) | undefined;
4646
onModeChange?: ((mode: KubernetesFormMode) => void) | undefined;
4747
initialTemplateId?: string | undefined;
4848
initialClusterId?: string | undefined;
@@ -92,7 +92,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
9292
Navigation.getQueryStringByName("clusterId") ||
9393
undefined;
9494

95-
const [_mode, setMode] = React.useState<KubernetesFormMode>("quick");
95+
const [, setMode] = React.useState<KubernetesFormMode>("quick");
9696

9797
const [rollingTime, setRollingTime] = React.useState<RollingTime | null>(
9898
null,
@@ -109,8 +109,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
109109
Array<DropdownOption>
110110
>([]);
111111

112-
const [_isLoadingClusters, setIsLoadingClusters] =
113-
React.useState<boolean>(true);
112+
const [, setIsLoadingClusters] = React.useState<boolean>(true);
114113

115114
// Quick Setup state
116115
const [selectedTemplateId, setSelectedTemplateId] = React.useState<
@@ -155,12 +154,11 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
155154
setClusterOptions(options);
156155

157156
// Auto-select cluster if initialClusterId or URL param is provided
158-
if (
159-
urlClusterId &&
160-
!monitorStepKubernetesMonitor.clusterIdentifier
161-
) {
157+
if (urlClusterId && !monitorStepKubernetesMonitor.clusterIdentifier) {
162158
const matchedCluster: DropdownOption | undefined = options.find(
163-
(o: DropdownOption) => o.value === urlClusterId,
159+
(o: DropdownOption) => {
160+
return o.value === urlClusterId;
161+
},
164162
);
165163
if (matchedCluster) {
166164
props.onChange({
@@ -211,13 +209,15 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
211209
);
212210
}, []);
213211

214-
const handleTemplateSelection = (
212+
const handleTemplateSelection: (template: KubernetesAlertTemplate) => void = (
215213
template: KubernetesAlertTemplate,
216214
): void => {
217215
setSelectedTemplateId(template.id);
218216

219-
// Build the kubernetes monitor config from the template's getMonitorStep
220-
// We need the cluster identifier to build the config
217+
/*
218+
* Build the kubernetes monitor config from the template's getMonitorStep
219+
* We need the cluster identifier to build the config
220+
*/
221221
const clusterIdentifier: string =
222222
monitorStepKubernetesMonitor.clusterIdentifier;
223223

@@ -245,9 +245,9 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
245245
}
246246
};
247247

248-
const handleCustomMetricSelection = (
248+
const handleCustomMetricSelection: (
249249
metric: KubernetesMetricDefinition,
250-
): void => {
250+
) => void = (metric: KubernetesMetricDefinition): void => {
251251
setSelectedMetricId(metric.id);
252252
setCustomAggregation(metric.defaultAggregation);
253253
setCustomResourceScope(metric.defaultResourceScope);
@@ -273,22 +273,19 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
273273
KubernetesResourceScope.Namespace ||
274274
monitorStepKubernetesMonitor.resourceScope ===
275275
KubernetesResourceScope.Workload ||
276-
monitorStepKubernetesMonitor.resourceScope ===
277-
KubernetesResourceScope.Pod;
276+
monitorStepKubernetesMonitor.resourceScope === KubernetesResourceScope.Pod;
278277

279278
const showWorkloadFilter: boolean =
280279
monitorStepKubernetesMonitor.resourceScope ===
281280
KubernetesResourceScope.Workload;
282281

283282
const showNodeFilter: boolean =
284-
monitorStepKubernetesMonitor.resourceScope ===
285-
KubernetesResourceScope.Node;
283+
monitorStepKubernetesMonitor.resourceScope === KubernetesResourceScope.Node;
286284

287285
const showPodFilter: boolean =
288-
monitorStepKubernetesMonitor.resourceScope ===
289-
KubernetesResourceScope.Pod;
286+
monitorStepKubernetesMonitor.resourceScope === KubernetesResourceScope.Pod;
290287

291-
const renderClusterDropdown = (): ReactElement => {
288+
const renderClusterDropdown: () => ReactElement = (): ReactElement => {
292289
return (
293290
<div className="mb-4">
294291
<FieldLabelElement
@@ -298,10 +295,11 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
298295
/>
299296
<Dropdown
300297
options={clusterOptions}
301-
value={clusterOptions.find(
302-
(option: DropdownOption) =>
303-
option.value === monitorStepKubernetesMonitor.clusterIdentifier,
304-
)}
298+
value={clusterOptions.find((option: DropdownOption) => {
299+
return (
300+
option.value === monitorStepKubernetesMonitor.clusterIdentifier
301+
);
302+
})}
305303
onChange={(value: DropdownValue | Array<DropdownValue> | null) => {
306304
props.onChange({
307305
...monitorStepKubernetesMonitor,
@@ -314,7 +312,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
314312
);
315313
};
316314

317-
const renderResourceFilters = (): ReactElement => {
315+
const renderResourceFilters: () => ReactElement = (): ReactElement => {
318316
return (
319317
<>
320318
{showNamespaceFilter && (
@@ -400,9 +398,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
400398
required={false}
401399
/>
402400
<Input
403-
value={
404-
monitorStepKubernetesMonitor.resourceFilters.podName || ""
405-
}
401+
value={monitorStepKubernetesMonitor.resourceFilters.podName || ""}
406402
onChange={(value: string) => {
407403
props.onChange({
408404
...monitorStepKubernetesMonitor,
@@ -420,7 +416,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
420416
);
421417
};
422418

423-
const renderQuickSetup = (): ReactElement => {
419+
const renderQuickSetup: () => ReactElement = (): ReactElement => {
424420
return (
425421
<div className="mt-4">
426422
<KubernetesTemplatePicker
@@ -464,7 +460,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
464460
);
465461
};
466462

467-
const renderCustomMetric = (): ReactElement => {
463+
const renderCustomMetric: () => ReactElement = (): ReactElement => {
468464
return (
469465
<div className="mt-4 space-y-4">
470466
<div>
@@ -493,10 +489,9 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
493489
/>
494490
<Dropdown
495491
options={resourceScopeOptions}
496-
value={resourceScopeOptions.find(
497-
(option: DropdownOption) =>
498-
option.value === customResourceScope,
499-
)}
492+
value={resourceScopeOptions.find((option: DropdownOption) => {
493+
return option.value === customResourceScope;
494+
})}
500495
onChange={(
501496
value: DropdownValue | Array<DropdownValue> | null,
502497
) => {
@@ -526,10 +521,9 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
526521
/>
527522
<Dropdown
528523
options={aggregationOptions}
529-
value={aggregationOptions.find(
530-
(option: DropdownOption) =>
531-
option.value === customAggregation,
532-
)}
524+
value={aggregationOptions.find((option: DropdownOption) => {
525+
return option.value === customAggregation;
526+
})}
533527
onChange={(
534528
value: DropdownValue | Array<DropdownValue> | null,
535529
) => {
@@ -543,9 +537,9 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
543537
monitorStepKubernetesMonitor.metricViewConfig.queryConfigs
544538
.length > 0
545539
) {
546-
const currentQueryConfig =
540+
const currentQueryConfig: MetricQueryConfigData =
547541
monitorStepKubernetesMonitor.metricViewConfig
548-
.queryConfigs[0];
542+
.queryConfigs[0]!;
549543
if (currentQueryConfig) {
550544
props.onChange({
551545
...monitorStepKubernetesMonitor,
@@ -601,7 +595,7 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
601595
);
602596
};
603597

604-
const renderAdvanced = (): ReactElement => {
598+
const renderAdvanced: () => ReactElement = (): ReactElement => {
605599
return (
606600
<div className="mt-4">
607601
<div>
@@ -612,10 +606,11 @@ const KubernetesMonitorStepForm: FunctionComponent<ComponentProps> = (
612606
/>
613607
<Dropdown
614608
options={resourceScopeOptions}
615-
value={resourceScopeOptions.find(
616-
(option: DropdownOption) =>
617-
option.value === monitorStepKubernetesMonitor.resourceScope,
618-
)}
609+
value={resourceScopeOptions.find((option: DropdownOption) => {
610+
return (
611+
option.value === monitorStepKubernetesMonitor.resourceScope
612+
);
613+
})}
619614
onChange={(value: DropdownValue | Array<DropdownValue> | null) => {
620615
props.onChange({
621616
...monitorStepKubernetesMonitor,

App/FeatureSet/Dashboard/src/Components/Form/Monitor/KubernetesMonitor/KubernetesTemplatePicker.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ const KubernetesTemplatePicker: FunctionComponent<ComponentProps> = (
7676
description: string;
7777
}) => {
7878
const categoryTemplates: Array<KubernetesAlertTemplate> =
79-
allTemplates.filter(
80-
(t: KubernetesAlertTemplate) => t.category === cat.category,
81-
);
79+
allTemplates.filter((t: KubernetesAlertTemplate) => {
80+
return t.category === cat.category;
81+
});
8282

8383
if (categoryTemplates.length === 0) {
8484
return null;

App/FeatureSet/Dashboard/src/Components/Form/Monitor/MonitorStep.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ const MonitorStepElement: FunctionComponent<ComponentProps> = (
133133
const [error, setError] = useState<string>("");
134134
const [isLoading, setIsLoading] = useState<boolean>(true);
135135

136-
137136
const fetchLogAttributes: PromiseVoidFunction = async (): Promise<void> => {
138137
const attributeRepsonse: HTTPResponse<JSONObject> | HTTPErrorResponse =
139138
await API.post({

App/FeatureSet/Dashboard/src/Components/Kubernetes/KubernetesContainersTab.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ function formatK8sResourceValue(key: string, value: string): string {
3030
}
3131

3232
// CPU whole cores (e.g. "2" = 2 cores)
33-
if (key.toLowerCase() === "cpu" && /^\d+$/.test(value)) {
33+
const wholeNumberRegex: RegExp = /^\d+$/;
34+
if (key.toLowerCase() === "cpu" && wholeNumberRegex.test(value)) {
3435
const cores: number = parseInt(value);
3536
return `${value} (${cores} CPU core${cores !== 1 ? "s" : ""})`;
3637
}
3738

3839
// Memory values: Ki, Mi, Gi, Ti
39-
const memMatch: RegExpMatchArray | null = value.match(
40-
/^(\d+)(Ki|Mi|Gi|Ti)$/,
41-
);
40+
const memMatch: RegExpMatchArray | null = value.match(/^(\d+)(Ki|Mi|Gi|Ti)$/);
4241
if (memMatch) {
4342
const num: number = parseInt(memMatch[1] || "0");
4443
const unit: string = memMatch[2] || "";
@@ -55,9 +54,7 @@ function formatK8sResourceValue(key: string, value: string): string {
5554
}
5655

5756
// Ephemeral storage: same units
58-
const storageMatch: RegExpMatchArray | null = value.match(
59-
/^(\d+)(K|M|G|T)$/,
60-
);
57+
const storageMatch: RegExpMatchArray | null = value.match(/^(\d+)(K|M|G|T)$/);
6158
if (storageMatch) {
6259
const num: number = parseInt(storageMatch[1] || "0");
6360
const unit: string = storageMatch[2] || "";
@@ -293,9 +290,7 @@ const ContainerCard: FunctionComponent<ContainerCardProps> = (
293290
}}
294291
className="flex items-center gap-1.5 text-sm text-indigo-600 hover:text-indigo-800 font-medium transition-colors"
295292
>
296-
<span className="text-xs">
297-
{showEnv ? "▼" : "▶"}
298-
</span>
293+
<span className="text-xs">{showEnv ? "▼" : "▶"}</span>
299294
Environment Variables ({props.container.env.length})
300295
</button>
301296
{showEnv && (
@@ -315,9 +310,7 @@ const ContainerCard: FunctionComponent<ContainerCardProps> = (
315310
}}
316311
className="flex items-center gap-1.5 text-sm text-indigo-600 hover:text-indigo-800 font-medium transition-colors"
317312
>
318-
<span className="text-xs">
319-
{showMounts ? "▼" : "▶"}
320-
</span>
313+
<span className="text-xs">{showMounts ? "▼" : "▶"}</span>
321314
Volume Mounts ({props.container.volumeMounts.length})
322315
</button>
323316
{showMounts && (

App/FeatureSet/Dashboard/src/Components/Kubernetes/KubernetesEnvVarsTab.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ const KubernetesEnvVarsTab: FunctionComponent<ComponentProps> = (
111111

112112
return (
113113
<span className="font-mono text-gray-600">
114-
{item.value || (
115-
<span className="text-gray-400 italic">empty</span>
116-
)}
114+
{item.value || <span className="text-gray-400 italic">empty</span>}
117115
</span>
118116
);
119117
},
@@ -126,10 +124,7 @@ const KubernetesEnvVarsTab: FunctionComponent<ComponentProps> = (
126124
<div className="px-4 pt-4">
127125
<div className="relative">
128126
<div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
129-
<Icon
130-
icon={IconProp.Search}
131-
className="h-4 w-4 text-gray-400"
132-
/>
127+
<Icon icon={IconProp.Search} className="h-4 w-4 text-gray-400" />
133128
</div>
134129
<input
135130
type="text"

0 commit comments

Comments
 (0)