Skip to content

Commit 2bf9625

Browse files
committed
UI improvement, text box where analytics queries are enters is expandable
1 parent 48f22d1 commit 2bf9625

File tree

1 file changed

+52
-38
lines changed

1 file changed

+52
-38
lines changed

src/ui/src/components/document-analytics-layout/AnalyticsQueryInput.jsx

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
import React, { useState, useEffect, useRef } from 'react';
44
import PropTypes from 'prop-types';
55
import { API, Logger } from 'aws-amplify';
6-
import { FormField, Input, Button, Grid, Box, SpaceBetween, ButtonDropdown } from '@awsui/components-react';
6+
import { FormField, Textarea, Button, Grid, Box, SpaceBetween, ButtonDropdown } from '@awsui/components-react';
77
import listAnalyticsJobs from '../../graphql/queries/listAnalyticsJobs';
88
import deleteAnalyticsJob from '../../graphql/queries/deleteAnalyticsJob';
99

10+
// Custom styles for expandable textarea
11+
const textareaStyles = `
12+
.expandable-textarea {
13+
max-height: 250px;
14+
overflow-y: auto !important;
15+
resize: vertical;
16+
}
17+
`;
18+
1019
const logger = new Logger('AnalyticsQueryInput');
1120

1221
const AnalyticsQueryInput = ({ onSubmit, isSubmitting, selectedResult }) => {
@@ -272,45 +281,50 @@ const AnalyticsQueryInput = ({ onSubmit, isSubmitting, selectedResult }) => {
272281
};
273282

274283
return (
275-
<form onSubmit={handleSubmit}>
276-
<SpaceBetween size="s">
277-
<Grid gridDefinition={[{ colspan: { default: 12, xxs: 9 } }, { colspan: { default: 12, xxs: 3 } }]}>
278-
<FormField label="Enter your analytics query">
279-
<Input
280-
placeholder="How has the number of documents processed per day trended over the past three weeks?"
281-
value={query}
282-
onChange={({ detail }) => setQuery(detail.value)}
284+
<>
285+
<style>{textareaStyles}</style>
286+
<form onSubmit={handleSubmit}>
287+
<SpaceBetween size="s">
288+
<Grid gridDefinition={[{ colspan: { default: 12, xxs: 9 } }, { colspan: { default: 12, xxs: 3 } }]}>
289+
<FormField label="Enter your analytics query">
290+
<Textarea
291+
placeholder="How has the number of documents processed per day trended over the past three weeks?"
292+
value={query}
293+
onChange={({ detail }) => setQuery(detail.value)}
294+
disabled={isSubmitting}
295+
rows={2}
296+
className="expandable-textarea"
297+
/>
298+
</FormField>
299+
<Box padding={{ top: 'xl' }}>
300+
{' '}
301+
{/* Add top padding to align with input box */}
302+
<Button variant="primary" type="submit" disabled={!query.trim() || isSubmitting} fullWidth>
303+
{isSubmitting ? 'Submitting...' : 'Submit query'}
304+
</Button>
305+
</Box>
306+
</Grid>
307+
308+
<FormField label="Previous queries">
309+
<ButtonDropdown
310+
items={createDropdownItems()}
311+
onItemClick={handleDropdownItemClick}
312+
onFocus={() => fetchQueryHistory()}
313+
loading={isLoadingHistory}
283314
disabled={isSubmitting}
284-
/>
315+
>
316+
{(() => {
317+
if (!selectedOption) return 'Select a previous query';
318+
if (selectedOption.label?.length > 40) {
319+
return `${selectedOption.label.substring(0, 40)}...`;
320+
}
321+
return selectedOption.label || 'Selected query';
322+
})()}
323+
</ButtonDropdown>
285324
</FormField>
286-
<Box padding={{ top: 'xl' }}>
287-
{' '}
288-
{/* Add top padding to align with input box */}
289-
<Button variant="primary" type="submit" disabled={!query.trim() || isSubmitting} fullWidth>
290-
{isSubmitting ? 'Submitting...' : 'Submit query'}
291-
</Button>
292-
</Box>
293-
</Grid>
294-
295-
<FormField label="Previous queries">
296-
<ButtonDropdown
297-
items={createDropdownItems()}
298-
onItemClick={handleDropdownItemClick}
299-
onFocus={() => fetchQueryHistory()}
300-
loading={isLoadingHistory}
301-
disabled={isSubmitting}
302-
>
303-
{(() => {
304-
if (!selectedOption) return 'Select a previous query';
305-
if (selectedOption.label?.length > 40) {
306-
return `${selectedOption.label.substring(0, 40)}...`;
307-
}
308-
return selectedOption.label || 'Selected query';
309-
})()}
310-
</ButtonDropdown>
311-
</FormField>
312-
</SpaceBetween>
313-
</form>
325+
</SpaceBetween>
326+
</form>
327+
</>
314328
);
315329
};
316330

0 commit comments

Comments
 (0)