Skip to content

Commit e449c88

Browse files
authored
[INS-1840] Add Connected Status Label and Extras (#5131)
* add status related changes * text label change
1 parent 8132f9f commit e449c88

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

packages/insomnia/src/ui/components/websockets/action-bar.tsx

+28-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import styled from 'styled-components';
33

44
import { ReadyState } from '../../context/websocket-client/use-ws-ready-state';
55

6-
const Button = styled.button({
6+
const Button = styled.button<{ warning?: boolean }>(({ warning }) => ({
77
paddingRight: 'var(--padding-md)',
88
paddingLeft: 'var(--padding-md)',
99
textAlign: 'center',
10-
background: 'var(--color-surprise)',
10+
background: warning ? 'var(--color-danger)' : 'var(--color-surprise)',
1111
color: 'var(--color-font-surprise)',
1212
flex: '0 0 100px',
1313
':hover': {
1414
filter: 'brightness(0.8)',
1515
},
16-
});
16+
}));
1717

1818
interface ActionButtonProps {
1919
requestId: string;
@@ -38,11 +38,12 @@ const ActionButton: FC<ActionButtonProps> = ({ requestId, readyState }) => {
3838
className="urlbar__send-btn"
3939
name="websocketActionCloseBtn"
4040
type="button"
41+
warning
4142
onClick={() => {
4243
window.main.webSocketConnection.close({ requestId });
4344
}}
4445
>
45-
Close
46+
Disconnect
4647
</Button>
4748
);
4849
};
@@ -72,20 +73,40 @@ const WebSocketIcon = styled.span({
7273
color: 'var(--color-notice)',
7374
display: 'flex',
7475
alignItems: 'center',
75-
paddingRight: 'var(--padding-md)',
7676
paddingLeft: 'var(--padding-md)',
7777
});
7878

79+
const ConnectionStatus = styled.span({
80+
color: 'var(--color-success)',
81+
display: 'flex',
82+
alignItems: 'center',
83+
paddingLeft: 'var(--padding-md)',
84+
});
85+
const ConnectionCircle = styled.span({
86+
backgroundColor: 'var(--color-success)',
87+
marginRight: 'var(--padding-sm)',
88+
width: 10,
89+
height: 10,
90+
borderRadius: '50%',
91+
});
92+
7993
export const WebSocketActionBar: FC<ActionBarProps> = ({ requestId, workspaceId, defaultValue, onChange, readyState }) => {
94+
const isOpen = readyState === ReadyState.OPEN;
8095
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
8196
event.preventDefault();
8297
window.main.webSocketConnection.create({ requestId, workspaceId });
8398
};
8499

85100
return (
86101
<>
87-
<WebSocketIcon>WS</WebSocketIcon>
88-
<Form aria-disabled={readyState === ReadyState.OPEN} id="websocketUrlForm" onSubmit={handleSubmit}>
102+
{!isOpen && <WebSocketIcon>WS</WebSocketIcon>}
103+
{isOpen && (
104+
<ConnectionStatus>
105+
<ConnectionCircle />
106+
CONNECTED
107+
</ConnectionStatus>
108+
)}
109+
<Form aria-disabled={isOpen} id="websocketUrlForm" onSubmit={handleSubmit}>
89110
<Input
90111
name="websocketUrlInput"
91112
disabled={readyState === ReadyState.OPEN}

0 commit comments

Comments
 (0)