Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport main] Various bug fixes & improvements #648

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type MDSQueryParams = {

export type ConfigFieldType =
| 'string'
| 'textArea'
| 'json'
| 'jsonArray'
| 'jsonString'
Expand Down
1 change: 0 additions & 1 deletion public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ interface Props extends RouteComponentProps {
export const FlowFrameworkDashboardsApp = (props: Props) => {
const { setHeaderActionMenu } = props;


// Render the application DOM.
return (
<EuiFlexGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CopyIngestProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class TextChunkingIngestProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class TextEmbeddingIngestProcessor extends Processor {
this.optionalFields = [
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class TextImageEmbeddingIngestProcessor extends Processor {
this.optionalFields = [
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
2 changes: 1 addition & 1 deletion public/configs/ml_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export abstract class MLProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CollapseProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'ignore_failure',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@ export class NormalizationProcessor extends Processor {
{
id: 'weights',
type: 'string',
value: '0.5, 0.5',
},
{
id: 'normalization_technique',
type: 'select',
selectOptions: ['min_max', 'l2'],
value: 'min_max',
},
{
id: 'combination_technique',
type: 'select',
selectOptions: ['arithmetic_mean', 'geometric_mean', 'harmonic_mean'],
value: 'arithmetic_mean',
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class RerankProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'ignore_failure',
Expand Down
2 changes: 1 addition & 1 deletion public/configs/sort_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export abstract class SortProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
2 changes: 1 addition & 1 deletion public/configs/split_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export abstract class SplitProcessor extends Processor {
},
{
id: 'description',
type: 'string',
type: 'textArea',
},
{
id: 'tag',
Expand Down
45 changes: 12 additions & 33 deletions public/pages/workflow_detail/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import React, { useEffect, useState, ReactElement } from 'react';
import { useHistory } from 'react-router-dom';
import {
EuiPageHeader,
EuiFlexGroup,
Expand All @@ -29,10 +28,10 @@ import {
import {
APP_PATH,
USE_NEW_HOME_PAGE,
constructUrlWithParams,
getDataSourceId,
dataSourceFilterFn,
formikToUiConfig,
constructHrefWithDataSourceId,
} from '../../../utils';
import { ExportModal } from './export_modal';
import {
Expand Down Expand Up @@ -70,11 +69,11 @@ interface WorkflowDetailHeaderProps {
unsavedSearchProcessors: boolean;
setUnsavedSearchProcessors: (unsavedSearchProcessors: boolean) => void;
setActionMenu: (menuMount?: MountPoint) => void;
setBlockNavigation: (blockNavigation: boolean) => void;
}

export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
const dispatch = useAppDispatch();
const history = useHistory();
const { resetForm, setTouched, values, touched, dirty } = useFormikContext<
WorkflowFormValues
>();
Expand Down Expand Up @@ -116,12 +115,6 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
};
}, [setHeaderVariant, USE_NEW_HOME_PAGE]);

const onExitButtonClick = () => {
history.replace(
constructUrlWithParams(APP_PATH.WORKFLOWS, undefined, dataSourceId)
);
};

// get & render the data source component, if applicable
let DataSourceComponent: ReactElement | null = null;
if (dataSourceEnabled && getDataSourceManagementPlugin() && dataSourceId) {
Expand Down Expand Up @@ -200,21 +193,8 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
? ingestSaveButtonDisabled
: searchSaveButtonDisabled;

// Add warning when exiting with unsaved changes
function alertFn(e: BeforeUnloadEvent) {
e.preventDefault();
}

// Hook for warning of unsaved changes if a browser refresh is detected
useEffect(() => {
if (!saveDisabled) {
window.addEventListener('beforeunload', alertFn);
} else {
window.removeEventListener('beforeunload', alertFn);
}
return () => {
window.removeEventListener('beforeunload', alertFn);
};
props.setBlockNavigation(!saveDisabled);
}, [saveDisabled]);

// Utility fn to update the workflow UI config only, based on the current form values.
Expand Down Expand Up @@ -319,7 +299,10 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
iconType: 'exit',
tooltip: 'Return to projects',
ariaLabel: 'Exit',
run: onExitButtonClick,
href: constructHrefWithDataSourceId(
APP_PATH.WORKFLOWS,
dataSourceId
),
controlType: 'icon',
} as TopNavMenuIconData,
{
Expand Down Expand Up @@ -407,15 +390,10 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
Export
</EuiSmallButton>,
<EuiSmallButtonEmpty
onClick={() => {
history.replace(
constructUrlWithParams(
APP_PATH.WORKFLOWS,
undefined,
dataSourceId
)
);
}}
href={constructHrefWithDataSourceId(
APP_PATH.WORKFLOWS,
dataSourceId
)}
data-testid="closeButton"
>
Close
Expand All @@ -430,6 +408,7 @@ export function WorkflowDetailHeader(props: WorkflowDetailHeaderProps) {
{`Save`}
</EuiSmallButtonEmpty>,
<EuiSmallButtonIcon
data-testid="undoButton"
iconType="editorUndo"
aria-label="undo changes"
isDisabled={undoDisabled}
Expand Down
13 changes: 0 additions & 13 deletions public/pages/workflow_detail/workflow_detail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,6 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
);
});
});

test('tests navigation to workflows list on Close button click', async () => {
const { getByTestId, history } = renderWithRouter(
workflowId,
workflowName,
WORKFLOW_TYPE.CUSTOM
);
// The WorkflowDetail Page Close button should navigate back to the workflows list
userEvent.click(getByTestId('closeButton'));
await waitFor(() => {
expect(history.location.pathname).toBe('/workflows');
});
});
});

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