diff --git a/packages/ui/src/components/SourceCode/RedoButton.tsx b/packages/ui/src/components/SourceCode/RedoButton.tsx new file mode 100644 index 000000000..278d95f45 --- /dev/null +++ b/packages/ui/src/components/SourceCode/RedoButton.tsx @@ -0,0 +1,22 @@ +import { CodeEditorControl } from '@patternfly/react-code-editor'; +import { RedoIcon } from '@patternfly/react-icons'; +import { FunctionComponent } from 'react'; + +interface IRedoIcon { + isVisible: boolean; + onClick: () => void; +} + +export const RedoButton: FunctionComponent = (props) => { + return ( + } + aria-label="Redo change" + data-testid="sourceCode--redoButton" + onClick={props.onClick} + tooltipProps={{content: 'Redo change', position: 'top'}} + isVisible={true} + /> + ); +}; diff --git a/packages/ui/src/components/SourceCode/SourceCode.tsx b/packages/ui/src/components/SourceCode/SourceCode.tsx index 810df03d4..5f0480bde 100644 --- a/packages/ui/src/components/SourceCode/SourceCode.tsx +++ b/packages/ui/src/components/SourceCode/SourceCode.tsx @@ -7,6 +7,8 @@ import { SyncButton } from './SyncButton'; import './workers/enable-workers'; import { sourceSchemaConfig, SourceSchemaType } from '../../models/camel'; import { EntitiesContext } from '../../providers/entities.provider'; +import { UndoButton } from './UndoButton'; +import { RedoButton } from './RedoButton'; interface SourceCodeProps { code: string; @@ -56,8 +58,20 @@ export const SourceCode: FunctionComponent = (props) => { quickSuggestions: { other: true, strings: true, comments: true }, }); + const undoAction = () => { + (editorRef.current?.getModel() as any)?.undo(); + } + + const redoAction = () => { + (editorRef.current?.getModel() as any)?.redo(); + } + const customControls = useMemo(() => { - return [ undefined} />]; + return [ + undoAction} />, + redoAction} />, + undefined} />, + ]; }, []); return ( diff --git a/packages/ui/src/components/SourceCode/UndoButton.tsx b/packages/ui/src/components/SourceCode/UndoButton.tsx new file mode 100644 index 000000000..ed4860998 --- /dev/null +++ b/packages/ui/src/components/SourceCode/UndoButton.tsx @@ -0,0 +1,22 @@ +import { CodeEditorControl } from '@patternfly/react-code-editor'; +import { UndoIcon } from '@patternfly/react-icons'; +import { FunctionComponent } from 'react'; + +interface IUndoIcon { + isVisible: boolean; + onClick: () => void; +} + +export const UndoButton: FunctionComponent = (props) => { + return ( + } + aria-label="Undo change" + data-testid="sourceCode--undoButton" + onClick={props.onClick} + tooltipProps={{content: 'Undo change', position: 'top'}} + isVisible={true} + /> + ); +};