Skip to content

Commit 3e2f153

Browse files
authored
Various bug fixes & improvements (#644)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent a484199 commit 3e2f153

21 files changed

+214
-171
lines changed

common/interfaces.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type MDSQueryParams = {
2727

2828
export type ConfigFieldType =
2929
| 'string'
30+
| 'textArea'
3031
| 'json'
3132
| 'jsonArray'
3233
| 'jsonString'

public/app.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ interface Props extends RouteComponentProps {
2929
export const FlowFrameworkDashboardsApp = (props: Props) => {
3030
const { setHeaderActionMenu } = props;
3131

32-
3332
// Render the application DOM.
3433
return (
3534
<EuiFlexGroup

public/configs/ingest_processors/copy_ingest_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class CopyIngestProcessor extends Processor {
4949
},
5050
{
5151
id: 'description',
52-
type: 'string',
52+
type: 'textArea',
5353
},
5454
{
5555
id: 'tag',

public/configs/ingest_processors/text_chunking_ingest_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class TextChunkingIngestProcessor extends Processor {
6464
},
6565
{
6666
id: 'description',
67-
type: 'string',
67+
type: 'textArea',
6868
},
6969
{
7070
id: 'tag',

public/configs/ingest_processors/text_embedding_ingest_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class TextEmbeddingIngestProcessor extends Processor {
2121
this.optionalFields = [
2222
{
2323
id: 'description',
24-
type: 'string',
24+
type: 'textArea',
2525
},
2626
{
2727
id: 'tag',

public/configs/ingest_processors/text_image_embedding_ingest_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class TextImageEmbeddingIngestProcessor extends Processor {
2525
this.optionalFields = [
2626
{
2727
id: 'description',
28-
type: 'string',
28+
type: 'textArea',
2929
},
3030
{
3131
id: 'tag',

public/configs/ml_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export abstract class MLProcessor extends Processor {
6060
},
6161
{
6262
id: 'description',
63-
type: 'string',
63+
type: 'textArea',
6464
},
6565
];
6666
}

public/configs/search_response_processors/collapse_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class CollapseProcessor extends Processor {
3333
},
3434
{
3535
id: 'description',
36-
type: 'string',
36+
type: 'textArea',
3737
},
3838
{
3939
id: 'ignore_failure',

public/configs/search_response_processors/normalization_processor.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ export class NormalizationProcessor extends Processor {
2121
{
2222
id: 'weights',
2323
type: 'string',
24+
value: '0.5, 0.5',
2425
},
2526
{
2627
id: 'normalization_technique',
2728
type: 'select',
2829
selectOptions: ['min_max', 'l2'],
30+
value: 'min_max',
2931
},
3032
{
3133
id: 'combination_technique',
3234
type: 'select',
3335
selectOptions: ['arithmetic_mean', 'geometric_mean', 'harmonic_mean'],
36+
value: 'arithmetic_mean',
3437
},
3538
{
3639
id: 'description',
37-
type: 'string',
40+
type: 'textArea',
3841
},
3942
{
4043
id: 'tag',

public/configs/search_response_processors/rerank_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class RerankProcessor extends Processor {
4141
},
4242
{
4343
id: 'description',
44-
type: 'string',
44+
type: 'textArea',
4545
},
4646
{
4747
id: 'ignore_failure',

public/configs/sort_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export abstract class SortProcessor extends Processor {
3434
},
3535
{
3636
id: 'description',
37-
type: 'string',
37+
type: 'textArea',
3838
},
3939
{
4040
id: 'tag',

public/configs/split_processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export abstract class SplitProcessor extends Processor {
3939
},
4040
{
4141
id: 'description',
42-
type: 'string',
42+
type: 'textArea',
4343
},
4444
{
4545
id: 'tag',

public/pages/workflow_detail/components/header.tsx

+12-33
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import React, { useEffect, useState, ReactElement } from 'react';
7-
import { useHistory } from 'react-router-dom';
87
import {
98
EuiPageHeader,
109
EuiFlexGroup,
@@ -29,10 +28,10 @@ import {
2928
import {
3029
APP_PATH,
3130
USE_NEW_HOME_PAGE,
32-
constructUrlWithParams,
3331
getDataSourceId,
3432
dataSourceFilterFn,
3533
formikToUiConfig,
34+
constructHrefWithDataSourceId,
3635
} from '../../../utils';
3736
import { ExportModal } from './export_modal';
3837
import {
@@ -70,11 +69,11 @@ interface WorkflowDetailHeaderProps {
7069
unsavedSearchProcessors: boolean;
7170
setUnsavedSearchProcessors: (unsavedSearchProcessors: boolean) => void;
7271
setActionMenu: (menuMount?: MountPoint) => void;
72+
setBlockNavigation: (blockNavigation: boolean) => void;
7373
}
7474

7575
export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
7676
const dispatch = useAppDispatch();
77-
const history = useHistory();
7877
const { resetForm, setTouched, values, touched, dirty } = useFormikContext<
7978
WorkflowFormValues
8079
>();
@@ -116,12 +115,6 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
116115
};
117116
}, [setHeaderVariant, USE_NEW_HOME_PAGE]);
118117

119-
const onExitButtonClick = () => {
120-
history.replace(
121-
constructUrlWithParams(APP_PATH.WORKFLOWS, undefined, dataSourceId)
122-
);
123-
};
124-
125118
// get & render the data source component, if applicable
126119
let DataSourceComponent: ReactElement | null = null;
127120
if (dataSourceEnabled && getDataSourceManagementPlugin() && dataSourceId) {
@@ -200,21 +193,8 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
200193
? ingestSaveButtonDisabled
201194
: searchSaveButtonDisabled;
202195

203-
// Add warning when exiting with unsaved changes
204-
function alertFn(e: BeforeUnloadEvent) {
205-
e.preventDefault();
206-
}
207-
208-
// Hook for warning of unsaved changes if a browser refresh is detected
209196
useEffect(() => {
210-
if (!saveDisabled) {
211-
window.addEventListener('beforeunload', alertFn);
212-
} else {
213-
window.removeEventListener('beforeunload', alertFn);
214-
}
215-
return () => {
216-
window.removeEventListener('beforeunload', alertFn);
217-
};
197+
props.setBlockNavigation(!saveDisabled);
218198
}, [saveDisabled]);
219199

220200
// Utility fn to update the workflow UI config only, based on the current form values.
@@ -319,7 +299,10 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
319299
iconType: 'exit',
320300
tooltip: 'Return to projects',
321301
ariaLabel: 'Exit',
322-
run: onExitButtonClick,
302+
href: constructHrefWithDataSourceId(
303+
APP_PATH.WORKFLOWS,
304+
dataSourceId
305+
),
323306
controlType: 'icon',
324307
} as TopNavMenuIconData,
325308
{
@@ -407,15 +390,10 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
407390
Export
408391
</EuiSmallButton>,
409392
<EuiSmallButtonEmpty
410-
onClick={() => {
411-
history.replace(
412-
constructUrlWithParams(
413-
APP_PATH.WORKFLOWS,
414-
undefined,
415-
dataSourceId
416-
)
417-
);
418-
}}
393+
href={constructHrefWithDataSourceId(
394+
APP_PATH.WORKFLOWS,
395+
dataSourceId
396+
)}
419397
data-testid="closeButton"
420398
>
421399
Close
@@ -430,6 +408,7 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
430408
{`Save`}
431409
</EuiSmallButtonEmpty>,
432410
<EuiSmallButtonIcon
411+
data-testid="undoButton"
433412
iconType="editorUndo"
434413
aria-label="undo changes"
435414
isDisabled={undoDisabled}

public/pages/workflow_detail/workflow_detail.test.tsx

-13
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,6 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
149149
);
150150
});
151151
});
152-
153-
test('tests navigation to workflows list on Close button click', async () => {
154-
const { getByTestId, history } = renderWithRouter(
155-
workflowId,
156-
workflowName,
157-
WORKFLOW_TYPE.CUSTOM
158-
);
159-
// The WorkflowDetail Page Close button should navigate back to the workflows list
160-
userEvent.click(getByTestId('closeButton'));
161-
await waitFor(() => {
162-
expect(history.location.pathname).toBe('/workflows');
163-
});
164-
});
165152
});
166153

167154
describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow)', () => {

0 commit comments

Comments
 (0)