Skip to content

Commit 17572e2

Browse files
authored
klogs-plugin: Use TextArea instead of TextInput (#447)
Use TextArea for klogs Plugin to insert multiple lines.
1 parent 413a82f commit 17572e2

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

plugins/plugin-klogs/src/components/page/AggregationToolbar.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { TextInput } from '@patternfly/react-core';
2+
import { TextArea } from '@patternfly/react-core';
33

44
import { IOptionsAdditionalFields, ITimes, Options, Toolbar, ToolbarItem } from '@kobsio/shared';
55
import { IAggregationOptions } from '../../utils/interfaces';
@@ -27,7 +27,14 @@ const AggregationToolbar: React.FunctionComponent<IAggregationToolbarProps> = ({
2727
return (
2828
<Toolbar usePageInsets={true}>
2929
<ToolbarItem grow={true}>
30-
<TextInput aria-label="Query" type="text" value={options.query} onChange={changeQuery} />
30+
<TextArea
31+
aria-label="Query"
32+
resizeOrientation="vertical"
33+
rows={1}
34+
type="text"
35+
value={options.query}
36+
onChange={changeQuery}
37+
/>
3138
</ToolbarItem>
3239

3340
<Options times={options.times} showOptions={true} showSearchButton={false} setOptions={changeOptions} />

plugins/plugin-klogs/src/components/page/LogsToolbar.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { TextInput } from '@patternfly/react-core';
2+
import { TextArea } from '@patternfly/react-core';
33

44
import { IOptionsAdditionalFields, ITimes, Options, Toolbar, ToolbarItem } from '@kobsio/shared';
55
import { IOptions } from '../../utils/interfaces';
@@ -12,11 +12,12 @@ interface ILogsToolbarProps {
1212
const LogsToolbar: React.FunctionComponent<ILogsToolbarProps> = ({ options, setOptions }: ILogsToolbarProps) => {
1313
const [query, setQuery] = useState<string>(options.query);
1414

15-
// onEnter is used to detect if the user pressed the "ENTER" key. If this is the case we are calling the setOptions
16-
// function to trigger the search.
17-
// use "SHIFT" + "ENTER".
18-
const onEnter = (e: React.KeyboardEvent<HTMLInputElement> | undefined): void => {
15+
// onEnter is used to detect if the user pressed the "ENTER" key. If this is the case we will not add a newline.
16+
// Instead of this we are calling the setOptions function to trigger the search.
17+
// use "SHIFT" + "ENTER" to write multiple lines.
18+
const onEnter = (e: React.KeyboardEvent<HTMLTextAreaElement> | undefined): void => {
1919
if (e?.key === 'Enter' && !e.shiftKey) {
20+
e.preventDefault();
2021
setOptions({ ...options, query: query });
2122
}
2223
};
@@ -42,8 +43,10 @@ const LogsToolbar: React.FunctionComponent<ILogsToolbarProps> = ({ options, setO
4243
return (
4344
<Toolbar usePageInsets={true}>
4445
<ToolbarItem grow={true}>
45-
<TextInput
46+
<TextArea
4647
aria-label="Query"
48+
resizeOrientation="vertical"
49+
rows={1}
4750
type="text"
4851
value={query}
4952
onChange={(value: string): void => setQuery(value)}

plugins/plugin-sql/src/components/page/PageToolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const PageToolbar: React.FunctionComponent<IPageToolbarProps> = ({ options, setO
2020

2121
// onEnter is used to detect if the user pressed the "ENTER" key. If this is the case we are calling the setOptions
2222
// function to trigger the search.
23-
// use "SHIFT" + "ENTER".
23+
// use "SHIFT" + "ENTER" to write multiple lines.
2424
const onEnter = (e: React.KeyboardEvent<HTMLTextAreaElement> | undefined): void => {
2525
if (e?.key === 'Enter' && !e.shiftKey) {
2626
e.preventDefault();

0 commit comments

Comments
 (0)