| 1 | import { useContext } from "react"; |
| 2 | import { IdeMessengerContext } from "../../../../context/IdeMessenger"; |
| 3 | import { getAltKeyLabel, getMetaKeyLabel } from "../../../../util"; |
| 4 | import { Container, StopButton } from "./components"; |
| 5 | import { GeneratingIndicator } from "./GeneratingIndicator"; |
| 6 | |
| 7 | export const IsApplyingToolbar = () => { |
| 8 | const ideMessenger = useContext(IdeMessengerContext); |
| 9 | |
| 10 | const jetbrains = window.location.protocol === "jb-api:"; |
| 11 | |
| 12 | return ( |
| 13 | <Container> |
| 14 | <GeneratingIndicator text="Applying" /> |
| 15 | <StopButton |
| 16 | className="text-description" |
| 17 | onClick={() => { |
| 18 | // Note that this will NOT stop generation but once apply is cancelled will show the Generating/cancel option |
| 19 | // Apply is prioritized because it can be more catastrophic |
| 20 | // Intentional to be more WYSIWYG for now |
| 21 | ideMessenger.post("cancelApply", undefined); |
| 22 | }} |
| 23 | > |
| 24 | {/* JetBrains overrides cmd+backspace, so we have to use another shortcut */} |
| 25 | {jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel |
| 26 | </StopButton> |
| 27 | </Container> |
| 28 | ); |
| 29 | }; |