@@ -23,6 +23,10 @@ import {
2323 getLayoutItemsOrder
2424} from "./utils" ;
2525import { actionRegistry , getAllActionItems } from "./actionConfigs" ;
26+ import { getThemeList } from "@lowcoder-ee/redux/selectors/commonSettingSelectors" ;
27+ import { useSelector } from "react-redux" ;
28+ import { ActionOptions } from "comps/controls/actionSelector/actionSelectorControl" ;
29+ import { eventToShortcut , readableShortcut } from "util/keyUtils" ;
2630
2731export function ActionInputSection ( ) {
2832 const [ actionValue , setActionValue ] = useState < string > ( "" ) ;
@@ -38,8 +42,20 @@ export function ActionInputSection() {
3842 const [ validationError , setValidationError ] = useState < string | null > ( null ) ;
3943 const [ showDynamicLayoutDropdown , setShowDynamicLayoutDropdown ] = useState < boolean > ( false ) ;
4044 const [ selectedDynamicLayoutIndex , setSelectedDynamicLayoutIndex ] = useState < string | null > ( null ) ;
45+ const [ showThemeDropdown , setShowThemeDropdown ] = useState < boolean > ( false ) ;
46+ const [ selectedTheme , setSelectedTheme ] = useState < string | null > ( null ) ;
47+ const [ showCustomShortcutsActionDropdown , setShowCustomShortcutsActionDropdown ] = useState < boolean > ( false ) ;
48+ const [ selectedCustomShortcutAction , setSelectedCustomShortcutAction ] = useState < string | null > ( null ) ;
4149 const inputRef = useRef < InputRef > ( null ) ;
4250 const editorState = useContext ( EditorContext ) ;
51+ const themeList = useSelector ( getThemeList ) || [ ] ;
52+
53+ const THEME_OPTIONS = useMemo ( ( ) => {
54+ return themeList . map ( ( theme ) => ( {
55+ label : theme . name ,
56+ value : theme . id + "" ,
57+ } ) ) ;
58+ } , [ themeList ] ) ;
4359
4460 const categories = useMemo ( ( ) => {
4561 return getComponentCategories ( ) ;
@@ -110,7 +126,11 @@ export function ActionInputSection() {
110126 setShowDynamicLayoutDropdown ( false ) ;
111127 setActionValue ( "" ) ;
112128 setSelectedDynamicLayoutIndex ( null ) ;
113-
129+ setShowThemeDropdown ( false ) ;
130+ setSelectedTheme ( null ) ;
131+ setShowCustomShortcutsActionDropdown ( false ) ;
132+ setSelectedCustomShortcutAction ( null ) ;
133+
114134 if ( action . requiresComponentSelection ) {
115135 setShowComponentDropdown ( true ) ;
116136 setPlaceholderText ( "Select a component to add" ) ;
@@ -134,6 +154,12 @@ export function ActionInputSection() {
134154 if ( action . dynamicLayout ) {
135155 setShowDynamicLayoutDropdown ( true ) ;
136156 }
157+ if ( action . isTheme ) {
158+ setShowThemeDropdown ( true ) ;
159+ }
160+ if ( action . isCustomShortcuts ) {
161+ setShowCustomShortcutsActionDropdown ( true ) ;
162+ }
137163 } , [ ] ) ;
138164
139165 const handleComponentSelection = useCallback ( ( key : string ) => {
@@ -199,6 +225,16 @@ export function ActionInputSection() {
199225 return ;
200226 }
201227
228+ if ( currentAction . isTheme && ! selectedTheme ) {
229+ message . error ( 'Please select a theme' ) ;
230+ return ;
231+ }
232+
233+ if ( currentAction . isCustomShortcuts && ! selectedCustomShortcutAction ) {
234+ message . error ( 'Please select a custom shortcut action' ) ;
235+ return ;
236+ }
237+
202238 try {
203239 await currentAction . execute ( {
204240 actionKey : selectedActionKey ,
@@ -207,6 +243,8 @@ export function ActionInputSection() {
207243 selectedEditorComponent,
208244 selectedNestComponent,
209245 selectedDynamicLayoutIndex,
246+ selectedTheme,
247+ selectedCustomShortcutAction,
210248 editorState
211249 } ) ;
212250
@@ -223,7 +261,10 @@ export function ActionInputSection() {
223261 setSelectedNestComponent ( null ) ;
224262 setShowDynamicLayoutDropdown ( false ) ;
225263 setSelectedDynamicLayoutIndex ( null ) ;
226-
264+ setShowThemeDropdown ( false ) ;
265+ setSelectedTheme ( null ) ;
266+ setShowCustomShortcutsActionDropdown ( false ) ;
267+ setSelectedCustomShortcutAction ( null ) ;
227268 } catch ( error ) {
228269 console . error ( 'Error executing action:' , error ) ;
229270 message . error ( 'Failed to execute action. Please try again.' ) ;
@@ -235,6 +276,8 @@ export function ActionInputSection() {
235276 selectedEditorComponent ,
236277 selectedNestComponent ,
237278 selectedDynamicLayoutIndex ,
279+ selectedTheme ,
280+ selectedCustomShortcutAction ,
238281 editorState ,
239282 currentAction ,
240283 validateInput
@@ -246,9 +289,21 @@ export function ActionInputSection() {
246289 if ( currentAction . requiresComponentSelection && ! selectedComponent ) return true ;
247290 if ( currentAction . requiresEditorComponentSelection && ! selectedEditorComponent ) return true ;
248291 if ( currentAction . requiresInput && ! actionValue . trim ( ) ) return true ;
292+ if ( currentAction . requiresStyle && ! selectedEditorComponent ) return true ;
293+ if ( currentAction . isTheme && ! selectedTheme ) return true ;
294+ if ( currentAction . isCustomShortcuts && ! selectedCustomShortcutAction ) return true ;
249295
250296 return false ;
251- } , [ selectedActionKey , currentAction , selectedComponent , selectedEditorComponent , actionValue ] ) ;
297+ } , [
298+ selectedActionKey ,
299+ currentAction ,
300+ selectedComponent ,
301+ selectedEditorComponent ,
302+ actionValue ,
303+ selectedCustomShortcutAction ,
304+ selectedTheme ,
305+ selectedNestComponent
306+ ] ) ;
252307
253308 const shouldShowInput = useMemo ( ( ) => {
254309 if ( ! currentAction ) return false ;
@@ -390,24 +445,70 @@ export function ActionInputSection() {
390445 </ Dropdown >
391446 ) }
392447
448+ { showThemeDropdown && (
449+ < Dropdown
450+ options = { THEME_OPTIONS }
451+ onChange = { ( value ) => {
452+ setSelectedTheme ( value ) ;
453+ } }
454+ >
455+ < Button size = { "small" } >
456+ < Space >
457+ { selectedTheme ? selectedTheme : 'Select Theme' }
458+ </ Space >
459+ </ Button >
460+ </ Dropdown >
461+ ) }
462+
463+ { showCustomShortcutsActionDropdown && (
464+ < Dropdown
465+ options = { ActionOptions }
466+ onChange = { ( value ) => {
467+ setSelectedCustomShortcutAction ( value ) ;
468+ } }
469+ >
470+ < Button size = { "small" } >
471+ < Space >
472+ { selectedCustomShortcutAction ? selectedCustomShortcutAction : 'Select Action' }
473+ </ Space >
474+ </ Button >
475+ </ Dropdown >
476+ ) }
477+
393478 { shouldShowInput && (
394- showStylingInput ? (
395- < Input . TextArea
396- ref = { inputRef }
397- value = { actionValue }
398- onChange = { handleInputChange }
399- placeholder = { placeholderText }
400- status = { validationError ? 'error' : undefined }
401- autoSize = { { minRows : 1 } }
402- />
403- ) : (
479+ currentAction ?. isCustomShortcuts ? (
404480 < Input
405481 ref = { inputRef }
406- value = { actionValue }
407- onChange = { handleInputChange }
482+ value = { readableShortcut ( actionValue ) }
408483 placeholder = { placeholderText }
409484 status = { validationError ? 'error' : undefined }
485+ onKeyDownCapture = { ( e ) => {
486+ setActionValue ( eventToShortcut ( e ) ) ;
487+ e . preventDefault ( ) ;
488+ e . stopPropagation ( ) ;
489+ } }
490+ onChange = { ( ) => { } }
491+ readOnly
410492 />
493+ ) : (
494+ showStylingInput ? (
495+ < Input . TextArea
496+ ref = { inputRef }
497+ value = { actionValue }
498+ onChange = { handleInputChange }
499+ placeholder = { placeholderText }
500+ status = { validationError ? 'error' : undefined }
501+ autoSize = { { minRows : 1 } }
502+ />
503+ ) : (
504+ < Input
505+ ref = { inputRef }
506+ value = { actionValue }
507+ onChange = { handleInputChange }
508+ placeholder = { placeholderText }
509+ status = { validationError ? 'error' : undefined }
510+ />
511+ )
411512 )
412513 ) }
413514
0 commit comments