-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to restart containers (#1808)
* Add "Restart Container" button. * UI Improvements for SSE - Introduce separate state for container - Disable button if the container is not started - Disable Terminal button if you don't own the sandbox * Updates * Only reset files to container if we're sure it received it * Return back to codesandbox.io * Remove old comment
- Loading branch information
1 parent
3dacc14
commit b315e5e
Showing
15 changed files
with
255 additions
and
125 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
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
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
53 changes: 0 additions & 53 deletions
53
packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Server/Status.js
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Server/Status.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,94 @@ | ||
// @flow | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import { | ||
SSEContainerStatus, | ||
SSEManagerStatus, | ||
} from '@codesandbox/common/lib/types'; | ||
|
||
type Props = { | ||
containerStatus: SSEContainerStatus; | ||
managerStatus: SSEManagerStatus; | ||
}; | ||
|
||
const StatusCircle = styled.div` | ||
border-radius: 50%; | ||
background-color: ${props => props.color}; | ||
width: 8px; | ||
height: 8px; | ||
margin-left: 0.75rem; /* Very precise to keep aligned with script icons */ | ||
margin-right: 0.75rem; | ||
`; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
color: ${props => | ||
props.theme['editor.foreground'] || 'rgba(255, 255, 255, 0.8)'}; | ||
`; | ||
|
||
const STATUS_MESSAGES = { | ||
disconnected: 'Reconnecting to sandbox...', | ||
connected: 'Connected to sandbox', | ||
initializing: 'Initializing connection to sandbox...', | ||
hibernated: 'Sandbox hibernated', | ||
error: 'Unrecoverable sandbox error', | ||
}; | ||
|
||
const STATUS_COLOR = { | ||
disconnected: '#FD2439', | ||
connected: '#4CFF00', | ||
initializing: '#FFD399', | ||
hibernated: '#FF662E', | ||
error: '#FD2439', | ||
}; | ||
|
||
function getContainerStatusMessageAndColor( | ||
containerStatus: SSEContainerStatus | ||
) { | ||
switch (containerStatus) { | ||
case 'initializing': | ||
return { color: '#FFD399', message: 'Container is starting...' }; | ||
case 'container-started': | ||
case 'stopped': | ||
return { color: '#FFD399', message: 'Sandbox is starting...' }; | ||
case 'sandbox-started': | ||
return { color: '#4CFF00', message: 'Connected to sandbox' }; | ||
case 'error': | ||
return { color: '#FD2439', message: 'A sandbox error occurred' }; | ||
case 'hibernated': | ||
return { color: '#FF662E', message: 'Sandbox hibernated' }; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
|
||
function getManagerStatusMessageAndColor(managerStatus: SSEManagerStatus) { | ||
switch (managerStatus) { | ||
case 'connected': | ||
case 'disconnected': | ||
return undefined; | ||
case 'initializing': | ||
return { | ||
message: 'Initializing connection to sandbox...', | ||
color: '#FFD399', | ||
}; | ||
default: | ||
return undefined; | ||
} | ||
} | ||
|
||
export default ({ containerStatus, managerStatus }: Props) => { | ||
const { color, message } = | ||
getManagerStatusMessageAndColor(managerStatus) || | ||
getContainerStatusMessageAndColor(containerStatus); | ||
return ( | ||
<Container> | ||
<StatusCircle color={color} /> | ||
|
||
{message} | ||
</Container> | ||
); | ||
}; |
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
Oops, something went wrong.