forked from getcursor/cursor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5defeb7
commit a0c53e5
Showing
8 changed files
with
307 additions
and
223 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ import { WelcomeScreen } from './components/welcomeScreen' | |
import { TitleBar } from './components/titlebar' | ||
import { BottomTerminal } from './components/terminal' | ||
import { throttleCallback } from './components/componentUtils' | ||
import { ErrorPopup } from './components/errors' | ||
|
||
const customStyles = { | ||
overlay: { | ||
|
@@ -57,116 +58,6 @@ const customStyles = { | |
}, | ||
} | ||
|
||
function ErrorPopup() { | ||
const showError = useAppSelector(gsel.getShowErrors) | ||
const dispatch = useAppDispatch() | ||
|
||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(gs.closeError()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
We ran into a problem | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(gs.closeError())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
Something unexpected happened. Please try again later. If | ||
this continues, please contact [email protected]. | ||
<br /> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
function RateLimitPopup() { | ||
const showError = useAppSelector(gsel.getShowRateLimit) | ||
const dispatch = useAppDispatch() | ||
|
||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(gs.closeRateLimit()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
You're going a bit fast... | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(gs.closeError())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
It seems like you're making a high rate of requests. Please | ||
slow down and try again in a minute or so. If you believe | ||
this is an error, contact us at [email protected] | ||
<br /> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
function NoAuthRateLimitPopup() { | ||
const showError = useAppSelector(gsel.getShowNoAuthRateLimit) | ||
const dispatch = useAppDispatch() | ||
|
||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(gs.closeNoAuthRateLimit()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
Maximum Capacity | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(gs.closeNoAuthRateLimit())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
We're getting more traffic than we can handle right now. | ||
Please try again in one minute. To avoid these limits, you | ||
can optionally upgrade to{' '} | ||
<a | ||
className="pay-link" | ||
onClick={() => dispatch(ts.upgradeCursor(null))} | ||
> | ||
pro | ||
</a> | ||
. | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
function SSHPopup() { | ||
const showRemotePopup = useAppSelector(gsel.getShowRemotePopup) | ||
const remoteCommand = useAppSelector(gsel.getRemoteCommand) | ||
|
@@ -438,8 +329,6 @@ export function App() { | |
</div> | ||
<ChatPopup /> | ||
<ErrorPopup /> | ||
<RateLimitPopup /> | ||
<NoAuthRateLimitPopup /> | ||
<SettingsPopup /> | ||
<FeedbackArea /> | ||
<SSHPopup /> | ||
|
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,129 @@ | ||
import { useAppDispatch, useAppSelector } from '../app/hooks'; | ||
import {closeError} from '../features/globalSlice' | ||
import {getShowErrors, getError} from '../features/selectors'; | ||
import { faClose } from '@fortawesome/pro-regular-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import Modal from 'react-modal' | ||
import { NoAuthRateLimitError, NotLoggedInError, OpenAIError } from '../utils'; | ||
import { CursorLogin, OpenAIPanel } from './settingsPane'; | ||
|
||
const customStyles = { | ||
overlay: { | ||
backgroundColor: 'rgba(0, 0, 0, 0.1)', | ||
display: 'flex', | ||
alignItems: 'center', | ||
zIndex: 10000, | ||
}, | ||
content: { | ||
padding: 'none', | ||
top: '150px', | ||
bottom: 'none', | ||
background: 'none', | ||
border: 'none', | ||
width: 'auto', | ||
height: 'auto', | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
maxWidth: '700px', | ||
}, | ||
} | ||
|
||
export function ErrorPopup() { | ||
const showError = useAppSelector(getShowErrors) | ||
const error = useAppSelector(getError) | ||
const dispatch = useAppDispatch() | ||
|
||
if (error == null) { | ||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(closeError()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
We ran into a problem | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(closeError())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
Something unexpected happened. Please try again later. If | ||
this continues, please contact [email protected]. | ||
<br /> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} else if (error instanceof NotLoggedInError) { | ||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(closeError()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
{error.title} | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(closeError())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
{error.message} | ||
<br /> | ||
Try logging in here: | ||
<CursorLogin showSettings={false}/> | ||
<br/> | ||
Or try using an OpenAI key: | ||
<OpenAIPanel /> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} else { | ||
return ( | ||
<Modal | ||
isOpen={showError} | ||
onRequestClose={() => { | ||
dispatch(closeError()) | ||
}} | ||
style={customStyles} | ||
> | ||
<div className="errorPopup"> | ||
<div className="errorPopup__title"> | ||
<div className="errorPopup__title_text"> | ||
{error.title} | ||
</div> | ||
<div | ||
className="errorPopup__title_close" | ||
onClick={() => dispatch(closeError())} | ||
> | ||
<FontAwesomeIcon icon={faClose} /> | ||
</div> | ||
</div> | ||
<div className="errorPopup__body"> | ||
{error.message} | ||
<br /> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.