Skip to content

Commit f04134c

Browse files
authored
style: use common refresh button in Attach to Session (#2756)
* chore: remove debounce for manual input for responsiveness This is better after the refactor, since only the ManualSessionIdInput component is refreshed now. * style: replace Form with Space * style: use common refresh button with custom text
1 parent 9c5b093 commit f04134c

File tree

7 files changed

+57
-94
lines changed

7 files changed

+57
-94
lines changed

app/common/public/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,5 +323,6 @@
323323
"useScreenshotApi": "Use Screenshot API",
324324
"Box Model": "Box Model",
325325
"detachFromSession": "Detach from Session",
326-
"enterSessionID": "Enter session ID for attaching manually"
326+
"enterSessionID": "Enter session ID for attaching manually",
327+
"refreshDiscoveredSessions": "Refresh Discovered Sessions"
327328
}

app/common/renderer/components/SessionBuilder/AttachToSessionTab/AttachToSession.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {Form, Spin} from 'antd';
1+
import {Empty, Space, Spin} from 'antd';
2+
import {useTranslation} from 'react-i18next';
23

34
import {getSessionInfo} from '../../../utils/attaching-to-session.js';
5+
import styles from './AttachToSession.module.css';
46
import AttachToSessionInstructions from './AttachToSessionInstructions.jsx';
57
import DiscoveredSessions from './DiscoveredSessions.jsx';
6-
import ManualSessionIdInput from './ManualSessionIdInput.jsx';
7-
import NoSessionsDiscovered from './NoSessionsDiscovered.jsx';
8+
import ManualIdInputAndRefreshBtn from './ManualIdInputAndRefreshBtn.jsx';
89

910
/**
1011
* The full Attach to Session tab.
@@ -18,29 +19,32 @@ const AttachToSession = ({
1819
getRunningSessions,
1920
loadNewSession,
2021
}) => {
22+
const {t} = useTranslation();
2123
// list is reversed in order to place the most recent sessions at the top
2224
// slice() is added because reverse() mutates the original array
2325
const sortedRunningSessions = [...runningAppiumSessions]
2426
.reverse()
2527
.map((session) => ({value: session.id, label: getSessionInfo(session, serverType)}));
2628

2729
return (
28-
<Form>
30+
<Space className={styles.spaceContainer} orientation="vertical" size="large">
2931
<AttachToSessionInstructions />
30-
<ManualSessionIdInput loadNewSession={loadNewSession} />
32+
<ManualIdInputAndRefreshBtn
33+
loadNewSession={loadNewSession}
34+
getRunningSessions={getRunningSessions}
35+
/>
3136
<Spin spinning={gettingSessions}>
3237
{sortedRunningSessions.length !== 0 ? (
3338
<DiscoveredSessions
3439
attachSessId={attachSessId}
3540
setAttachSessId={setAttachSessId}
36-
getRunningSessions={getRunningSessions}
3741
sortedRunningSessions={sortedRunningSessions}
3842
/>
3943
) : (
40-
<NoSessionsDiscovered getRunningSessions={getRunningSessions} />
44+
<Empty description={t('noRunningSessionsFound')} image={Empty.PRESENTED_IMAGE_SIMPLE} />
4145
)}
4246
</Spin>
43-
</Form>
47+
</Space>
4448
);
4549
};
4650

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.btnReload {
2-
float: right;
3-
margin-left: 8px;
1+
.spaceContainer {
2+
display: flex;
3+
word-break: break-word;
44
}

app/common/renderer/components/SessionBuilder/AttachToSessionTab/AttachToSessionInstructions.jsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Card, Form} from 'antd';
1+
import {Card} from 'antd';
22
import {useTranslation} from 'react-i18next';
33

44
import builderStyles from '../SessionBuilder.module.css';
@@ -10,15 +10,13 @@ const AttachToSessionInstructions = () => {
1010
const {t} = useTranslation();
1111

1212
return (
13-
<Form.Item>
14-
<Card>
15-
<p className={builderStyles.localDesc}>
16-
{t('connectToExistingSessionInstructions')}
17-
<br />
18-
{t('selectSessionID')}
19-
</p>
20-
</Card>
21-
</Form.Item>
13+
<Card>
14+
<p className={builderStyles.localDesc}>
15+
{t('connectToExistingSessionInstructions')}
16+
<br />
17+
{t('selectSessionID')}
18+
</p>
19+
</Card>
2220
);
2321
};
2422

app/common/renderer/components/SessionBuilder/AttachToSessionTab/DiscoveredSessions.jsx

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
1-
import {IconRefresh} from '@tabler/icons-react';
2-
import {Button, Col, Form, Row, Select, Tooltip} from 'antd';
1+
import {Col, Row, Select} from 'antd';
32
import {useTranslation} from 'react-i18next';
43

5-
import styles from './AttachToSession.module.css';
6-
74
/**
8-
* Selection dropdown for all discovered sessions, and a button to refresh the session list.
5+
* Selection dropdown for all discovered sessions.
96
*/
10-
const DiscoveredSessions = ({
11-
attachSessId,
12-
setAttachSessId,
13-
getRunningSessions,
14-
sortedRunningSessions,
15-
}) => {
7+
const DiscoveredSessions = ({attachSessId, setAttachSessId, sortedRunningSessions}) => {
168
const {t} = useTranslation();
179

1810
return (
19-
<Form.Item>
20-
<Row>
21-
<Col span={23}>
22-
<Select
23-
showSearch
24-
placeholder={t('searchSessions')}
25-
value={attachSessId || undefined}
26-
onChange={(value) => setAttachSessId(value)}
27-
options={sortedRunningSessions}
28-
/>
29-
</Col>
30-
<Col span={1}>
31-
<Tooltip title={t('Reload')}>
32-
<Button
33-
className={styles.btnReload}
34-
onClick={getRunningSessions}
35-
icon={<IconRefresh size={18} />}
36-
/>
37-
</Tooltip>
38-
</Col>
39-
</Row>
40-
</Form.Item>
11+
<Row>
12+
<Col span={24}>
13+
<Select
14+
style={{width: '100%'}}
15+
showSearch
16+
placeholder={t('searchSessions')}
17+
value={attachSessId || undefined}
18+
onChange={(value) => setAttachSessId(value)}
19+
options={sortedRunningSessions}
20+
/>
21+
</Col>
22+
</Row>
4123
);
4224
};
4325

app/common/renderer/components/SessionBuilder/AttachToSessionTab/ManualSessionIdInput.jsx renamed to app/common/renderer/components/SessionBuilder/AttachToSessionTab/ManualIdInputAndRefreshBtn.jsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
import {IconLinkPlus} from '@tabler/icons-react';
2-
import {Button, Col, Form, Input, Row} from 'antd';
3-
import _ from 'lodash';
4-
import {useRef, useState} from 'react';
1+
import {IconLinkPlus, IconRefresh} from '@tabler/icons-react';
2+
import {Button, Col, Input, Row, Space} from 'antd';
3+
import {useState} from 'react';
54
import {useTranslation} from 'react-i18next';
65

76
import {BUTTON} from '../../../constants/antd-types.js';
87

98
/**
10-
* Input field and button for manually entering a session ID to attach to.
9+
* Input field and button for manually entering a session ID to attach to,
10+
* as well as a button to refresh the list of discovered sessions.
1111
*/
12-
const ManualSessionIdInput = ({loadNewSession}) => {
12+
const ManualIdInputAndRefreshBtn = ({loadNewSession, getRunningSessions}) => {
1313
const {t} = useTranslation();
1414
const [manualSessionId, setManualSessionId] = useState(null);
15-
const debouncedSetManualSessionId = useRef(
16-
_.debounce((value) => setManualSessionId(value), 200),
17-
).current;
1815

1916
return (
20-
<Form.Item>
21-
<Row gutter={8}>
22-
<Col span={8} offset={6}>
17+
<Row justify="space-around">
18+
<Col span={12}>
19+
<Space.Compact block>
2320
<Input
2421
placeholder={t('enterSessionID')}
2522
allowClear={true}
26-
onChange={(e) => debouncedSetManualSessionId(e.target.value)}
23+
onChange={(e) => setManualSessionId(e.target.value)}
2724
/>
28-
</Col>
29-
<Col span={4}>
3025
<Button
3126
type={BUTTON.PRIMARY}
3227
disabled={!manualSessionId || manualSessionId.trim() === ''}
@@ -35,10 +30,13 @@ const ManualSessionIdInput = ({loadNewSession}) => {
3530
>
3631
{t('attachToSession')}
3732
</Button>
38-
</Col>
39-
</Row>
40-
</Form.Item>
33+
</Space.Compact>
34+
</Col>
35+
<Button onClick={getRunningSessions} icon={<IconRefresh size={18} />}>
36+
{t('refreshDiscoveredSessions')}
37+
</Button>
38+
</Row>
4139
);
4240
};
4341

44-
export default ManualSessionIdInput;
42+
export default ManualIdInputAndRefreshBtn;

app/common/renderer/components/SessionBuilder/AttachToSessionTab/NoSessionsDiscovered.jsx

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)