Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
feat: add sessionName in the attach to session dropdown (#1694)
Browse files Browse the repository at this point in the history
* feat: add sessionName in the attach to session dropdown

* add method formatCapsBrowserstack

* replace if..else with switch..case
  • Loading branch information
huzaifaiftikhar committed Mar 17, 2021
1 parent 03601e7 commit 413271f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions app/renderer/components/Session/AttachToSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SessionCSS from './Session.css';
import {
ReloadOutlined
} from '@ant-design/icons';
import {ServerTypes} from '../../actions/Session';

const FormItem = Form.Item;

Expand All @@ -15,14 +16,27 @@ function formatCaps (caps) {
return importantCaps.join(', ').trim();
}

function formatCapsBrowserstack (caps) {
let importantCaps = formatCaps(caps).split(', ');
if (caps.sessionName) {
importantCaps.push(caps.sessionName);
}
return importantCaps.join(', ').trim();
}

export default class AttachToSession extends Component {

getSessionInfo (session) {
return `${session.id}${formatCaps(session.capabilities)}`;
getSessionInfo (session, serverType) {
switch (serverType) {
case ServerTypes.browserstack:
return `${session.id}${formatCapsBrowserstack(session.capabilities)}`;
default:
return `${session.id}${formatCaps(session.capabilities)}`;
}
}

render () {
let {attachSessId, setAttachSessId, runningAppiumSessions, getRunningSessions, t} = this.props;
let {serverType, attachSessId, setAttachSessId, runningAppiumSessions, getRunningSessions, t} = this.props;
attachSessId = attachSessId || undefined;
return (<Form>
<FormItem>
Expand All @@ -40,7 +54,7 @@ export default class AttachToSession extends Component {
value={attachSessId}
onChange={(value) => setAttachSessId(value)}>
{runningAppiumSessions.map((session) => <Select.Option key={session.id} value={session.id}>
<div>{this.getSessionInfo(session)}</div>
<div>{this.getSessionInfo(session, serverType)}</div>
</Select.Option>)}
</Select>
</Col>
Expand Down

0 comments on commit 413271f

Please sign in to comment.