Skip to content

Commit ce631fa

Browse files
authored
Merge pull request #2315 from Particular/john/small_improvements
Fixing typescript typings
2 parents 27d4787 + 43dd966 commit ce631fa

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed

src/Frontend/package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"bootstrap": "^5.3.3",
2727
"bootstrap-icons": "^1.11.3",
2828
"codemirror": "^6.0.1",
29+
"lodash.debounce": "^4.0.8",
2930
"lossless-json": "^4.0.2",
3031
"memoize-one": "^6.0.0",
3132
"moment": "^2.30.1",
@@ -48,6 +49,7 @@
4849
"@testing-library/vue": "^8.1.0",
4950
"@tsconfig/node18": "^18.2.4",
5051
"@types/bootstrap": "^5.2.10",
52+
"@types/lodash": "^4.17.16",
5153
"@types/node": "^22.13.10",
5254
"@vitejs/plugin-vue": "^5.2.3",
5355
"@vitest/coverage-v8": "^3.0.9",

src/Frontend/src/components/FilterInput.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<script setup lang="ts">
2+
import { ref, watch } from "vue";
3+
import debounce from "lodash/debounce";
4+
25
const model = defineModel<string>({ required: true });
3-
defineProps({
4-
placeholder: {
5-
type: String,
6-
default: "Filter by name...", // Default value
7-
},
6+
const props = withDefaults(defineProps<{ placeholder?: string; ariaLabel?: string }>(), { placeholder: "Filter by name...", ariaLabel: "filter by name" });
7+
const localInput = ref<string>(model.value);
8+
9+
const debounceUpdateModel = debounce((value: string) => {
10+
model.value = value;
11+
}, 600);
12+
13+
watch(localInput, (newValue) => {
14+
debounceUpdateModel(newValue);
815
});
916
</script>
1017

1118
<template>
1219
<div role="search" aria-label="filter" class="filter-input">
13-
<input type="search" :placeholder="placeholder" aria-label="filter by name" class="form-control-static filter-input" v-model="model" />
20+
<input type="search" :placeholder="props.placeholder" :aria-label="props.ariaLabel" class="form-control-static filter-input" v-model="localInput" />
1421
</div>
1522
</template>
1623

src/Frontend/src/components/messages/HeadersView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const filteredHeaders = computed(() => {
2828
<div class="text-search-container">
2929
<div class="text-search">
3030
<div class="filter-group">
31-
<FilterInput v-model="searchTerm" aria-label="Filter by name" :placeholder="'Search for a header key or value...'" />
31+
<FilterInput v-model="searchTerm" :aria-label="`Search for a header key or value`" :placeholder="'Search for a header key or value...'" />
3232
</div>
3333
</div>
3434
</div>

src/Frontend/test/specs/heartbeats/configuring-heartbeats.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, describe } from "../../drivers/vitest/driver";
22
import * as precondition from "../../preconditions";
3-
import { expect } from "vitest";
3+
import { expect, vi } from "vitest";
44
import { getNothingToConfigureStatus } from "./questions/getNothingToConfigureStatus";
55
import { navigateToHeartbeatsConfiguration, navigateToUnHealthyHeartbeats } from "./actions/navigateToHeartbeatsTabs";
66
import { getEndpointsForConfiguration } from "./questions/getEndpointsForConfiguration";
@@ -12,6 +12,11 @@ import { healthyEndpointTemplate } from "../../mocks/heartbeat-endpoint-template
1212
import { setHeartbeatFilter } from "./actions/setHeartbeatFilter";
1313
import { getHeartbeatFilterValue } from "./questions/getHeartbeatFilterValue";
1414

15+
vi.mock("lodash/debounce", () => ({
16+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
17+
default: (fn: Function) => fn,
18+
}));
19+
1520
describe("FEATURE: Heartbeats configuration", () => {
1621
describe("RULE: A list of all endpoints with the heartbeats plug-in installed should be displayed", () => {
1722
test("EXAMPLE: With no endpoints, the text 'Nothing to configure' should be displayed", async ({ driver }) => {

src/Frontend/test/specs/monitoring/filtering-endpoints.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect } from "vitest";
1+
import { vi, expect } from "vitest";
22
import { test, describe } from "../../drivers/vitest/driver";
33
import { enterFilterString } from "./actions/enterFilterString";
44
import { groupEndpointsBy } from "./actions/groupEndpointsBy";
@@ -8,6 +8,11 @@ import { currentFilterValueToBe } from "./questions/currentFilterValueToBe";
88
import { endpointsNames } from "./questions/endpointsNames";
99
import * as precondition from "../../preconditions";
1010

11+
vi.mock("lodash/debounce", () => ({
12+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
13+
default: (fn: Function) => fn,
14+
}));
15+
1116
describe("FEATURE: Endpoint filtering", () => {
1217
describe("RULE: List of monitoring endpoints should be filterable by the name", () => {
1318
[

0 commit comments

Comments
 (0)