Skip to content

Commit bd718b5

Browse files
committed
Merge remote-tracking branch 'upstream/bi-1.5.x' into newRecordView
2 parents 111aee2 + 186163a commit bd718b5

File tree

8 files changed

+1435
-1414
lines changed

8 files changed

+1435
-1414
lines changed

common/config/rush/.pnpmfile.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ module.exports = {
6060
if (pkg.dependencies['min-document']) {
6161
pkg.dependencies['min-document'] = '^2.19.1';
6262
}
63+
if (pkg.dependencies['js-yaml']) {
64+
pkg.dependencies['js-yaml'] = '^4.1.1';
65+
}
6366
}
6467

6568
if (pkg.devDependencies) {

common/config/rush/pnpm-lock.yaml

Lines changed: 1340 additions & 1359 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/ballerina/ballerina-extension/src/stateMachine.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {
1919
fetchScope,
2020
getOrgPackageName,
2121
UndoRedoManager,
22-
getProjectTomlValues,
23-
getWorkspaceTomlValues
22+
getPackageName
2423
} from './utils';
2524
import { buildProjectsStructure } from './utils/project-artifacts';
2625
import { runCommandWithOutput } from './utils/runCommand';
@@ -516,8 +515,7 @@ const stateMachine = createMachine<MachineContext>(
516515
},
517516
findView(context, event): Promise<void> {
518517
return new Promise(async (resolve, reject) => {
519-
const projectTomlValues = context.projectPath ? await getProjectTomlValues(context.projectPath) : undefined;
520-
const packageName = projectTomlValues?.package?.name;
518+
const packageName = getPackageName(context.projectInfo, context.projectPath);
521519
if (!context.view && context.langClient) {
522520
if (!context.position || ("groupId" in context.position)) {
523521
if (!context.projectPath && context.workspacePath) {

workspaces/ballerina/ballerina-extension/src/utils/config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* under the License.
1717
*/
1818

19-
import { SemanticVersion, PackageTomlValues, SCOPE, WorkspaceTomlValues } from '@wso2/ballerina-core';
19+
import { SemanticVersion, PackageTomlValues, SCOPE, WorkspaceTomlValues, ProjectInfo } from '@wso2/ballerina-core';
2020
import { BallerinaExtension } from '../core';
2121
import { WorkspaceConfiguration, workspace, Uri, RelativePattern } from 'vscode';
2222
import * as fs from 'fs';
@@ -356,3 +356,21 @@ export function setupBIFiles(projectDir: string): void {
356356
}
357357
});
358358
}
359+
360+
export function getPackageName(projectInfo: ProjectInfo, projectPath: string): string {
361+
if (!projectPath || !projectInfo) {
362+
return "";
363+
}
364+
365+
if (projectInfo.children?.length) {
366+
const matchedProject = projectInfo.children.find(
367+
(child) => child.projectPath === projectPath
368+
);
369+
370+
if (matchedProject) {
371+
return matchedProject.title || matchedProject.name;
372+
}
373+
}
374+
375+
return projectInfo.title || projectInfo.name;
376+
}

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export const ChipExpressionEditorComponent = (props: ChipExpressionEditorCompone
249249
}, []);
250250

251251
useEffect(() => {
252-
if (!props.value || !viewRef.current) return;
252+
if (props.value == null || !viewRef.current) return;
253253
const updateEditorState = async () => {
254254
const currentDoc = viewRef.current!.state.doc.toString();
255255
const isExternalUpdate = props.value !== currentDoc;
@@ -259,19 +259,24 @@ export const ChipExpressionEditorComponent = (props: ChipExpressionEditorCompone
259259
const tokenStream = await expressionEditorRpcManager?.getExpressionTokens(
260260
props.value,
261261
props.fileName,
262-
props.targetLineRange.startLine
262+
props.targetLineRange?.startLine
263263
);
264264
setIsTokenUpdateScheduled(false);
265-
if (tokenStream) {
266-
viewRef.current!.dispatch({
267-
effects: tokensChangeEffect.of(tokenStream),
268-
changes: { from: 0, to: viewRef.current!.state.doc.length, insert: props.value },
269-
...{ annotations: isExternalUpdate ? [SyncDocValueWithPropValue.of(true)] : [] }
270-
});
271-
}
265+
const effects = tokenStream ? [tokensChangeEffect.of(tokenStream)] : [];
266+
const changes = isExternalUpdate
267+
? { from: 0, to: viewRef.current!.state.doc.length, insert: props.value }
268+
: undefined;
269+
const annotations = isExternalUpdate ? [SyncDocValueWithPropValue.of(true)] : [];
270+
271+
viewRef.current!.dispatch({
272+
...(effects.length > 0 && { effects }),
273+
...(changes && { changes }),
274+
...(annotations.length > 0 && { annotations }),
275+
});
276+
272277
};
273278
updateEditorState();
274-
}, [props.value, props.fileName, props.targetLineRange.startLine, isTokenUpdateScheduled]);
279+
}, [props.value, props.fileName, props.targetLineRange?.startLine, isTokenUpdateScheduled]);
275280

276281

277282
// this keeps completions ref updated

workspaces/ballerina/ballerina-visualizer/src/views/BI/Forms/FormGeneratorNew/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ export function FormGeneratorNew(props: FormProps) {
897897
retrieveCompletions: handleRetrieveCompletions,
898898
extractArgsFromFunction: extractArgsFromFunction,
899899
types: filteredTypes,
900+
fileName: fileName,
900901
referenceTypes: types,
901902
rpcManager: {
902903
getExpressionTokens: getExpressionTokens

workspaces/ballerina/ballerina-visualizer/src/views/BI/WorkspaceOverview/PackageListView.tsx

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
* under the License.
1717
*/
1818

19+
import React, { useMemo } from 'react';
1920
import styled from '@emotion/styled';
20-
import React from 'react';
21-
import { Codicon, Typography } from '@wso2/ui-toolkit';
21+
import { Codicon, Icon, Typography } from '@wso2/ui-toolkit';
2222
import { EVENT_TYPE, MACHINE_VIEW, ProjectStructureResponse, SCOPE } from '@wso2/ballerina-core';
2323
import { useRpcContext } from '@wso2/ballerina-rpc-client';
2424
import { getIntegrationTypes } from '../PackageOverview/utils';
@@ -154,12 +154,6 @@ export interface PackageListViewProps {
154154
workspaceStructure: ProjectStructureResponse;
155155
}
156156

157-
interface Package {
158-
id: string;
159-
name: string;
160-
types?: SCOPE[];
161-
}
162-
163157
const getTypeColor = (type: SCOPE): string => {
164158
const colors: Record<SCOPE, string> = {
165159
[SCOPE.AUTOMATION]: 'var(--vscode-charts-blue)',
@@ -172,14 +166,14 @@ const getTypeColor = (type: SCOPE): string => {
172166
return colors[type];
173167
};
174168

175-
const getTypeIcon = (type: SCOPE): string => {
176-
const icons: Record<SCOPE, string> = {
177-
[SCOPE.AUTOMATION]: 'robot',
178-
[SCOPE.INTEGRATION_AS_API]: 'cloud',
179-
[SCOPE.EVENT_INTEGRATION]: 'pulse',
180-
[SCOPE.FILE_INTEGRATION]: 'file',
181-
[SCOPE.AI_AGENT]: 'sparkle',
182-
[SCOPE.ANY]: 'package'
169+
const getTypeIcon = (type: SCOPE): { name: string; source: 'icon' | 'codicon' } => {
170+
const icons: Record<SCOPE, { name: string; source: 'icon' | 'codicon' }> = {
171+
[SCOPE.AUTOMATION]: { name: 'task', source: 'icon' },
172+
[SCOPE.INTEGRATION_AS_API]: { name: 'cloud', source: 'codicon' },
173+
[SCOPE.EVENT_INTEGRATION]: { name: 'Event', source: 'icon' },
174+
[SCOPE.FILE_INTEGRATION]: { name: 'file', source: 'icon' },
175+
[SCOPE.AI_AGENT]: { name: 'bi-ai-agent', source: 'icon' },
176+
[SCOPE.ANY]: { name: 'project', source: 'codicon' }
183177
};
184178
return icons[type];
185179
};
@@ -196,17 +190,42 @@ const getTypeLabel = (type: SCOPE): string => {
196190
return labels[type];
197191
};
198192

193+
const renderIcon = (iconConfig: { name: string; source: 'icon' | 'codicon' }) => {
194+
const iconProps = {
195+
iconSx: { fontSize: 25, opacity: 0.85 },
196+
sx: { height: 25, width: 25 }
197+
};
198+
199+
return iconConfig.source === 'icon' ? (
200+
<Icon name={iconConfig.name} {...iconProps} />
201+
) : (
202+
<Codicon name={iconConfig.name} {...iconProps} />
203+
);
204+
};
205+
206+
const renderPackageIcon = (types: SCOPE[]) => {
207+
if (types.length > 0) {
208+
const iconConfig = getTypeIcon(types[0]);
209+
return renderIcon(iconConfig);
210+
}
211+
212+
return renderIcon({ name: 'project', source: 'codicon' });
213+
};
214+
199215
export function PackageListView(props: PackageListViewProps) {
200216
const { rpcClient } = useRpcContext();
201217
const workspaceStructure = props.workspaceStructure;
202-
const packages = workspaceStructure.projects.map((project) => {
203-
return {
204-
id: project.projectName,
205-
name: project.projectTitle,
206-
projectPath: project.projectPath,
207-
types: getIntegrationTypes(workspaceStructure, project.projectPath)
208-
}
209-
});
218+
219+
const packages = useMemo(() => {
220+
return workspaceStructure.projects.map((project) => {
221+
return {
222+
id: project.projectName,
223+
name: project.projectTitle,
224+
projectPath: project.projectPath,
225+
types: getIntegrationTypes(workspaceStructure, project.projectPath)
226+
}
227+
});
228+
}, [workspaceStructure]);
210229

211230
const handlePackageClick = async (packageId: string, event: React.MouseEvent) => {
212231
// Don't trigger if clicking on delete button
@@ -237,11 +256,7 @@ export function PackageListView(props: PackageListViewProps) {
237256
<PackageHeader>
238257
<PackageTitleRow title={pkg.name}>
239258
<PackageIcon>
240-
<Codicon
241-
name={pkg.types.length > 0 ? getTypeIcon(pkg.types[0]) : 'package'}
242-
iconSx={{ fontSize: 28, opacity: 0.85 }}
243-
sx={{ height: 28, width: 28 }}
244-
/>
259+
{renderPackageIcon(pkg.types)}
245260
</PackageIcon>
246261
<PackageName>{pkg.name}</PackageName>
247262
</PackageTitleRow>

workspaces/bi/bi-extension/src/project-explorer/project-explorer-provider.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function generateTreeData(
192192
'project',
193193
true
194194
);
195-
projectRootEntry.resourceUri = Uri.file(packagePath);
195+
projectRootEntry.resourceUri = Uri.parse(`bi-category:${packagePath}`);
196196
projectRootEntry.contextValue = 'bi-project';
197197
const children = getEntriesBI(components);
198198
projectRootEntry.children = children;
@@ -212,7 +212,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
212212
'start',
213213
false
214214
);
215-
entryPoints.resourceUri = Uri.file(projectPath);
215+
entryPoints.resourceUri = Uri.parse(`bi-category:${projectPath}`);
216216
entryPoints.contextValue = "entryPoint";
217217
entryPoints.children = [];
218218
if (project.directoryMap[DIRECTORY_MAP.AUTOMATION].length > 0) {
@@ -232,7 +232,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
232232
'radio',
233233
false
234234
);
235-
listeners.resourceUri = Uri.file(projectPath);
235+
listeners.resourceUri = Uri.parse(`bi-category:${projectPath}`);
236236
listeners.contextValue = "listeners";
237237
listeners.children = getComponents(project.directoryMap[DIRECTORY_MAP.LISTENER], DIRECTORY_MAP.LISTENER, projectPath);
238238
if (listeners.children.length > 0) {
@@ -248,7 +248,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
248248
'connection',
249249
false
250250
);
251-
connections.resourceUri = Uri.file(projectPath);
251+
connections.resourceUri = Uri.parse(`bi-category:${projectPath}`);
252252
connections.contextValue = "connections";
253253
connections.children = getComponents(project.directoryMap[DIRECTORY_MAP.CONNECTION], DIRECTORY_MAP.CONNECTION, projectPath);
254254
if (connections.children.length > 0) {
@@ -264,7 +264,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
264264
'type',
265265
false
266266
);
267-
types.resourceUri = Uri.file(projectPath);
267+
types.resourceUri = Uri.parse(`bi-category:${projectPath}`);
268268
types.contextValue = "types";
269269
types.children = getComponents([
270270
...project.directoryMap[DIRECTORY_MAP.TYPE]
@@ -282,7 +282,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
282282
'function',
283283
false
284284
);
285-
functions.resourceUri = Uri.file(projectPath);
285+
functions.resourceUri = Uri.parse(`bi-category:${projectPath}`);
286286
functions.contextValue = "functions";
287287
functions.children = getComponents(project.directoryMap[DIRECTORY_MAP.FUNCTION], DIRECTORY_MAP.FUNCTION, projectPath);
288288
if (functions.children.length > 0) {
@@ -298,7 +298,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
298298
'dataMapper',
299299
false
300300
);
301-
dataMappers.resourceUri = Uri.file(projectPath);
301+
dataMappers.resourceUri = Uri.parse(`bi-category:${projectPath}`);
302302
dataMappers.contextValue = "dataMappers";
303303
dataMappers.children = getComponents(project.directoryMap[DIRECTORY_MAP.DATA_MAPPER], DIRECTORY_MAP.DATA_MAPPER, projectPath);
304304
if (dataMappers.children.length > 0) {
@@ -314,7 +314,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
314314
'config',
315315
false
316316
);
317-
configs.resourceUri = Uri.file(projectPath);
317+
configs.resourceUri = Uri.parse(`bi-category:${projectPath}`);
318318
configs.contextValue = "configurations";
319319
entries.push(configs);
320320

@@ -327,7 +327,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
327327
'function',
328328
false
329329
);
330-
naturalFunctions.resourceUri = Uri.file(projectPath);
330+
naturalFunctions.resourceUri = Uri.parse(`bi-category:${projectPath}`);
331331
naturalFunctions.contextValue = "naturalFunctions";
332332
naturalFunctions.children = getComponents(project.directoryMap[DIRECTORY_MAP.NP_FUNCTION], DIRECTORY_MAP.NP_FUNCTION, projectPath);
333333
if (naturalFunctions.children.length > 0) {
@@ -344,7 +344,7 @@ function getEntriesBI(project: ProjectStructure): ProjectExplorerEntry[] {
344344
'connection',
345345
false
346346
);
347-
localConnectors.resourceUri = Uri.file(projectPath);
347+
localConnectors.resourceUri = Uri.parse(`bi-category:${projectPath}`);
348348
localConnectors.contextValue = "localConnectors";
349349
localConnectors.children = getComponents(project.directoryMap[DIRECTORY_MAP.LOCAL_CONNECTORS], DIRECTORY_MAP.CONNECTOR, projectPath);
350350
if (localConnectors.children.length > 0) {
@@ -372,7 +372,7 @@ function getComponents(items: ProjectStructureArtifactResponse[], itemType: DIRE
372372
comp.path,
373373
comp.icon
374374
);
375-
fileEntry.resourceUri = Uri.file(projectPath);
375+
fileEntry.resourceUri = Uri.parse(`bi-category:${projectPath}`);
376376
fileEntry.command = {
377377
"title": "Visualize",
378378
"command": SHARED_COMMANDS.SHOW_VISUALIZER,

0 commit comments

Comments
 (0)