-
Notifications
You must be signed in to change notification settings - Fork 67
Improve file integration funcitonality #887
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
base: main
Are you sure you want to change the base?
Changes from all commits
eea58cc
8340974
33e1efa
1b7a111
558d975
a3e6a5b
93c3d03
732a306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| * under the License. | ||
| */ | ||
| import React, { useEffect, useState } from 'react'; | ||
| import { Codicon } from '@wso2/ui-toolkit'; | ||
| import { Icon } from '@wso2/ui-toolkit'; | ||
| import { useRpcContext } from '@wso2/ballerina-rpc-client'; | ||
| import { EVENT_TYPE, MACHINE_VIEW, SCOPE, ServiceModel, TriggerModelsResponse } from '@wso2/ballerina-core'; | ||
|
|
||
|
|
@@ -67,17 +67,7 @@ export function FileIntegrationPanel(props: FileIntegrationPanelProps) { | |
| id={`trigger-${item.moduleName}`} | ||
| key={item.id} | ||
| title={item.name} | ||
| icon={ | ||
| item.icon ? ( | ||
| <img | ||
| src={item.icon} | ||
| alt={item.name} | ||
| style={{ width: "40px" }} | ||
| /> | ||
| ) : ( | ||
| <Codicon name="mail" /> | ||
| ) | ||
| } | ||
| icon={getFileIntegrationIcon(item)} | ||
| onClick={() => { | ||
| handleOnSelect(item); | ||
| }} | ||
|
|
@@ -90,3 +80,21 @@ export function FileIntegrationPanel(props: FileIntegrationPanelProps) { | |
| </PanelViewMore> | ||
| ); | ||
| }; | ||
|
|
||
| // TODO: This should be removed once the new icons are added to the BE API. | ||
| export function getFileIntegrationIcon(item: ServiceModel) { | ||
| return getCustomFileIntegrationIcon(item.moduleName) || <img src={item.icon} alt={item.name} style={{ width: "38px" }} />; | ||
| } | ||
|
|
||
| // INFO: This is a temporary function to get the custom icon for the file integration triggers. | ||
| // TODO: This should be removed once the new icons are added to the BE API. | ||
| export function getCustomFileIntegrationIcon(type: string) { | ||
| switch (type) { | ||
| case "ftp": | ||
| return <Icon name="bi-ftp" />; | ||
| case "file": | ||
| return <Icon name="bi-file" />; | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
|
Comment on lines
+84
to
+100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -type f -name "FileIntegrationPanel.tsx" -o -name "FileIntegrationPanel.ts"Repository: wso2/vscode-extensions Length of output: 236 🏁 Script executed: fd "FileIntegrationPanel.tsx"Repository: wso2/vscode-extensions Length of output: 163 🏁 Script executed: cat -n workspaces/ballerina/ballerina-visualizer/src/views/BI/ComponentListView/FileIntegrationPanel.tsx | sed -n '80,105p'Repository: wso2/vscode-extensions Length of output: 946 🏁 Script executed: # Check where Icon component comes from and how it's imported
head -50 workspaces/ballerina/ballerina-visualizer/src/views/BI/ComponentListView/FileIntegrationPanel.tsxRepository: wso2/vscode-extensions Length of output: 2122 🏁 Script executed: # Search for usages of getFileIntegrationIcon throughout the codebase
rg "getFileIntegrationIcon" -B 2 -A 2Repository: wso2/vscode-extensions Length of output: 1586 🏁 Script executed: # Check ButtonCard component to see what it expects for the icon prop
rg "interface ButtonCardProps|type ButtonCardProps" -A 10Repository: wso2/vscode-extensions Length of output: 1204 🏁 Script executed: # Check how ButtonCard renders the icon
cat -n workspaces/ballerina/ballerina-visualizer/src/components/ButtonCard/index.tsx | head -100Repository: wso2/vscode-extensions Length of output: 3855 🏁 Script executed: cat -n workspaces/ballerina/ballerina-visualizer/src/components/ButtonCard/index.tsx | sed -n '100,150p'Repository: wso2/vscode-extensions Length of output: 1720 🏁 Script executed: # Search for Icon component definition in @wso2/ui-toolkit
rg "Icon" node_modules/@wso2/ui-toolkit -l | head -5Repository: wso2/vscode-extensions Length of output: 135 🏁 Script executed: # Check package.json to see ui-toolkit dependency
find . -name "package.json" -type f | xargs grep -l "@wso2/ui-toolkit" | head -3Repository: wso2/vscode-extensions Length of output: 242 🏁 Script executed: # Check the ui-toolkit version
cat workspaces/ballerina/ballerina-visualizer/package.json | grep -A 2 -B 2 "@wso2/ui-toolkit"Repository: wso2/vscode-extensions Length of output: 274 🏁 Script executed: # Find the ui-toolkit workspace package
find . -path "*/node_modules" -prune -o -name "ui-toolkit" -type d -printRepository: wso2/vscode-extensions Length of output: 101 🏁 Script executed: # Check Icon component in ui-toolkit
find workspaces/common-libs/ui-toolkit -name "*.tsx" -o -name "*.ts" | xargs rg "export.*Icon" | head -20Repository: wso2/vscode-extensions Length of output: 2741 🏁 Script executed: # Check the Icon component implementation
cat workspaces/common-libs/ui-toolkit/src/components/Icon/Icon.tsxRepository: wso2/vscode-extensions Length of output: 1683 🏁 Script executed: # Check the font-wso2-vscode package
find . -path "*/node_modules" -prune -o -name "*font*wso2*" -type d -print | grep -v node_modulesRepository: wso2/vscode-extensions Length of output: 107 🏁 Script executed: # Check what icons are available in the font
ls -la workspaces/common-libs/font-wso2-vscode/dist/Repository: wso2/vscode-extensions Length of output: 158 Clarify parameter naming and verify icon availability. The helper functions have issues that need attention:
Rename the parameter for clarity: -export function getCustomFileIntegrationIcon(type: string) {
- switch (type) {
+export function getCustomFileIntegrationIcon(moduleName: string) {
+ switch (moduleName) { |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. | ||
| * | ||
| * WSO2 LLC. licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import React from "react"; | ||
| import { SidePanelBody } from "@wso2/ui-toolkit"; | ||
| import ButtonCard from "../../../../../components/ButtonCard"; | ||
| import { ServiceModel } from "@wso2/ballerina-core"; | ||
|
|
||
| import { EditorContentColumn } from "../../styles"; | ||
|
|
||
| interface FunctionConfigFormProps { | ||
| onBack?: () => void; | ||
| isSaving: boolean; | ||
| onSubmit?: (selectedHandler: string) => void; | ||
| serviceModel: ServiceModel; | ||
| } | ||
|
|
||
| export function FunctionConfigForm(props: FunctionConfigFormProps) { | ||
|
|
||
| const { onBack, onSubmit, isSaving, serviceModel } = props; | ||
|
|
||
| const events = [ | ||
| { name: 'onCreate', description: 'Triggered when a new file is created' }, | ||
| { name: 'onDelete', description: 'Triggered when a file is deleted' } | ||
| ]; | ||
|
|
||
| // Check if all functions with a specific metadata.label are enabled | ||
| const hasAvailableFunctions = (handlerType: string) => { | ||
| const functionsWithHandler = serviceModel.functions?.filter(fn => fn.metadata?.label === handlerType) || []; | ||
| if (functionsWithHandler.length === 0) return false; | ||
|
|
||
| // Return true if there's at least one non-enabled function | ||
| return functionsWithHandler.some(fn => !fn.enabled); | ||
| }; | ||
|
|
||
| const handleEventClick = (handlerName: string) => { | ||
| // if (onBack) { | ||
| // onBack(); | ||
| // } | ||
|
|
||
| onSubmit && onSubmit(handlerName); | ||
| }; | ||
|
|
||
| // Filter events to only show those with available functions | ||
| const availableEvents = events.filter(event => hasAvailableFunctions(event.name)); | ||
|
|
||
| return ( | ||
| <SidePanelBody> | ||
| <EditorContentColumn> | ||
| {availableEvents.map((event, index) => { | ||
| const handleClick = () => handleEventClick(event.name); | ||
| return ( | ||
| <ButtonCard | ||
| key={event.name} | ||
| id={`event-card-${index}`} | ||
| title={event.name} | ||
| tooltip={event.description} | ||
| onClick={handleClick} | ||
| disabled={isSaving} | ||
| /> | ||
| ); | ||
| })} | ||
| </EditorContentColumn> | ||
| </SidePanelBody> | ||
| ); | ||
| } | ||
|
|
||
| export default FunctionConfigForm; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug console logs.
These debug logs should also be removed before merging to production.
Apply this diff to remove the debug logs:
📝 Committable suggestion
🤖 Prompt for AI Agents