Skip to content

Commit

Permalink
Update packages/ui/src/components/SourceCode/SourceCode.tsx
Browse files Browse the repository at this point in the history
Co-authored-by: Ricardo M. <lordrip@gmail.com>
  • Loading branch information
lhein and lordrip committed Nov 24, 2023
1 parent d57afb8 commit 89f95f2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 55 deletions.
1 change: 0 additions & 1 deletion packages/ui-tests/cypress/support/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ declare global {
editorDeleteLine(line: number, repeatCount: number): Chainable<JQuery<Element>>;
checkCodeSpanLine(spanText: string, linesCount: number | undefined): Chainable<JQuery<Element>>;
checkCodeSpanLine(spanText: string): Chainable<JQuery<Element>>;
syncUpCodeChanges(): Chainable<JQuery<Element>>;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/SourceCode/RedoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const RedoButton: FunctionComponent<IRedoIcon> = (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}
/>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/ui/src/components/SourceCode/SourceCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -59,18 +58,19 @@ export const SourceCode: FunctionComponent<SourceCodeProps> = (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 [
<UndoButton key="undo-button" isVisible onClick={() => undoAction} />,
<RedoButton key="redo-button" isVisible onClick={() => redoAction} />,
<SyncButton key="sync-button" isDirty={false} isVisible onClick={() => undefined} />,
<UndoButton key="undo-button" isVisible onClick={undoAction} />,
<RedoButton key="redo-button" isVisible onClick={redoAction} />,
];
}, []);

Expand Down
7 changes: 0 additions & 7 deletions packages/ui/src/components/SourceCode/SyncButton.scss

This file was deleted.

33 changes: 0 additions & 33 deletions packages/ui/src/components/SourceCode/SyncButton.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/ui/src/components/SourceCode/UndoButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const UndoButton: FunctionComponent<IUndoIcon> = (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}
/>
);
Expand Down

0 comments on commit 89f95f2

Please sign in to comment.