diff --git a/packages/ui-tests/cypress/support/cypress.d.ts b/packages/ui-tests/cypress/support/cypress.d.ts index 21ac3de17..fd04aa6fb 100644 --- a/packages/ui-tests/cypress/support/cypress.d.ts +++ b/packages/ui-tests/cypress/support/cypress.d.ts @@ -40,7 +40,6 @@ declare global { editorDeleteLine(line: number, repeatCount: number): Chainable>; checkCodeSpanLine(spanText: string, linesCount: number | undefined): Chainable>; checkCodeSpanLine(spanText: string): Chainable>; - syncUpCodeChanges(): Chainable>; } } } diff --git a/packages/ui-tests/cypress/support/next-commands/sourceCode.ts b/packages/ui-tests/cypress/support/next-commands/sourceCode.ts index 874666752..01eb0bd12 100644 --- a/packages/ui-tests/cypress/support/next-commands/sourceCode.ts +++ b/packages/ui-tests/cypress/support/next-commands/sourceCode.ts @@ -13,11 +13,6 @@ Cypress.Commands.add('editorAddText', (line, text) => { Cypress.Commands.add('uploadFixture', (fixture) => { cy.openSourceCode(); cy.get('.pf-v5-c-code-editor__main > input').attachFile(fixture); - cy.syncUpCodeChanges(); -}); - -Cypress.Commands.add('syncUpCodeChanges', () => { - cy.get('[data-testid="sourceCode--applyButton"]').click(); }); Cypress.Commands.add('editorDeleteLine', (line, repeatCount) => { @@ -37,7 +32,7 @@ Cypress.Commands.add('editorDeleteLine', (line, repeatCount) => { ); }); -Cypress.Commands.add('checkCodeSpanLine', (spanText, linesCount) => { +Cypress.Commands.add('checkCodeSpanLine', ( spanText, linesCount ) => { linesCount = linesCount ?? 1; cy.get('.pf-v5-c-code-editor').within(() => { cy.get('span:only-child').contains(spanText).should('have.length', linesCount); diff --git a/packages/ui/src/components/SourceCode/RedoButton.tsx b/packages/ui/src/components/SourceCode/RedoButton.tsx index 278d95f45..8573d6c35 100644 --- a/packages/ui/src/components/SourceCode/RedoButton.tsx +++ b/packages/ui/src/components/SourceCode/RedoButton.tsx @@ -15,7 +15,7 @@ export const RedoButton: FunctionComponent = (props) => { aria-label="Redo change" data-testid="sourceCode--redoButton" onClick={props.onClick} - tooltipProps={{content: 'Redo change', position: 'top'}} + 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 5f0480bde..51163a88e 100644 --- a/packages/ui/src/components/SourceCode/SourceCode.tsx +++ b/packages/ui/src/components/SourceCode/SourceCode.tsx @@ -3,7 +3,6 @@ import { setDiagnosticsOptions } from 'monaco-yaml'; import { FunctionComponent, Ref, useCallback, useContext, useEffect, useMemo, useRef } from 'react'; import { EditorDidMount } from 'react-monaco-editor'; import './SourceCode.scss'; -import { SyncButton } from './SyncButton'; import './workers/enable-workers'; import { sourceSchemaConfig, SourceSchemaType } from '../../models/camel'; import { EntitiesContext } from '../../providers/entities.provider'; @@ -59,18 +58,19 @@ export const SourceCode: FunctionComponent = (props) => { }); const undoAction = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (editorRef.current?.getModel() as any)?.undo(); - } + }; const redoAction = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any (editorRef.current?.getModel() as any)?.redo(); - } + }; const customControls = useMemo(() => { return [ - undoAction} />, - redoAction} />, - undefined} />, + , + , ]; }, []); diff --git a/packages/ui/src/components/SourceCode/SyncButton.scss b/packages/ui/src/components/SourceCode/SyncButton.scss deleted file mode 100644 index 400c9cc17..000000000 --- a/packages/ui/src/components/SourceCode/SyncButton.scss +++ /dev/null @@ -1,7 +0,0 @@ -.icon-warning { - color: var(--pf-global--warning-color--100); -} - -.icon-success { - color: var(--pf-global--success-color--100); -} diff --git a/packages/ui/src/components/SourceCode/SyncButton.tsx b/packages/ui/src/components/SourceCode/SyncButton.tsx deleted file mode 100644 index e6a6a2703..000000000 --- a/packages/ui/src/components/SourceCode/SyncButton.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { CodeEditorControl } from '@patternfly/react-code-editor'; -import { CheckCircleIcon, SyncAltIcon } from '@patternfly/react-icons'; -import { FunctionComponent, useEffect, useState } from 'react'; -import './SyncButton.scss'; - -interface ISyncIcon { - isDirty: boolean; - isVisible: boolean; - onClick: () => void; -} - -export const SyncButton: FunctionComponent = (props) => { - const [tooltipProps, setTooltipProps] = useState({ content: 'Sync your code', position: 'top' }); - - useEffect(() => { - setTooltipProps({ - content: props.isDirty ? 'Sync your code' : 'Code is synced', - position: 'top', - }); - }, [props.isDirty]); - - return ( - : } - aria-label="Apply the code" - data-testid="sourceCode--applyButton" - onClick={props.onClick} - tooltipProps={tooltipProps} - isVisible={props.isVisible} - /> - ); -}; diff --git a/packages/ui/src/components/SourceCode/UndoButton.tsx b/packages/ui/src/components/SourceCode/UndoButton.tsx index ed4860998..b228e188f 100644 --- a/packages/ui/src/components/SourceCode/UndoButton.tsx +++ b/packages/ui/src/components/SourceCode/UndoButton.tsx @@ -15,7 +15,7 @@ export const UndoButton: FunctionComponent = (props) => { aria-label="Undo change" data-testid="sourceCode--undoButton" onClick={props.onClick} - tooltipProps={{content: 'Undo change', position: 'top'}} + tooltipProps={{ content: 'Undo change', position: 'top' }} isVisible={true} /> );