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

Commit

Permalink
Add sauce datacenters (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham authored May 2, 2019
1 parent 808a9d3 commit 9045f6c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
3 changes: 2 additions & 1 deletion app/renderer/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ export function newSession (caps, attachSessId = null) {
https = session.server.remote.ssl;
break;
case ServerTypes.sauce:
host = 'ondemand.saucelabs.com';
host = session.server.sauce.dataCenter === 'eu-central-1' ?
'ondemand.eu-central-1.saucelabs.com' : 'ondemand.saucelabs.com';
port = 80;
if (session.server.sauce.useSCProxy) {
host = session.server.sauce.scHost || 'localhost';
Expand Down
14 changes: 13 additions & 1 deletion app/renderer/components/Session/ServerTabSauce.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import { Form, Row, Col, Input, Checkbox } from 'antd';
import { Form, Row, Col, Input, Checkbox, Radio } from 'antd';
import SessionStyles from './Session.css';
const FormItem = Form.Item;

export default class ServerTabSauce extends Component {
Expand Down Expand Up @@ -28,6 +29,17 @@ export default class ServerTabSauce extends Component {
</FormItem>
</Col>
</Row>
<Row gutter={8}>
<Col span={24}>
<FormItem>
<div className={['ant-input-group-addon', SessionStyles.addonDataCenter].join(' ') }>{t('SauceLabs Data Center')}</div>
<Radio.Group className={SessionStyles.inputDataCenter} buttonStyle="solid" defaultValue='us-west-1' id='sauceObjectDataCenter' value={server.sauce.dataCenter} onChange={(e) => setServerParam('dataCenter', e.target.value)}>
<Radio value='us-west-1'>{t('US')}</Radio>
<Radio value='eu-central-1'>{t('EU')}</Radio>
</Radio.Group>
</FormItem>
</Col>
</Row>
<Row gutter={8}>
<Col span={10}>
<FormItem>
Expand Down
48 changes: 31 additions & 17 deletions app/renderer/reducers/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { NEW_SESSION_REQUESTED, NEW_SESSION_BEGAN, NEW_SESSION_DONE,
IS_ADDING_CLOUD_PROVIDER, SET_PROVIDERS,
ServerTypes } from '../actions/Session';


const visibleProviders = []; // Pull this from "electron-settings"
const server = {
local: {},
Expand All @@ -25,15 +24,30 @@ for (const serverName of _.keys(ServerTypes)) {
server[serverName] = {};
}

server.testobject.dataCenter = 'US';

// Make sure there's always at least one cap
const INITIAL_STATE = {
savedSessions: [],
tabKey: 'new',
serverType: ServerTypes.local,
server,
visibleProviders,
server: {
local: {},
remote: {},
sauce: {
dataCenter: 'us-west-1',
},
testobject: {
dataCenter: 'US',
},
headspin: {},
browserstack: {},
advanced: {},
bitbar: {},
kobiton: {},
perfecto: {},
pcloudy: {},
testingbot: {},
},
attachSessId: null,

// Make sure there's always at least one cap
Expand Down Expand Up @@ -182,20 +196,20 @@ export default function session (state = INITIAL_STATE, action) {
case SET_SERVER:
return {
...state,
// Only set remote and cloud providers;
// 'local' comes from electron-settings
server: {
...state.server,
remote: action.server.remote || {},
sauce: action.server.sauce || {},
testobject: action.server.testobject || {},
headspin: action.server.headspin || {},
browserstack: action.server.browserstack || {},
bitbar: action.server.bitbar || {},
kobiton: action.server.kobiton || {},
perfecto: action.server.perfecto || {},
pcloudy: action.server.pcloudy || {},
testingbot: action.server.testingbot || {},
...(function extendCurrentServerStateWithNewServerState (currentServerState, newServerState) {
// Copy current server state and extend it with new server state
const nextServerState = _.cloneDeep(currentServerState || {});

// Extend each server (sauce, testobject, remote, kobiton, etc...)
for (let serverName of _.keys(nextServerState)) {
nextServerState[serverName] = {
...(nextServerState[serverName] || {}),
...(newServerState[serverName] || {}),
};
}
return nextServerState;
})(state.server, action.server),
},
serverType: action.serverType || ServerTypes.local,
};
Expand Down
1 change: 1 addition & 0 deletions assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
"xCoordinate": "X: {{x}}",
"yCoordinate": "Y: {{y}}",
"TestObject Data Center": "TestObject Data Center",
"SauceLabs Data Center": "SauceLabs Data Center",
"US": "US",
"EU": "EU",
"proxyThroughSC": "Proxy through Sauce Connect's Selenium Relay",
Expand Down

0 comments on commit 9045f6c

Please sign in to comment.