This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(code-editor): Update icon when editor is dirty
Currently, when the source code is changed through the source code editor, the sync button is always green, being the only feedback that it was changed the top banner. This commit updates the icon from the green check to an orange sync icon whenever the code editor is dirty. It also changes the tooltip text from "Sync your code" to "Code is synced" fixes: #2185
- Loading branch information
Showing
6 changed files
with
62 additions
and
44 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.icon-warning { | ||
color: var(--pf-global--warning-color--100); | ||
} | ||
|
||
.icon-success { | ||
color: var(--pf-global--success-color--100); | ||
} |
39 changes: 39 additions & 0 deletions
39
packages/kaoto-ui/src/components/SourceCode/SyncButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import './SyncButton.css'; | ||
import { CodeEditorControl } from '@patternfly/react-code-editor'; | ||
import { CheckCircleIcon, SyncAltIcon } from '@patternfly/react-icons'; | ||
import { FunctionComponent, useEffect, useState } from 'react'; | ||
|
||
interface ISyncIcon { | ||
isDirty: boolean; | ||
isVisible: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
export const SyncButton: FunctionComponent<ISyncIcon> = (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 ( | ||
<CodeEditorControl | ||
key="updateButton" | ||
icon={ | ||
props.isDirty ? ( | ||
<SyncAltIcon className="icon-warning" /> | ||
) : ( | ||
<CheckCircleIcon className="icon-success" /> | ||
) | ||
} | ||
aria-label="Apply the code" | ||
data-testid="sourceCode--applyButton" | ||
onClick={props.onClick} | ||
tooltipProps={tooltipProps} | ||
isVisible={props.isVisible} | ||
/> | ||
); | ||
}; |
32 changes: 0 additions & 32 deletions
32
packages/kaoto-ui/src/components/SourceCodeEditorModal.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters