Skip to content

Commit d226d81

Browse files
committed
Merge remote-tracking branch 'upstream/main' into bi-multi-project
2 parents 307c614 + 66d595a commit d226d81

File tree

5 files changed

+42
-18
lines changed

5 files changed

+42
-18
lines changed

workspaces/ballerina/ballerina-side-panel/src/components/editors/ExpressionField.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const ExpressionField: React.FC<ExpressionField> = ({
159159
targetLineRange={targetLineRange}
160160
extractArgsFromFunction={extractArgsFromFunction}
161161
onOpenExpandedMode={onOpenExpandedMode}
162+
onRemove={onRemove}
162163
isInExpandedMode={isInExpandedMode}
163164
/>
164165
);

workspaces/ballerina/ballerina-side-panel/src/components/editors/MultiModeExpressionEditor/ChipExpressionEditor/ChipExpressionBaseComponent.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
setCursorPositionToExpressionModel,
3838
updateTokens,
3939
} from "./utils";
40-
import { CompletionItem, FnSignatureDocumentation, HelperPaneHeight } from "@wso2/ui-toolkit";
40+
import { Button, Codicon, CompletionItem, FnSignatureDocumentation, HelperPaneHeight, ThemeColors } from "@wso2/ui-toolkit";
4141
import { useFormContext } from "../../../../context";
4242
import { DATA_ELEMENT_ID_ATTRIBUTE, FOCUS_MARKER, ARROW_LEFT_MARKER, ARROW_RIGHT_MARKER, BACKSPACE_MARKER, COMPLETIONS_MARKER, HELPER_MARKER, DELETE_MARKER } from "./constants";
4343
import { LineRange } from "@wso2/ballerina-core/lib/interfaces/common";
@@ -63,6 +63,7 @@ export type ChipExpressionBaseComponentProps = {
6363
}>;
6464
targetLineRange?: LineRange;
6565
onOpenExpandedMode?: () => void;
66+
onRemove?: () => void;
6667
isInExpandedMode?: boolean;
6768
}
6869

@@ -553,6 +554,11 @@ export const ChipExpressionBaseComponent = (props: ChipExpressionBaseComponentPr
553554
/>
554555
</AutoExpandingEditableDiv>
555556
</div>
557+
{props.onRemove && (
558+
<Button appearance="icon" onClick={props.onRemove} tooltip="Remove Expression" sx={{ marginLeft: '4px' }}>
559+
<Codicon name="trash" sx={{ color: ThemeColors.ERROR, fontSize: '16px' }} />
560+
</Button>
561+
)}
556562
</ChipEditorContainer >
557563
)
558564
}

workspaces/ballerina/ballerina-visualizer/src/views/BI/Connection/AddConnectionWizard/index.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { useEffect, useRef, useState } from "react";
2020
import styled from "@emotion/styled";
2121
import {
2222
AvailableNode,
23+
DataMapperDisplayMode,
2324
DIRECTORY_MAP,
2425
EVENT_TYPE,
2526
FlowNode,
@@ -42,6 +43,7 @@ import { HelperView } from "../../HelperView";
4243
import { BodyText } from "../../../styles";
4344
import { DownloadIcon } from "../../../../components/DownloadIcon";
4445
import FormGeneratorNew from "../../Forms/FormGeneratorNew";
46+
import { FormSubmitOptions } from "../../FlowDiagram";
4547

4648
const Container = styled.div`
4749
width: 100%;
@@ -232,7 +234,7 @@ export function AddConnectionWizard(props: AddConnectionWizardProps) {
232234
setCurrentStep(WizardStep.GENERATE_CONNECTOR);
233235
};
234236

235-
const handleOnFormSubmit = async (node: FlowNode) => {
237+
const handleOnFormSubmit = async (node: FlowNode, _dataMapperMode?: DataMapperDisplayMode, options?: FormSubmitOptions) => {
236238
console.log(">>> on form submit", node);
237239
if (selectedNodeRef.current) {
238240
setSavingFormStatus(SavingFormStatus.SAVING);
@@ -258,15 +260,28 @@ export function AddConnectionWizard(props: AddConnectionWizardProps) {
258260
};
259261
}
260262

263+
// Check if the node is a connector
264+
// otherwise, this is a new variable creation or something else
265+
// triggered by the helper pane
266+
const isConnector = node.codedata.node === "NEW_CONNECTION";
267+
261268
rpcClient
262269
.getBIDiagramRpcClient()
263270
.getSourceCode({
264271
filePath: connectionsFilePath,
265272
flowNode: node,
266-
isConnector: true,
273+
isConnector: isConnector,
267274
})
268275
.then((response) => {
269276
console.log(">>> Updated source code", response);
277+
if (!isConnector) {
278+
setSavingFormStatus(SavingFormStatus.SUCCESS);
279+
selectedNodeRef.current = undefined;
280+
if (options?.postUpdateCallBack) {
281+
options.postUpdateCallBack();
282+
}
283+
return;
284+
};
270285
if (response.artifacts.length > 0) {
271286
// clear memory
272287
selectedNodeRef.current = undefined;
@@ -295,12 +310,12 @@ export function AddConnectionWizard(props: AddConnectionWizardProps) {
295310
prevFields.map((field) =>
296311
field.key === "module"
297312
? {
298-
...field,
299-
diagnostics: [
300-
...field.diagnostics,
301-
{ message: response.errorMessage, severity: "ERROR" },
302-
],
303-
}
313+
...field,
314+
diagnostics: [
315+
...field.diagnostics,
316+
{ message: response.errorMessage, severity: "ERROR" },
317+
],
318+
}
304319
: field
305320
)
306321
);

workspaces/ballerina/ballerina-visualizer/src/views/BI/Connection/ConnectionConfigView/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
import React, { ReactNode, useEffect, useState } from "react";
2020
import styled from "@emotion/styled";
2121
import { ExpressionFormField } from "@wso2/ballerina-side-panel";
22-
import { FlowNode, LineRange, SubPanel } from "@wso2/ballerina-core";
22+
import { DataMapperDisplayMode, FlowNode, LineRange, SubPanel } from "@wso2/ballerina-core";
2323
import FormGenerator from "../../Forms/FormGenerator";
2424
import { useRpcContext } from "@wso2/ballerina-rpc-client";
2525
import { SidePanelView } from "../../FlowDiagram/PanelManager";
2626
import { ConnectionKind } from "../../../../components/ConnectionSelector";
27+
import { FormSubmitOptions } from "../../FlowDiagram";
2728

2829
const Container = styled.div`
2930
max-width: 600px;
@@ -50,7 +51,7 @@ interface ConnectionConfigViewProps {
5051
submitText?: string;
5152
isSaving?: boolean;
5253
selectedNode: FlowNode;
53-
onSubmit: (node?: FlowNode) => void;
54+
onSubmit: (updatedNode?: FlowNode, dataMapperMode?: DataMapperDisplayMode, options?: FormSubmitOptions) => void;
5455
openSubPanel?: (subPanel: SubPanel) => void;
5556
updatedExpressionField?: ExpressionFormField;
5657
resetUpdatedExpressionField?: () => void;
@@ -114,6 +115,7 @@ export function ConnectionConfigView(props: ConnectionConfigViewProps) {
114115
resetUpdatedExpressionField={resetUpdatedExpressionField}
115116
disableSaveButton={isPullingConnector}
116117
navigateToPanel={navigateToPanel}
118+
handleOnFormSubmit={onSubmit}
117119
/>
118120
)}
119121
</Container>

workspaces/ballerina/type-editor/src/RecordFromJson/RecordFromJson.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,29 +92,29 @@ export const RecordFromJson = (props: RecordFromJsonProps) => {
9292
typeName: name
9393
});
9494

95-
// find the record with the name
96-
const record = typesFromJson.types.find((t) => t.type.name === name);
97-
// if there are other records than the matching name, get the types
95+
const record = typesFromJson.types[typesFromJson.types.length - 1];
9896
const otherRecords = typesFromJson.types
99-
.filter((t) => t.type.name !== name)
97+
.slice(0, -1)
10098
.map((t) => t.type);
10199

102-
103100
if (otherRecords.length > 0) {
104-
const response: UpdateTypesResponse = await rpcClient.getBIDiagramRpcClient().updateTypes({
101+
await rpcClient.getBIDiagramRpcClient().updateTypes({
105102
filePath: 'types.bal',
106103
types: otherRecords
107104
});
108105

109106
if (!isPopupTypeForm) {
110-
await props.rpcClient.getVisualizerRpcClient().openView(
107+
await rpcClient.getVisualizerRpcClient().openView(
111108
{ type: EVENT_TYPE.UPDATE_PROJECT_LOCATION, location: { addType: false } }
112109
);
113110
}
114111
}
115112

116113
if (record) {
117114
onImport([record.type]);
115+
} else {
116+
setIsSaving(false);
117+
setError("Could not import JSON as type.");
118118
}
119119
} catch (err) {
120120
setError("Could not import JSON as type.");

0 commit comments

Comments
 (0)